i386: Don't allow GOTOFF relocation against IFUNC symbol for PIC
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 21 Jul 2022 17:35:58 +0000 (10:35 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 21 Jul 2022 18:40:27 +0000 (11:40 -0700)
commit8f29211c3f0a6335c17e0a90396c146facf6dba4
tree5f38e50ea5188f6e4588ca968bec955c03a8e3b0
parentc44885db3b56c83a12e88a176c03f2a2268428b8
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.
bfd/elf32-i386.c
ld/testsuite/ld-i386/pr27998a.d
ld/testsuite/ld-i386/pr27998b.d
ld/testsuite/ld-ifunc/ifunc-2-i386-now.d
ld/testsuite/ld-ifunc/ifunc-2-i386.s
ld/testsuite/ld-ifunc/ifunc-2-local-i386-now.d
ld/testsuite/ld-ifunc/ifunc-2-local-i386.s