aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-06-15 12:10:06 +0930
committerAlan Modra <amodra@gmail.com>2020-06-15 12:10:06 +0930
commit75cfe082c067db0b12fb982de0833309e454a8e2 (patch)
tree849f43dd0057e20e947e5f5fd8b7f80c7382e645 /bfd/elflink.c
parentcda58d5f970d0257749d549aee9c0e2bfb4a1fe8 (diff)
downloadbinutils-75cfe082c067db0b12fb982de0833309e454a8e2.zip
binutils-75cfe082c067db0b12fb982de0833309e454a8e2.tar.gz
binutils-75cfe082c067db0b12fb982de0833309e454a8e2.tar.bz2
PR26103, Assertion failure with symbols defined in link-once sections
PR 26103 * elflink.c (elf_link_add_archive_symbols): Exclude undefined symbols that were defined in discarded sections. * cofflink.c (coff_link_check_archive_element): Likewise. (coff_link_add_symbols): Set indx to -3 for symbols defined in discarded sections. (_bfd_coff_write_global_sym): Don't emit such symbols. libcoff-in.h (struct coff_link_hash_entry): Update indx comment. libcoff.h: Regenerate.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 3e56a29..ac00f29 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5813,7 +5813,15 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
if (h == NULL)
continue;
- if (h->root.type == bfd_link_hash_common)
+ if (h->root.type == bfd_link_hash_undefined)
+ {
+ /* If the archive element has already been loaded then one
+ of the symbols defined by that element might have been
+ made undefined due to being in a discarded section. */
+ if (h->indx == -3)
+ continue;
+ }
+ else if (h->root.type == bfd_link_hash_common)
{
/* We currently have a common symbol. The archive map contains
a reference to this symbol, so we may want to include it. We
@@ -5830,7 +5838,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
if (! elf_link_is_defined_archive_symbol (abfd, symdef))
continue;
}
- else if (h->root.type != bfd_link_hash_undefined)
+ else
{
if (h->root.type != bfd_link_hash_undefweak)
/* Symbol must be defined. Don't check it again. */