diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-07-21 10:35:58 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-07-21 11:40:27 -0700 |
commit | 8f29211c3f0a6335c17e0a90396c146facf6dba4 (patch) | |
tree | 5f38e50ea5188f6e4588ca968bec955c03a8e3b0 /bfd | |
parent | c44885db3b56c83a12e88a176c03f2a2268428b8 (diff) | |
download | gdb-8f29211c3f0a6335c17e0a90396c146facf6dba4.zip gdb-8f29211c3f0a6335c17e0a90396c146facf6dba4.tar.gz gdb-8f29211c3f0a6335c17e0a90396c146facf6dba4.tar.bz2 |
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/elf32-i386.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index cfb0085..52b1db4 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2460,6 +2460,11 @@ elf_i386_relocate_section (bfd *output_bfd, goto do_relocation; case R_386_GOTOFF: + /* NB: 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. */ + if (bfd_link_pic (info)) + goto bad_ifunc_reloc; relocation -= (gotplt->output_section->vma + gotplt->output_offset); goto do_relocation; |