aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-01-27 10:27:42 +1030
committerAlan Modra <amodra@gmail.com>2020-01-27 10:53:00 +1030
commit3024a17ae029ec7f55b498e99ddd6238e22fe565 (patch)
tree554320c69f99bb0a36f8301e9bcfe539873f6f20 /bfd
parent27ee3a66bfba776a2af8e9e1248e6a65c31e25a3 (diff)
downloadgdb-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')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c18
2 files changed, 17 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 558e11e..3deba43 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-01-27 H.J. Lu <hongjiu.lu@intel.com>
+ Alan Modra <amodra@gmail.com>
+
+ PR ld/25458
+ * elflink.c (_bfd_elf_gc_mark_rsec): Mark all weak aliases.
+
2020-01-24 Jim Wilson <jimw@sifive.com>
* elfxx-riscv.c (riscv_get_prefix_class): Format s case like others.
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)
{