public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Michael Matz <matz@suse.de>
To: binutils@sourceware.org
Subject: [PATCH 7/8] section-select: Remove bfd_max_section_id again
Date: Fri, 25 Nov 2022 16:57:38 +0000 (UTC)	[thread overview]
Message-ID: <alpine.LSU.2.20.2211251656020.24878@wotan.suse.de> (raw)
In-Reply-To: <cover.1669391757.git.matz@suse.de>

since we reset the whole matching state completely we don't
need the already-seen early-outs anymore.
---

Depending on how 4/8 is decided this patch might not land in the tree in 
the end, as without rebuilding the whole matchings from scratch the 
early-outs remain useful,


Ciao,
Michael.

 bfd/bfd-in2.h |  2 --
 bfd/section.c | 19 -------------------
 ld/ldlang.c   | 19 +------------------
 ld/ldlang.h   |  1 -
 4 files changed, 1 insertion(+), 40 deletions(-)

diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 5350ae42b03..0b071dda1e5 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1330,8 +1330,6 @@ discarded_section (const asection *sec)
   { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
 #endif
 
-unsigned int bfd_get_max_section_id (void);
-
 void bfd_section_list_clear (bfd *);
 
 asection *bfd_get_section_by_name (bfd *abfd, const char *name);
diff --git a/bfd/section.c b/bfd/section.c
index d691bf265ab..f73e0345e15 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -849,25 +849,6 @@ SUBSECTION
 These are the functions exported by the section handling part of BFD.
 */
 
-/*
-FUNCTION
-	bfd_get_max_section_id
-
-SYNOPSIS
-	unsigned int bfd_get_max_section_id (void);
-
-DESCRIPTION
-	Returns an internal number representing the maximum value of
-	any SECTION->id member.  Whenever a new section is created that
-	value increases.  It never decreases.
-*/
-
-unsigned int
-bfd_get_max_section_id (void)
-{
-  return _bfd_section_id;
-}
-
 /*
 FUNCTION
 	bfd_section_list_clear
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 18d10531d51..abaa9916256 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -368,8 +368,6 @@ walk_wild_file_in_exclude_list (struct name_list *exclude_list,
   return false;
 }
 
-static unsigned int old_max_section_id = 0;
-
 /* Add SECTION (from input FILE) to the list of matching sections
    within PTR (the matching wildcard is SEC).  */
 
@@ -402,9 +400,6 @@ walk_wild_section_match (lang_wild_statement_type *ptr,
   const char *file_spec = ptr->filename;
   char *p;
 
-  if (s->id < ptr->max_section_id)
-    return;
-
   /* Check if filenames match.  */
   if (file_spec == NULL)
     ;
@@ -896,8 +891,6 @@ resolve_wild_sections (lang_input_statement_type *file)
       const char *sname = bfd_section_name (s);
       char c = 1;
       struct prefixtree *t = ptroot;
-      if (old_max_section_id && s->id < old_max_section_id)
-	continue;
       //printf (" YYY consider %s of %s\n", sname, file->the_bfd->filename);
       do
 	{
@@ -954,7 +947,6 @@ resolve_wilds (void)
 	    }
 	}
     }
-  old_max_section_id = bfd_get_max_section_id ();
 }
 
 /* For each input section that matches wild statement S calls
@@ -965,12 +957,7 @@ walk_wild (lang_wild_statement_type *s, callback_t callback, void *data)
 {
   lang_statement_union_type *l;
 
-  if (s->max_section_id < bfd_get_max_section_id ())
-    {
-      //printf("XXX %s\n", s->filename ? s->filename : "<null>");
-      s->max_section_id = bfd_get_max_section_id ();
-    }
-
+  //printf("XXX %s\n", s->filename ? s->filename : "<null>");
   for (l = s->matching_sections.head; l; l = l->header.next)
     {
       (*callback) (s, l->input_matcher.pattern, l->input_matcher.section,
@@ -7853,8 +7840,6 @@ 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->max_section_id = 0;
-      /* XXX Leaks? */
       lang_list_init (&stmt->matching_sections);
     }
 }
@@ -7863,7 +7848,6 @@ static void
 reset_resolved_wilds (void)
 {
   lang_for_each_statement (reset_one_wild);
-  old_max_section_id = 0;
 }
 
 void
@@ -8240,7 +8224,6 @@ lang_add_wild (struct wildcard_spec *filespec,
   new_stmt->section_list = section_list;
   new_stmt->keep_sections = keep_sections;
   lang_list_init (&new_stmt->children);
-  new_stmt->max_section_id = 0;
   lang_list_init (&new_stmt->matching_sections);
   analyze_walk_wild_section_handler (new_stmt);
   if (0)
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 5d9d2447f1c..b92a7bb9d96 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -399,7 +399,6 @@ struct lang_wild_statement_struct
   lang_statement_list_type children;
   struct name_list *exclude_name_list;
   lang_statement_list_type matching_sections;
-  unsigned int max_section_id;
 
   lang_section_bst_type *tree, **rightmost;
   struct flag_info *section_flag_list;
-- 
2.36.1


  parent reply	other threads:[~2022-11-25 16:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1669391757.git.matz@suse.de>
2022-11-25 16:44 ` [PATCH 1/8] section-select: Lazily resolve section matches Michael Matz
2022-11-25 16:46 ` [PATCH 2/8] section-select: Deal with sections added late Michael Matz
2022-11-25 16:47 ` [PATCH 3/8] section-select: Implement a prefix-tree Michael Matz
2022-11-25 16:55 ` [PATCH 4/8] section-select: Completely rebuild matches Michael Matz
2022-11-28  1:57   ` Alan Modra
2022-11-28 14:24     ` Michael Matz
2022-11-29 12:22       ` Alan Modra
2022-11-29 13:23         ` Michael Matz
2022-11-25 16:55 ` [PATCH 5/8] section-select: Remove unused code Michael Matz
2022-11-25 16:55 ` [PATCH 6/8] section-select: Cleanup Michael Matz
2022-11-25 16:57 ` Michael Matz [this message]
2022-11-25 16:58 ` [PATCH 8/8] section-select: Fix exclude-file-3 Michael Matz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.20.2211251656020.24878@wotan.suse.de \
    --to=matz@suse.de \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).