diff options
author | Tristan Gingold <gingold@adacore.com> | 2017-03-31 15:25:18 +0200 |
---|---|---|
committer | Tristan Gingold <gingold@adacore.com> | 2017-04-07 10:03:17 +0200 |
commit | 1fd6d111905e76dfa7af9fbee5229f3f1d360b4c (patch) | |
tree | cb8f9e966484f2911a9ef1f3d0df62d338701922 /bfd | |
parent | 436252de3e9de546001c4312d0863ce7e10aa200 (diff) | |
download | gdb-1fd6d111905e76dfa7af9fbee5229f3f1d360b4c.zip gdb-1fd6d111905e76dfa7af9fbee5229f3f1d360b4c.tar.gz gdb-1fd6d111905e76dfa7af9fbee5229f3f1d360b4c.tar.bz2 |
pe/coff: handle weak defined symbol for gc-sections.
bfd/
* coffgen.c (_bfd_coff_gc_mark_hook): Handle PE weak
external symbols with a definition.
(_bfd_coff_gc_mark_extra_sections): Fix typo.
ld/
* testsuite/ld-pe/pe.exp: New test.
* testsuite/ld-pe/weakdef-1.s: New test source.
* testsuite/ld-pe/weakdef-1.d: New test.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/coffgen.c | 18 |
2 files changed, 22 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a1ab388..d912e1a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2017-04-07 gingold <gingold@gingold-Precision-7510> + + * coffgen.c (_bfd_coff_gc_mark_hook): Handle PE weak + external symbols with a definition. + (_bfd_coff_gc_mark_extra_sections): Fix typo. + 2017-04-07 Alan Modra <amodra@gmail.com> * po/SRC-POTFILES.in: Regenerate. diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 3c60ed4..18f423b 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -2785,8 +2785,22 @@ _bfd_coff_gc_mark_hook (asection *sec, case bfd_link_hash_common: return h->root.u.c.p->section; - case bfd_link_hash_undefined: case bfd_link_hash_undefweak: + if (h->symbol_class == C_NT_WEAK && h->numaux == 1) + { + /* PE weak externals. A weak symbol may include an auxiliary + record indicating that if the weak symbol is not resolved, + another external symbol is used instead. */ + struct coff_link_hash_entry *h2 = + h->auxbfd->tdata.coff_obj_data->sym_hashes[ + h->aux->x_sym.x_tagndx.l]; + + if (h2 && h2->root.type != bfd_link_hash_undefined) + return h2->root.u.def.section; + } + break; + + case bfd_link_hash_undefined: default: break; } @@ -2897,7 +2911,7 @@ _bfd_coff_gc_mark_extra_sections (struct bfd_link_info *info, asection *isec; bfd_boolean some_kept; - if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) + if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour) continue; /* Ensure all linker created sections are kept, and see whether |