diff options
author | Alan Modra <amodra@gmail.com> | 2020-01-27 10:27:42 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-01-27 10:53:00 +1030 |
commit | 3024a17ae029ec7f55b498e99ddd6238e22fe565 (patch) | |
tree | 554320c69f99bb0a36f8301e9bcfe539873f6f20 /bfd/elflink.c | |
parent | 27ee3a66bfba776a2af8e9e1248e6a65c31e25a3 (diff) | |
download | gdb-3024a17ae029ec7f55b498e99ddd6238e22fe565.zip gdb-3024a17ae029ec7f55b498e99ddd6238e22fe565.tar.gz gdb-3024a17ae029ec7f55b498e99ddd6238e22fe565.tar.bz2 |
Mark all weak aliases for copy relocations
bfd/
PR ld/25458
* elflink.c (_bfd_elf_gc_mark_rsec): Mark all weak aliases.
ld/
PR ld/25458
* testsuite/ld-elf/pr25458.map: New file.
* testsuite/ld-elf/pr25458.rd: Likewise.
* testsuite/ld-elf/pr25458a.s: Likewise.
* testsuite/ld-elf/pr25458b.s: Likewise.
* testsuite/ld-elf/shared.exp: Run PR ld/25458 test.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 300be3f..5217528 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -13123,7 +13123,7 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec, bfd_boolean *start_stop) { unsigned long r_symndx; - struct elf_link_hash_entry *h; + struct elf_link_hash_entry *h, *hw; r_symndx = cookie->rel->r_info >> cookie->r_sym_shift; if (r_symndx == STN_UNDEF) @@ -13143,12 +13143,16 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec, || h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; h->mark = 1; - /* If this symbol is weak and there is a non-weak definition, we - keep the non-weak definition because many backends put - dynamic reloc info on the non-weak definition for code - handling copy relocs. */ - if (h->is_weakalias) - weakdef (h)->mark = 1; + /* Keep all aliases of the symbol too. If an object symbol + needs to be copied into .dynbss then all of its aliases + should be present as dynamic symbols, not just the one used + on the copy relocation. */ + hw = h; + while (hw->is_weakalias) + { + hw = hw->u.alias; + hw->mark = 1; + } if (start_stop != NULL) { |