[hjl@gnu-tgl-2 pr83782]$ cat test.s .text .p2align 4 .type my_foo, @function my_foo: ret .size my_foo, .-my_foo .p2align 4 .type resolve_foo, @function resolve_foo: leal my_foo@GOTOFF(%eax), %eax ret .size resolve_foo, .-resolve_foo .type foo, @gnu_indirect_function .set foo,resolve_foo .p2align 4 .globl bar .type bar, @function bar: leal foo@GOTOFF(%eax), %eax ret [hjl@gnu-tgl-2 pr83782]$ gcc -m32 -c test.s [hjl@gnu-tgl-2 pr83782]$ ld -m elf_i386 -o libtest.so -shared test.o ld: test.o: relocation R_386_GOTOFF against STT_GNU_IFUNC symbol `foo' isn't supported ld: final link failed: bad value [hjl@gnu-tgl-2 pr83782]$
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=406b4ada55b2957c10fedaeaada801e77912d976 commit 406b4ada55b2957c10fedaeaada801e77912d976 Author: H.J. Lu <hjl.tools@gmail.com> Date: Sat Jun 19 20:20:52 2021 -0700 x86: Count PLT for GOTOFF relocation against IFUNC symbol Since GOTOFF relocations against IFUNC symbols must go through PLT, set PLT reference count to 1 for GOTOFF relocation. bfd/ PR ld/27998 * elfxx-x86.c (elf_x86_allocate_dynrelocs): Count PLT for GOTOFF relocation against IFUNC symbols. (_bfd_x86_elf_adjust_dynamic_symbol): Likewise. ld/ PR ld/27998 * testsuite/ld-i386/i386.exp: Run PR ld/27998 tests. * testsuite/ld-i386/pr27998a.d: New file. * testsuite/ld-i386/pr27998a.s: Likewise. * testsuite/ld-i386/pr27998b.d: Likewise. * testsuite/ld-i386/pr27998b.s: Likewise.
Fixed for 2.37.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8f29211c3f0a6335c17e0a90396c146facf6dba4 commit 8f29211c3f0a6335c17e0a90396c146facf6dba4 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Jul 21 10:35:58 2022 -0700 i386: Don't allow GOTOFF relocation against IFUNC symbol for PIC We can't use the PLT entry as the function address for PIC since the PIC register may not be set up properly for indirect call. bfd/ PR ld/27998 * elf32-i386.c (elf_i386_relocate_section): Don't allow GOTOFF relocation against IFUNC symbol for PIC. ld/ PR ld/27998 * testsuite/ld-i386/pr27998a.d: Replace -shared with -e bar. * testsuite/ld-i386/pr27998b.d: Expect a linker error. * testsuite/ld-ifunc/ifunc-2-i386-now.d: Updated. * testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-i386.s: Replace @GOTOFF with @GOT. * testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise.
The binutils-2_39-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=28067e797c50eaf33bf24619aea97d3350db69e5 commit 28067e797c50eaf33bf24619aea97d3350db69e5 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Jul 21 10:35:58 2022 -0700 i386: Don't allow GOTOFF relocation against IFUNC symbol for PIC We can't use the PLT entry as the function address for PIC since the PIC register may not be set up properly for indirect call. bfd/ PR ld/27998 * elf32-i386.c (elf_i386_relocate_section): Don't allow GOTOFF relocation against IFUNC symbol for PIC. ld/ PR ld/27998 * testsuite/ld-i386/pr27998a.d: Replace -shared with -e bar. * testsuite/ld-i386/pr27998b.d: Expect a linker error. * testsuite/ld-ifunc/ifunc-2-i386-now.d: Updated. * testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-i386.s: Replace @GOTOFF with @GOT. * testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise. (cherry picked from commit 8f29211c3f0a6335c17e0a90396c146facf6dba4)
The binutils-2_38-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5c0b4ee406035917d0e50aa138194fab57ae6bf8 commit 5c0b4ee406035917d0e50aa138194fab57ae6bf8 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Jul 21 10:35:58 2022 -0700 i386: Don't allow GOTOFF relocation against IFUNC symbol for PIC We can't use the PLT entry as the function address for PIC since the PIC register may not be set up properly for indirect call. bfd/ PR ld/27998 * elf32-i386.c (elf_i386_relocate_section): Don't allow GOTOFF relocation against IFUNC symbol for PIC. ld/ PR ld/27998 * testsuite/ld-i386/pr27998a.d: Replace -shared with -e bar. * testsuite/ld-i386/pr27998b.d: Expect a linker error. * testsuite/ld-ifunc/ifunc-2-i386-now.d: Updated. * testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-i386.s: Replace @GOTOFF with @GOT. * testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise. (cherry picked from commit 8f29211c3f0a6335c17e0a90396c146facf6dba4)