Page MenuHomeFreeBSD

D54970.diff
No OneTemporary

D54970.diff

diff --git a/sys/arm/arm/elf_machdep.c b/sys/arm/arm/elf_machdep.c
--- a/sys/arm/arm/elf_machdep.c
+++ b/sys/arm/arm/elf_machdep.c
@@ -150,7 +150,7 @@
elf_is_ifunc_reloc(Elf_Size r_info __unused)
{
- return (false);
+ return (ELF_R_TYPE(r_info) == R_ARM_IRELATIVE);
}
/*
@@ -253,6 +253,12 @@
case R_ARM_RELATIVE:
break;
+ case R_ARM_IRELATIVE:
+ addr = relocbase + addend;
+ addr = ((Elf_Addr (*)(void))addr)();
+ if (*where != addr)
+ *where = addr;
+ break;
default:
printf("kldload: unexpected relocation type %d, "
"symbol index %d\n", rtype, symidx);
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c
--- a/sys/arm/arm/machdep.c
+++ b/sys/arm/arm/machdep.c
@@ -447,6 +447,8 @@
set_cpufuncs();
cpuinfo_init();
+ sched_instance_select();
+ link_elf_ireloc();
/*
* Find the dtb passed in by the boot loader.
@@ -523,9 +525,6 @@
/* Do basic tuning, hz etc */
init_param1();
- sched_instance_select();
- /* link_elf_ireloc(); */
-
/*
* Allocate a page for the system page mapped to 0xffff0000
* This page will just contain the system vectors and can be
diff --git a/sys/arm/include/ifunc.h b/sys/arm/include/ifunc.h
--- a/sys/arm/include/ifunc.h
+++ b/sys/arm/include/ifunc.h
@@ -1,10 +1,28 @@
-/*
- * This file is in the public domain.
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025, Michal Meloun <mmel@freebsd.org>
+ *
*/
#ifndef __ARM_IFUNC_H
#define __ARM_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"))); \
+ static ret_type (*name##_resolver(void))args
+
+#ifdef __not_yet__
+#define DEFINE_UIFUNC(qual, ret_type, name, args) \
+ static ret_type (*name##_resolver(uint32_t, uint32_t, uint32_t, \
+ uint32_t))args __used; \
+ qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
+ static ret_type (*name##_resolver( \
+ uint32_t elf_hwcap __unused, \
+ uint32_t elf_hwcap2 __unused, \
+ uint32_t arg3 __unused, \
+ uint32_t arg4 __unused))args
+#endif
#endif
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,11 +119,10 @@
LDFLAGS+= --build-id=sha1
.endif
-.if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
- ${MACHINE_CPUARCH} == "i386" || ${MACHINE} == "powerpc") && \
+.if ${MACHINE_CPUARCH} != "riscv" && \
defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == "" && \
!make(install)
-.error amd64/arm64/i386/ppc* kernel requires linker ifunc support
+.error amd64/arm/arm64/i386/ppc* 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,7 @@
}
#endif
-#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__) || defined(__powerpc__)
+#if !defined(__riscv)
/*
* Use this lookup routine when performing relocations early during boot.
* The generic lookup routine depends on kobj, which is not initialized
diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h
--- a/sys/sys/elf_common.h
+++ b/sys/sys/elf_common.h
@@ -1122,6 +1122,7 @@
#define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */
#define R_ARM_GNU_VTENTRY 100
#define R_ARM_GNU_VTINHERIT 101
+#define R_ARM_IRELATIVE 160
#define R_ARM_RSBREL32 250
#define R_ARM_THM_RPC22 251
#define R_ARM_RREL32 252

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 16, 7:04 AM (18 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35128286
Default Alt Text
D54970.diff (3 KB)

Event Timeline