Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171009658
D55082.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55082.diff
View Options
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -119,10 +119,9 @@
LDFLAGS+= --build-id=sha1
.endif
-.if ${MACHINE_CPUARCH} != "riscv" && \
- defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == "" && \
+.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == "" && \
!make(install)
-.error amd64/arm/arm64/i386/ppc* kernel requires linker ifunc support
+.error kernel requires linker ifunc support
.endif
.if ${MACHINE_CPUARCH} == "amd64"
LDFLAGS+= -z max-page-size=2097152
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -2041,7 +2041,6 @@
}
#endif
-#if !defined(__riscv)
/*
* Use this lookup routine when performing relocations early during boot.
* The generic lookup routine depends on kobj, which is not initialized
@@ -2104,4 +2103,3 @@
relocate_file1(ef, elf_lookup_ifunc, elf_reloc_late, true);
}
#endif
-#endif
diff --git a/sys/riscv/include/ifunc.h b/sys/riscv/include/ifunc.h
--- a/sys/riscv/include/ifunc.h
+++ b/sys/riscv/include/ifunc.h
@@ -30,8 +30,6 @@
#ifndef __RISCV_IFUNC_H
#define __RISCV_IFUNC_H
-#define __DO_NOT_HAVE_SYS_IFUNCS 1
-
#define DEFINE_IFUNC(qual, ret_type, name, args) \
static ret_type (*name##_resolver(void))args __used; \
qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
diff --git a/sys/riscv/riscv/elf_machdep.c b/sys/riscv/riscv/elf_machdep.c
--- a/sys/riscv/riscv/elf_machdep.c
+++ b/sys/riscv/riscv/elf_machdep.c
@@ -271,10 +271,10 @@
}
bool
-elf_is_ifunc_reloc(Elf_Size r_info __unused)
+elf_is_ifunc_reloc(Elf_Size r_info)
{
- return (false);
+ return (ELF_R_TYPE(r_info) == R_RISCV_IRELATIVE);
}
/*
@@ -501,7 +501,12 @@
(local ? 'l' : 'g'), reloctype_to_str(rtype),
before32, *insn32p);
break;
-
+ case R_RISCV_IRELATIVE:
+ addr = relocbase + addend;
+ val = ((Elf64_Addr (*)(void))addr)();
+ if (*where != val)
+ *where = val;
+ break;
default:
printf("kldload: unexpected relocation type %ld, "
"symbol index %ld\n", rtype, symidx);
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c
--- a/sys/riscv/riscv/machdep.c
+++ b/sys/riscv/riscv/machdep.c
@@ -479,8 +479,6 @@
/* Initialize preload_kmdp */
preload_initkmdp(true);
- sched_instance_select();
- /* link_elf_ireloc(); */
/* Read the boot metadata */
boothowto = MD_FETCH(preload_kmdp, MODINFOMD_HOWTO, int);
@@ -626,6 +624,10 @@
*/
identify_cpu(0);
+ sched_instance_select();
+
+ link_elf_ireloc();
+
/* Do basic tuning, hz etc */
init_param1();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Sep 9, 4:18 AM (10 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38561109
Default Alt Text
D55082.diff (2 KB)
Attached To
Mode
D55082: riscv: implement kernel ifunc resolution
Attached
Detach File
Event Timeline
Log In to Comment