diff options
author | Alan Modra <amodra@gmail.com> | 2020-06-15 12:10:06 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-06-15 12:10:06 +0930 |
commit | 75cfe082c067db0b12fb982de0833309e454a8e2 (patch) | |
tree | 849f43dd0057e20e947e5f5fd8b7f80c7382e645 /bfd/cofflink.c | |
parent | cda58d5f970d0257749d549aee9c0e2bfb4a1fe8 (diff) | |
download | gdb-75cfe082c067db0b12fb982de0833309e454a8e2.zip gdb-75cfe082c067db0b12fb982de0833309e454a8e2.tar.gz gdb-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/cofflink.c')
-rw-r--r-- | bfd/cofflink.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 27ac20e..63bdcde 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -212,6 +212,12 @@ coff_link_check_archive_element (bfd *abfd, if (h->type != bfd_link_hash_undefined) return TRUE; + /* 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 (((struct coff_link_hash_entry *) h)->indx == -3) + return TRUE; + /* PR 22369 - Skip non COFF objects in the archive. */ if (! bfd_family_coff (abfd)) return TRUE; @@ -286,6 +292,7 @@ coff_link_add_symbols (bfd *abfd, asection *section; bfd_vma value; bfd_boolean addit; + bfd_boolean discarded = FALSE; /* This symbol is externally visible. */ @@ -311,7 +318,10 @@ coff_link_add_symbols (bfd *abfd, flags = BSF_EXPORT | BSF_GLOBAL; section = coff_section_from_bfd_index (abfd, sym.n_scnum); if (discarded_section (section)) - section = bfd_und_section_ptr; + { + discarded = TRUE; + section = bfd_und_section_ptr; + } else if (! obj_pe (abfd)) value -= section->vma; break; @@ -408,6 +418,9 @@ coff_link_add_symbols (bfd *abfd, (const char *) NULL, copy, FALSE, (struct bfd_link_hash_entry **) sym_hash))) goto error_return; + + if (discarded) + (*sym_hash)->indx = -3; } if (obj_pe (abfd) && (flags & BSF_SECTION_SYM) != 0) @@ -2567,6 +2580,9 @@ _bfd_coff_write_global_sym (struct bfd_hash_entry *bh, void *data) return FALSE; case bfd_link_hash_undefined: + if (h->indx == -3) + return TRUE; + /* Fall through. */ case bfd_link_hash_undefweak: isym.n_scnum = N_UNDEF; isym.n_value = 0; |