1 From f5edd1ac0e79c0356c6a1e2beffcadc0c532be98 Mon Sep 17 00:00:00 2001
2 From: Alan Modra <amodra@bigpond.net.au>
3 Date: Wed, 8 Feb 2012 10:12:19 +0000
4 Subject: [PATCH] * elflink.c (_bfd_elf_gc_mark_rsec): Mark weakdef syms too.
5 (_bfd_elf_fix_symbol_flags): When a weakdef is def_regular, clear
6 the correct h->u.weakdef.
9 bfd/ChangeLog | 6 ++++++
10 bfd/elflink.c | 26 +++++++++++++++-----------
11 2 files changed, 21 insertions(+), 11 deletions(-)
13 diff --git a/bfd/elflink.c b/bfd/elflink.c
14 index 1d1ca0b..7f9ec60 100644
17 @@ -2510,23 +2510,21 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h,
18 over to the real definition. */
19 if (h->u.weakdef != NULL)
21 - struct elf_link_hash_entry *weakdef;
23 - weakdef = h->u.weakdef;
24 - while (h->root.type == bfd_link_hash_indirect)
25 - h = (struct elf_link_hash_entry *) h->root.u.i.link;
27 - BFD_ASSERT (h->root.type == bfd_link_hash_defined
28 - || h->root.type == bfd_link_hash_defweak);
29 - BFD_ASSERT (weakdef->def_dynamic);
31 /* If the real definition is defined by a regular object file,
32 don't do anything special. See the longer description in
33 _bfd_elf_adjust_dynamic_symbol, below. */
34 - if (weakdef->def_regular)
35 + if (h->u.weakdef->def_regular)
39 + struct elf_link_hash_entry *weakdef = h->u.weakdef;
41 + while (h->root.type == bfd_link_hash_indirect)
42 + h = (struct elf_link_hash_entry *) h->root.u.i.link;
44 + BFD_ASSERT (h->root.type == bfd_link_hash_defined
45 + || h->root.type == bfd_link_hash_defweak);
46 + BFD_ASSERT (weakdef->def_dynamic);
47 BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined
48 || weakdef->root.type == bfd_link_hash_defweak);
49 (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef, h);
50 @@ -11575,6 +11573,12 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
51 || h->root.type == bfd_link_hash_warning)
52 h = (struct elf_link_hash_entry *) h->root.u.i.link;
54 + /* If this symbol is weak and there is a non-weak definition, we
55 + keep the non-weak definition because many backends put
56 + dynamic reloc info on the non-weak definition for code
57 + handling copy relocs. */
58 + if (h->u.weakdef != NULL)
59 + h->u.weakdef->mark = 1;
60 return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);