From c683c18298788eb517a6d10b7adc55678a7cdef5 Mon Sep 17 00:00:00 2001 From: dim Date: Tue, 18 Sep 2018 20:46:55 +0000 Subject: [PATCH] MFC r309748 (by glebius): Treat R_X86_64_PLT32 relocs as R_X86_64_PC32. If we load a binary that is designed to be a library, it produces relocatable code via assembler directives in the assembly itself (rather than compiler options). This emits R_X86_64_PLT32 relocations, which are not handled by the kernel linker. Submitted by: gallatin Reviewed by: kib PR: 231451 git-svn-id: svn://svn.freebsd.org/base/stable/9@338756 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/amd64/amd64/elf_machdep.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c index 38a11c680..1b1c738f1 100644 --- a/sys/amd64/amd64/elf_machdep.c +++ b/sys/amd64/amd64/elf_machdep.c @@ -163,6 +163,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, switch (rtype) { case R_X86_64_PC32: case R_X86_64_32S: + case R_X86_64_PLT32: addend = *(Elf32_Addr *)where; break; default: @@ -196,6 +197,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, break; case R_X86_64_PC32: /* S + A - P */ + case R_X86_64_PLT32: /* L + A - P, L is PLT location for + the symbol, which we treat as S */ addr = lookup(lf, symidx, 1); where32 = (Elf32_Addr *)where; val32 = (Elf32_Addr)(addr + addend - (Elf_Addr)where); -- 2.42.0