git: c84617e87a70 - main - i386: Switch to PIC kernel modules

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Wed, 19 Jul 2023 18:21:36 UTC
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=c84617e87a70f4aea5df46fa521835aefa7d8163

commit c84617e87a70f4aea5df46fa521835aefa7d8163
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-07-19 18:21:04 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-07-19 18:21:04 +0000

    i386: Switch to PIC kernel modules
    
    It seems since the last llvm project update, the lld linker has started
    creating a PLT dependent kernel module object files.
    
    Reviewed by:            kib, jhb, emaste
    Differential Revision:  https://reviews.freebsd.org/D41088
---
 sys/conf/kmod.mk            | 2 +-
 sys/i386/i386/elf_machdep.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index 246af5ba1e81..a83d64eb8bf7 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -166,7 +166,7 @@ CFLAGS+=	-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" || \
-    ${MACHINE_CPUARCH} == "powerpc"
+    ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "i386"
 CFLAGS+=	-fPIC
 .endif
 
diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c
index d8b7ab9c586b..5d8b41a16672 100644
--- a/sys/i386/i386/elf_machdep.c
+++ b/sys/i386/i386/elf_machdep.c
@@ -244,6 +244,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
 			break;
 
 		case R_386_GLOB_DAT:	/* S */
+		case R_386_JMP_SLOT:	/* S */
 			error = lookup(lf, symidx, 1, &addr);
 			if (error != 0)
 				return (-1);