public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] section-select: Completely rebuild matches
@ 2022-11-30 16:15 Michael Matz
  0 siblings, 0 replies; only message in thread
From: Michael Matz @ 2022-11-30 16:15 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=50be5d11289c8ca8d5aa7ec621b7110b6572612a

commit 50be5d11289c8ca8d5aa7ec621b7110b6572612a
Author: Michael Matz <matz@suse.de>
Date:   Thu Oct 27 14:50:40 2022 +0200

    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).

Diff:
---
 ld/ldlang.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

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.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-30 16:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30 16:15 [binutils-gdb] section-select: Completely rebuild matches Michael Matz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).