aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-06-23 23:50:56 +0930
committerAlan Modra <amodra@gmail.com>2020-06-24 00:50:48 +0930
commit9221725d1f6e3f5dd0c0143ee750460619c582f2 (patch)
treed3c8991309aa4961a98a10489063eb6bc70ef8d9 /ld/ldlang.c
parent39f381cb80463bd814da549a927bee4643d4ceac (diff)
downloadbinutils-9221725d1f6e3f5dd0c0143ee750460619c582f2.zip
binutils-9221725d1f6e3f5dd0c0143ee750460619c582f2.tar.gz
binutils-9221725d1f6e3f5dd0c0143ee750460619c582f2.tar.bz2
PR26150, Assertion when asm() defines global symbols, -flto and --start-group
If an archive map contains symbols that aren't actually defined by the indexed element for any reason, then loading that element will leave the symbol undefined (or common). This leads to the possibility of the element being loaded again should the archive be searched again due to the action of --start-group/--end-group. The testcase triggering this problem was an archive containing fat lto objects, with the archive map incorrectly created by ar rather than gcc-ar. PR 26150 * ldlang.c (ldlang_add_file): Assert that we aren't adding the current end of link.next list again too. * ldmain.c (add_archive_element): Don't load archive elements again that have already been loaded.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 8ab6a0b..38ed83a 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7266,7 +7266,8 @@ ldlang_add_file (lang_input_statement_type *entry)
/* The BFD linker needs to have a list of all input BFDs involved in
a link. */
- ASSERT (entry->the_bfd->link.next == NULL);
+ ASSERT (link_info.input_bfds_tail != &entry->the_bfd->link.next
+ && entry->the_bfd->link.next == NULL);
ASSERT (entry->the_bfd != link_info.output_bfd);
*link_info.input_bfds_tail = entry->the_bfd;