diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-06-19 20:20:52 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-06-19 20:21:04 -0700 |
commit | 406b4ada55b2957c10fedaeaada801e77912d976 (patch) | |
tree | e53f5b5356ec93296df94c593b8d6617681c1e49 /bfd | |
parent | 7e3941ac0619431d51a9643e20cb0e0720502101 (diff) | |
download | gdb-406b4ada55b2957c10fedaeaada801e77912d976.zip gdb-406b4ada55b2957c10fedaeaada801e77912d976.tar.gz gdb-406b4ada55b2957c10fedaeaada801e77912d976.tar.bz2 |
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elfxx-x86.c | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5211e98..212fe33 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,12 @@ 2021-06-19 H.J. Lu <hongjiu.lu@intel.com> + 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. + +2021-06-19 H.J. Lu <hongjiu.lu@intel.com> + * elflink.c (bfd_elf_final_link): Correct DT_TEXTREL warning in PDE. diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 62d516a..088f6e5 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -131,6 +131,10 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (h->type == STT_GNU_IFUNC && h->def_regular) { + /* GOTOFF relocation needs PLT. */ + if (eh->gotoff_ref) + h->plt.refcount = 1; + if (_bfd_elf_allocate_ifunc_dyn_relocs (info, h, &h->dyn_relocs, plt_entry_size, (htab->plt.has_plt0 @@ -1818,6 +1822,8 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info, const struct elf_backend_data *bed = get_elf_backend_data (info->output_bfd); + eh = (struct elf_x86_link_hash_entry *) h; + /* STT_GNU_IFUNC symbol must go through PLT. */ if (h->type == STT_GNU_IFUNC) { @@ -1856,6 +1862,10 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->plt.refcount += 1; } } + + /* GOTOFF relocation needs PLT. */ + if (eh->gotoff_ref) + h->plt.refcount = 1; } if (h->plt.refcount <= 0) @@ -1896,8 +1906,6 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info, the link may change h->type. So fix it now. */ h->plt.offset = (bfd_vma) -1; - eh = (struct elf_x86_link_hash_entry *) h; - /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ |