summaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2022-10-27 14:50:40 +0200
committerMichael Matz <matz@suse.de>2022-11-30 17:15:08 +0100
commit50be5d11289c8ca8d5aa7ec621b7110b6572612a (patch)
tree8808ebe7201b3c7437b38af707d855484c4f199d /ld/ldlang.c
parent43ae96e94ab7e3d5dfdb0d7c1b6ba57814a43f1d (diff)
downloadbinutils-gdb-50be5d11289c8ca8d5aa7ec621b7110b6572612a.tar.gz
section-select: Completely rebuild matches
The check_relocs callback (and others) might have created new section behind our back and some of them (e.g. on powerpc the "linker stubs" .got) need to come in front of all others, despite being created late (a symptom would be "TOC opt*" failing on powerpc). This resets all section matches before updating for newly created sections (i.e. completely rebuilds the matches).
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 846dcdf2918..df5292d8e95 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -8066,6 +8066,23 @@ lang_propagate_lma_regions (void)
}
}
+static void
+reset_one_wild (lang_statement_union_type *statement)
+{
+ if (statement->header.type == lang_wild_statement_enum)
+ {
+ lang_wild_statement_type *stmt = &statement->wild_statement;
+ stmt->resolved = false;
+ lang_list_init (&stmt->matching_sections);
+ }
+}
+
+static void
+reset_resolved_wilds (void)
+{
+ lang_for_each_statement (reset_one_wild);
+}
+
void
lang_process (void)
{
@@ -8279,6 +8296,11 @@ lang_process (void)
ldemul_after_check_relocs ();
+ /* There might have been new sections created (e.g. as result of
+ checking relocs to need a .got, or suchlike), so to properly order
+ them into our lists of matching sections reset them here. */
+ reset_resolved_wilds ();
+
/* Update wild statements in case the user gave --sort-section.
Note how the option might have come after the linker script and
so couldn't have been set when the wild statements were created. */