public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/toolchain/binutils-patches:master commit in: 9999/
Date: Tue, 05 Aug 2025 20:21:01 +0000 (UTC)	[thread overview]
Message-ID: <1754425251.f81f9f5a26d3b0b70d5ef0fb58e00b5842b9bf68.sam@gentoo> (raw)

commit:     f81f9f5a26d3b0b70d5ef0fb58e00b5842b9bf68
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Aug  5 20:20:51 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug  5 20:20:51 2025 +0000
URL:        https://gitweb.gentoo.org/proj/toolchain/binutils-patches.git/commit/?id=f81f9f5a

999(: refresh strip LTO patch

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...n-t-treat-fat-IR-objects-as-plugin-object.patch | 449 +++++++++++++++------
 1 file changed, 330 insertions(+), 119 deletions(-)

diff --git a/9999/0006-strip-Don-t-treat-fat-IR-objects-as-plugin-object.patch b/9999/0006-strip-Don-t-treat-fat-IR-objects-as-plugin-object.patch
index 9c24514..b34bbbb 100644
--- a/9999/0006-strip-Don-t-treat-fat-IR-objects-as-plugin-object.patch
+++ b/9999/0006-strip-Don-t-treat-fat-IR-objects-as-plugin-object.patch
@@ -1,6 +1,6 @@
-https://sourceware.org/bugzilla/show_bug.cgi?id=33246#c27
+https://inbox.sourceware.org/binutils/CAMe9rOprvH1SusdkbmAnE7L0Sr4kYeMZTYAQBw4t9oTySVsgjw@mail.gmail.com/
 
-From ec362769c8e381900cd432d288ca5b5641bac02b Mon Sep 17 00:00:00 2001
+From a0fafaa5186a248ac75e178d39fa257ddbce5f2d Mon Sep 17 00:00:00 2001
 From: "H.J. Lu" <hjl.tools@gmail.com>
 Date: Sun, 3 Aug 2025 10:28:40 -0700
 Subject: [PATCH] strip: Don't treat fat IR objects as plugin object
@@ -18,7 +18,7 @@ since fat IR objects are recognized as plugin object and copied as unknown
 objects.  Update strip not to treat archive member nor standalone fat IR
 object as IR object so that strip can remove debug and IR sections in
 fat IR object.  For archive member, it is copied as an unknown object if
-it isn't a fat IR object or a slim IR object.
+it isn't a fat IR object nor a slim IR object.
 
 bfd/
 
@@ -28,17 +28,14 @@ bfd/
 	(_bfd_compute_and_write_armap): Don't complain plugin is needed
 	when the plugin target is in use.
 	* bfd-in2.h: Regenerated.
-	* format.c (bfd_check_format_lto): Add a bool argument to
-	indicate called from strip.
+	* format.c (bfd_check_format_lto): Removed.
 	(bfd_check_format): Updated.
-	(bfd_set_lto_type): If there is .llvm.lto section,
-	set LTO type to lto_fat_ir_object.
-	(bfd_check_format_matches_lto): Add a bool argument to indicate
-	called from strip.  When called from strip, don't treat archive
-	member nor standalone fat IR object as an IR object.  Don't set
-	LTO type when setting format.  Set LTO type if IR sections won't
-	be removed.
-	(bfd_check_format_matches): Updated.
+	(bfd_set_lto_type): If there is .llvm.lto section, set LTO type
+	to lto_fat_ir_object.
+	(bfd_check_format_matches_lto): Removed.
+	(bfd_check_format_matches): Don't set LTO type when setting
+	format.  When called from strip, don't treat archive
+	member nor standalone fat IR object as an IR object.
 	* plugin.c (bfd_plugin_get_symbols_in_object_only): Copy LTO
 	type derived from input sections.
 
@@ -64,21 +61,23 @@ ld/
 	Run binutils/33246 tests with GCC and Clang.
 	* testsuite/ld-plugin/pr33246.c: New file.
 
+Co-Authored-By: Alan Modra <amodra@gmail.com>
 Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
 ---
- bfd/archive.c                           |  10 +-
- bfd/bfd-in2.h                           |   5 +-
- bfd/format.c                            |  48 +++++--
- bfd/plugin.c                            |   3 +
+ bfd/archive.c                           |  12 +-
+ bfd/bfd-in2.h                           |  10 +-
+ bfd/bfd.c                               |   3 +
+ bfd/format.c                            | 140 +++++++------------
+ bfd/plugin.c                            |   7 +-
  binutils/nm.c                           |   6 +-
- binutils/objcopy.c                      |  21 ++-
+ binutils/objcopy.c                      |  57 +++++---
  ld/testsuite/ld-plugin/lto-binutils.exp | 175 ++++++++++++++++++++++++
  ld/testsuite/ld-plugin/pr33246.c        |   4 +
- 8 files changed, 248 insertions(+), 24 deletions(-)
+ 9 files changed, 290 insertions(+), 124 deletions(-)
  create mode 100644 ld/testsuite/ld-plugin/pr33246.c
 
 diff --git a/bfd/archive.c b/bfd/archive.c
-index c61d4b12658..c323fb4fbd3 100644
+index c61d4b12658..491c44f5191 100644
 --- a/bfd/archive.c
 +++ b/bfd/archive.c
 @@ -141,6 +141,10 @@ SUBSECTION
@@ -102,84 +101,122 @@ index c61d4b12658..c323fb4fbd3 100644
  	      && report_plugin_err)
  	    {
  	      report_plugin_err = false;
-@@ -2398,7 +2403,8 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
+@@ -2398,8 +2403,9 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
  			  map = new_map;
  			}
  
 -		      if (bfd_lto_slim_symbol_p (current,
+-						 syms[src_count]->name)
 +		      if (!bfd_plugin_target_p (current->xvec)
 +			  && bfd_lto_slim_symbol_p (current,
- 						 syms[src_count]->name)
++						    syms[src_count]->name)
  			  && report_plugin_err)
  			{
+ 			  report_plugin_err = false;
 diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
-index 2ff3e930bfa..351c9a97c52 100644
+index 2ff3e930bfa..12512a3962c 100644
 --- a/bfd/bfd-in2.h
 +++ b/bfd/bfd-in2.h
-@@ -2904,13 +2904,14 @@ bool generic_core_file_matches_executable_p
+@@ -2131,6 +2131,9 @@ struct bfd
+   /* Set if this is the linker input BFD.  */
+   unsigned int is_linker_input : 1;
+ 
++  /* Set if this is the strip input BFD.  */
++  unsigned int is_strip_input : 1;
++
+   /* If this is an input for a compiler plug-in library.  */
+   ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2;
+ 
+@@ -2903,15 +2906,8 @@ bool generic_core_file_matches_executable_p
+    (bfd *core_bfd, bfd *exec_bfd);
  
  /* Extracted from format.c.  */
- bool bfd_check_format_lto (bfd *abfd, bfd_format format,
+-bool bfd_check_format_lto (bfd *abfd, bfd_format format,
 -    bool lto_sections_removed);
-+    bool lto_sections_removed,
-+    bool from_strip);
- 
+-
  bool bfd_check_format (bfd *abfd, bfd_format format);
  
- bool bfd_check_format_matches_lto
-    (bfd *abfd, bfd_format format, char ***matching,
+-bool bfd_check_format_matches_lto
+-   (bfd *abfd, bfd_format format, char ***matching,
 -    bool lto_sections_removed);
-+    bool lto_sections_removed, bool from_strip);
- 
+-
  bool bfd_check_format_matches
     (bfd *abfd, bfd_format format, char ***matching);
+ 
+diff --git a/bfd/bfd.c b/bfd/bfd.c
+index 858ab5ce017..4aded6809bb 100644
+--- a/bfd/bfd.c
++++ b/bfd/bfd.c
+@@ -296,6 +296,9 @@ CODE_FRAGMENT
+ .  {* Set if this is the linker input BFD.  *}
+ .  unsigned int is_linker_input : 1;
+ .
++.  {* Set if this is the strip input BFD.  *}
++.  unsigned int is_strip_input : 1;
++.
+ .  {* If this is an input for a compiler plug-in library.  *}
+ .  ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2;
+ .
 diff --git a/bfd/format.c b/bfd/format.c
-index f3a0774af08..bc7a5bc2cac 100644
+index f3a0774af08..f8e73b7eaea 100644
 --- a/bfd/format.c
 +++ b/bfd/format.c
-@@ -60,7 +60,8 @@ FUNCTION
+@@ -56,19 +56,16 @@ extern const size_t _bfd_target_vector_entries;
+ 
+ /*
+ FUNCTION
+-	bfd_check_format_lto
++	bfd_check_format
  
  SYNOPSIS
- 	bool bfd_check_format_lto (bfd *abfd, bfd_format format,
+-	bool bfd_check_format_lto (bfd *abfd, bfd_format format,
 -				   bool lto_sections_removed);
-+				   bool lto_sections_removed,
-+				   bool from_strip);
++	bool bfd_check_format (bfd *abfd, bfd_format format);
  
  DESCRIPTION
  	Verify if the file attached to the BFD @var{abfd} is compatible
-@@ -69,6 +70,8 @@ DESCRIPTION
+ 	with the format @var{format} (i.e., one of <<bfd_object>>,
+ 	<<bfd_archive>> or <<bfd_core>>).
  
- 	If LTO_SECTION_REMOVED is true, ignore plugin target.
- 
-+	If FROM_STRIP is true, this is called from strip.
-+
+-	If LTO_SECTION_REMOVED is true, ignore plugin target.
+-
  	If the BFD has been set to a specific target before the
  	call, only the named target and format combination is
  	checked. If the target has not been set, or has been set to
-@@ -104,10 +107,11 @@ DESCRIPTION
+@@ -102,31 +99,10 @@ DESCRIPTION
+ 	itself.
+ */
  
- bool
- bfd_check_format_lto (bfd *abfd, bfd_format format,
+-bool
+-bfd_check_format_lto (bfd *abfd, bfd_format format,
 -		      bool lto_sections_removed)
-+		      bool lto_sections_removed, bool from_strip)
- {
-   return bfd_check_format_matches_lto (abfd, format, NULL,
+-{
+-  return bfd_check_format_matches_lto (abfd, format, NULL,
 -				       lto_sections_removed);
-+				       lto_sections_removed,
-+				       from_strip);
- }
- 
- 
-@@ -126,7 +130,7 @@ DESCRIPTION
+-}
+-
+-
+-/*
+-FUNCTION
+-	bfd_check_format
+-
+-SYNOPSIS
+-	bool bfd_check_format (bfd *abfd, bfd_format format);
+-
+-DESCRIPTION
+-	Similar to bfd_check_format_plugin, except plugin target isn't
+-	ignored.
+-*/
+-
  bool
  bfd_check_format (bfd *abfd, bfd_format format)
  {
 -  return bfd_check_format_matches_lto (abfd, format, NULL, false);
-+  return bfd_check_format_matches_lto (abfd, format, NULL, false, false);
++  return bfd_check_format_matches (abfd, format, NULL);
  }
  
  struct bfd_preserve
-@@ -413,6 +417,11 @@ bfd_set_lto_type (bfd *abfd ATTRIBUTE_UNUSED)
+@@ -413,6 +389,11 @@ bfd_set_lto_type (bfd *abfd ATTRIBUTE_UNUSED)
  	    abfd->object_only_section = sec;
  	    break;
  	  }
@@ -191,33 +228,53 @@ index f3a0774af08..bc7a5bc2cac 100644
  	else if (lsection.major_version == 0
  		 && startswith (sec->name, ".gnu.lto_.lto.")
  		 && bfd_get_section_contents (abfd, sec, &lsection, 0,
-@@ -436,7 +445,7 @@ FUNCTION
+@@ -431,36 +412,32 @@ bfd_set_lto_type (bfd *abfd ATTRIBUTE_UNUSED)
+ 
+ /*
+ FUNCTION
+-	bfd_check_format_matches_lto
++	bfd_check_format_matches
+ 
  SYNOPSIS
- 	bool bfd_check_format_matches_lto
- 	  (bfd *abfd, bfd_format format, char ***matching,
+-	bool bfd_check_format_matches_lto
+-	  (bfd *abfd, bfd_format format, char ***matching,
 -	   bool lto_sections_removed);
-+	   bool lto_sections_removed, bool from_strip);
++	bool bfd_check_format_matches
++	  (bfd *abfd, bfd_format format, char ***matching);
  
  DESCRIPTION
  	Like <<bfd_check_format>>, except when it returns FALSE with
-@@ -450,12 +459,15 @@ DESCRIPTION
- 	should free it.
+-	<<bfd_errno>> set to <<bfd_error_file_ambiguously_recognized>>.  In that
+-	case, if @var{matching} is not NULL, it will be filled in with
+-	a NULL-terminated list of the names of the formats that matched,
+-	allocated with <<malloc>>.
++	<<bfd_errno>> set to <<bfd_error_file_ambiguously_recognized>>.
++	In that case, if @var{matching} is not NULL, it will be filled
++	in with a NULL-terminated list of the names of the formats
++	that matched, allocated with <<malloc>>.
+ 	Then the user may choose a format and try again.
  
- 	If LTO_SECTION_REMOVED is true, ignore plugin target.
-+
-+	If FROM_STRIP is true, this is called from strip.
+ 	When done with the list that @var{matching} points to, the caller
+ 	should free it.
+-
+-	If LTO_SECTION_REMOVED is true, ignore plugin target.
  */
  
  bool
- bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
- 			      char ***matching,
+-bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
+-			      char ***matching,
 -			      bool lto_sections_removed ATTRIBUTE_UNUSED)
-+			      bool lto_sections_removed ATTRIBUTE_UNUSED,
-+			      bool from_strip ATTRIBUTE_UNUSED)
++bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
  {
    extern const bfd_target binary_vec;
    const bfd_target * const *target;
-@@ -481,10 +493,7 @@ bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
+   const bfd_target **matching_vector = NULL;
+   const bfd_target *save_targ, *right_targ, *ar_right_targ, *match_targ;
++  const bfd_target *fail_targ;
+   int match_count, best_count, best_match;
+   int ar_match_index;
+   unsigned int initial_section_id = _bfd_section_id;
+@@ -481,10 +458,7 @@ bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
      }
  
    if (abfd->format != bfd_unknown)
@@ -229,7 +286,25 @@ index f3a0774af08..bc7a5bc2cac 100644
  
    if (matching != NULL || *bfd_associated_vector != NULL)
      {
-@@ -537,7 +546,16 @@ bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
+@@ -524,20 +498,30 @@ bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
+   if (!bfd_preserve_save (abfd, &preserve, NULL))
+     goto err_ret;
+ 
+-  /* If the target type was explicitly specified, just check that target.
+-     If LTO_SECTION_REMOVED is true, don't match the plugin target.  */
++  /* If the target type was explicitly specified, just check that target.  */
++  fail_targ = NULL;
+   if (!abfd->target_defaulted
+ #if BFD_SUPPORTS_PLUGINS
+-      && (!lto_sections_removed || !bfd_plugin_target_p (abfd->xvec))
++      && !(abfd->plugin_format == bfd_plugin_no
++	   && bfd_plugin_target_p (save_targ))
+ #endif
+-     )
++      )
+     {
+       if (bfd_seek (abfd, 0, SEEK_SET) != 0)	/* rewind! */
+ 	goto err_ret;
  
        cleanup = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
  
@@ -240,40 +315,114 @@ index f3a0774af08..bc7a5bc2cac 100644
 +	 isn't a fat IR object.  For standalone fat IR object,
 +	 it will be copied as non-IR object.  */
 +      if (cleanup
-+	  && (!from_strip
++	  && (!abfd->is_strip_input
 +	      || !bfd_plugin_target_p (abfd->xvec)
 +	      || (abfd->lto_type != lto_fat_ir_object
 +		  && abfd->my_archive == NULL)))
  	goto ok_ret;
  
        /* For a long time the code has dropped through to check all
-@@ -621,6 +639,11 @@ bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
- 	{
- 	  int match_priority = abfd->xvec->match_priority;
+@@ -554,10 +538,10 @@ bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
+ 	 target.  */
+       if (format == bfd_archive && save_targ == &binary_vec)
+ 	goto err_unrecog;
++      fail_targ = save_targ;
+     }
  
-+	  /* Set LTO type if IR sections won't be removed so that it
-+	     can be checked for fat and slim IR objects.  */
-+	  if (!lto_sections_removed)
-+	    bfd_set_lto_type (abfd);
-+
- 	  if (abfd->format != bfd_archive
- 	      || (bfd_has_map (abfd)
- 		  && bfd_get_error () != bfd_error_wrong_object_format))
-@@ -854,7 +877,8 @@ DESCRIPTION
- bool
- bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
- {
--  return bfd_check_format_matches_lto (abfd, format, matching, false);
-+  return bfd_check_format_matches_lto (abfd, format, matching, false,
-+				       false);
+-  /* Since the target type was defaulted, check them all in the hope
+-     that one will be uniquely recognized.  */
++  /* Check all targets in the hope that one will be recognized.  */
+   right_targ = NULL;
+   ar_right_targ = NULL;
+   match_targ = NULL;
+@@ -571,26 +555,26 @@ bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
+       void **high_water;
+ 
+       /* The binary target matches anything, so don't return it when
+-	 searching.  Don't match the plugin target if we have another
+-	 alternative since we want to properly set the input format
+-	 before allowing a plugin to claim the file.  Also, don't
+-	 check the default target twice.   If LTO_SECTION_REMOVED is
+-	 true, don't match the plugin target.  */
++	 searching.  Also, don't check the current target twice when
++	 it has failed already.
++	 Don't match the plugin target during linking if we have 
++	 another alternative since we want to properly set the input
++	 format before allowing a plugin to claim the file.
++	 Also as an optimisation don't match the plugin target when
++	 abfd->plugin_format is set to bfd_plugin_no.  (This occurs
++	 when LTO sections have been stripped or when we have a
++	 recursive call here from the plugin object_p via
++	 bfd_plugin_get_symbols_in_object_only.)  */
+       if (*target == &binary_vec
++	  || *target == fail_targ
+ #if BFD_SUPPORTS_PLUGINS
+-	  || ((lto_sections_removed || match_count != 0)
++	  || (((abfd->is_linker_input && match_count != 0)
++	       || abfd->plugin_format == bfd_plugin_no)
+ 	      && bfd_plugin_target_p (*target))
+ #endif
+-	  || (!abfd->target_defaulted && *target == save_targ))
++	  )
+ 	continue;
+ 
+-#if BFD_SUPPORTS_PLUGINS
+-      /* If the plugin target is explicitly specified when a BFD file
+-	 is opened, don't check it twice.  */
+-      if (bfd_plugin_specified_p () && bfd_plugin_target_p (*target))
+-	continue;
+-#endif
+-
+       /* If we already tried a match, the bfd is modified and may
+ 	 have sections attached, which will confuse the next
+ 	 _bfd_check_format call.  */
+@@ -831,32 +815,6 @@ bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
+   return false;
  }
  
+-/*
+-FUNCTION
+-	bfd_check_format_matches
+-
+-SYNOPSIS
+-	bool bfd_check_format_matches
+-	  (bfd *abfd, bfd_format format, char ***matching);
+-
+-DESCRIPTION
+-	Like <<bfd_check_format>>, except when it returns FALSE with
+-	<<bfd_errno>> set to <<bfd_error_file_ambiguously_recognized>>.  In that
+-	case, if @var{matching} is not NULL, it will be filled in with
+-	a NULL-terminated list of the names of the formats that matched,
+-	allocated with <<malloc>>.
+-	Then the user may choose a format and try again.
+-
+-	When done with the list that @var{matching} points to, the caller
+-	should free it.
+-*/
+-
+-bool
+-bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
+-{
+-  return bfd_check_format_matches_lto (abfd, format, matching, false);
+-}
+-
  /*
+ FUNCTION
+ 	bfd_set_format
 diff --git a/bfd/plugin.c b/bfd/plugin.c
-index 1c72b748a8f..6dd22d75137 100644
+index 1c72b748a8f..be9d1e58bf3 100644
 --- a/bfd/plugin.c
 +++ b/bfd/plugin.c
-@@ -203,6 +203,9 @@ bfd_plugin_get_symbols_in_object_only (bfd *abfd)
+@@ -196,13 +196,17 @@ bfd_plugin_get_symbols_in_object_only (bfd *abfd)
+ 	     abfd->filename, bfd_errmsg (bfd_get_error ()));
+ 	  return;
+ 	}
+-      else if (!bfd_check_format (nbfd, bfd_object))
++      nbfd->plugin_format = bfd_plugin_no;
++      if (!bfd_check_format (nbfd, bfd_object))
+ 	{
+ 	  /* There is no object only section if it isn't a bfd_object
+ 	     file.  */
  	  bfd_close (nbfd);
  	  return;
  	}
@@ -283,6 +432,14 @@ index 1c72b748a8f..6dd22d75137 100644
      }
    else
      {
+@@ -239,6 +243,7 @@ bfd_plugin_get_symbols_in_object_only (bfd *abfd)
+ 
+   /* Open the file containing object only section.  */
+   nbfd = bfd_openr (object_only_file, NULL);
++  nbfd->plugin_format = bfd_plugin_no;
+   if (!bfd_check_format (nbfd, bfd_object))
+     {
+       (*_bfd_error_handler)
 diff --git a/binutils/nm.c b/binutils/nm.c
 index a5d56311dde..94333042ee2 100644
 --- a/binutils/nm.c
@@ -308,19 +465,43 @@ index a5d56311dde..94333042ee2 100644
        report_plugin_err = false;
        non_fatal (_("%s: plugin needed to handle lto object"),
 diff --git a/binutils/objcopy.c b/binutils/objcopy.c
-index 5774711abe6..496f0a13daa 100644
+index 5774711abe6..3404bec1d08 100644
 --- a/binutils/objcopy.c
 +++ b/binutils/objcopy.c
-@@ -3746,7 +3746,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
+@@ -170,6 +170,8 @@ static bool sections_removed;
+ #if BFD_SUPPORTS_PLUGINS
+ /* TRUE if all GCC LTO sections are to be removed.  */
+ static bool lto_sections_removed;
++#else
++#define lto_sections_removed false
+ #endif
+ 
+ /* TRUE if only some sections are to be copied.  */
+@@ -3687,6 +3689,8 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
+       bool ok_object;
+       const char *element_name;
+ 
++      this_element->is_strip_input = 1;
++
+       element_name = bfd_get_filename (this_element);
+       /* PR binutils/17533: Do not allow directory traversal
+ 	 outside of the current directory tree by archive members.  */
+@@ -3745,11 +3749,10 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
+ 
  #if BFD_SUPPORTS_PLUGINS
        /* Ignore plugin target if all LTO sections should be removed.  */
-       ok_object = bfd_check_format_lto (this_element, bfd_object,
+-      ok_object = bfd_check_format_lto (this_element, bfd_object,
 -					lto_sections_removed);
-+					lto_sections_removed, true);
- #else
-       ok_object = bfd_check_format (this_element, bfd_object);
+-#else
+-      ok_object = bfd_check_format (this_element, bfd_object);
++      if (lto_sections_removed)
++	this_element->plugin_format = bfd_plugin_no;
  #endif
-@@ -3768,7 +3768,9 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
++      ok_object = bfd_check_format (this_element, bfd_object);
+ 
+       /* PR binutils/3110: Cope with archives
+ 	 containing multiple target types.  */
+@@ -3768,7 +3771,9 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
  
  #if BFD_SUPPORTS_PLUGINS
        /* Copy LTO IR file as unknown object.  */
@@ -331,35 +512,65 @@ index 5774711abe6..496f0a13daa 100644
  	ok_object = false;
        else
  #endif
-@@ -3946,7 +3948,8 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
+@@ -3863,6 +3868,25 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
+   return ok;
+ }
+ 
++static bool
++check_format_object (bfd *ibfd, char ***obj_matching,
++		     bool no_plugins ATTRIBUTE_UNUSED)
++{
++#if BFD_SUPPORTS_PLUGINS
++  /* Ignore plugin target first if all LTO sections should be
++     removed.  Try with plugin target next if ignoring plugin
++     target fails to match the format.  */
++  if (no_plugins && ibfd->plugin_format == bfd_plugin_unknown)
++    {
++      ibfd->plugin_format = bfd_plugin_no;
++      if (bfd_check_format_matches (ibfd, bfd_object, obj_matching))
++	return true;
++      ibfd->plugin_format = bfd_plugin_unknown;
++    }
++#endif
++  return bfd_check_format_matches (ibfd, bfd_object, obj_matching);
++}
++
+ /* The top-level control.  */
+ 
+ static void
+@@ -3946,6 +3970,8 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
        break;
      }
  
--  if (bfd_check_format (ibfd, bfd_archive))
-+  if (bfd_check_format_lto (ibfd, bfd_archive, lto_sections_removed,
-+			    true))
++  ibfd->is_strip_input = 1;
++
+   if (bfd_check_format (ibfd, bfd_archive))
      {
        bool force_output_target;
-       bfd *obfd;
-@@ -3994,13 +3997,14 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
- 	      removed.  Try with plugin target next if ignoring plugin
- 	      target fails to match the format.  */
- 	   bfd_check_format_matches_lto (ibfd, bfd_object, &obj_matching,
+@@ -3988,21 +4014,7 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
+ 			 input_arch, target_defaulted))
+ 	status = 1;
+     }
+-  else if (
+-#if BFD_SUPPORTS_PLUGINS
+-	   /* Ignore plugin target first if all LTO sections should be
+-	      removed.  Try with plugin target next if ignoring plugin
+-	      target fails to match the format.  */
+-	   bfd_check_format_matches_lto (ibfd, bfd_object, &obj_matching,
 -					 lto_sections_removed)
-+					 lto_sections_removed, true)
- 	   || (lto_sections_removed
- 	       && bfd_check_format_matches_lto (ibfd, bfd_object,
+-	   || (lto_sections_removed
+-	       && bfd_check_format_matches_lto (ibfd, bfd_object,
 -						&obj_matching, false))
-+						&obj_matching, false,
-+						true))
- #else
- 	   bfd_check_format_matches_lto (ibfd, bfd_object, &obj_matching,
+-#else
+-	   bfd_check_format_matches_lto (ibfd, bfd_object, &obj_matching,
 -					 false)
-+					 false, true)
- #endif
- 	   )
+-#endif
+-	   )
++  else if (check_format_object (ibfd, &obj_matching, lto_sections_removed))
      {
-@@ -5066,6 +5070,11 @@ strip_main (int argc, char *argv[])
+       bfd *obfd;
+     do_copy:
+@@ -5066,6 +5078,11 @@ strip_main (int argc, char *argv[])
  					       SECTION_CONTEXT_REMOVE)
  			  || !!find_section_list (".llvm.lto", false,
  					       SECTION_CONTEXT_REMOVE));


             reply	other threads:[~2025-08-05 20:21 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05 20:21 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-08-29 13:40 [gentoo-commits] proj/toolchain/binutils-patches:master commit in: 9999/ Sam James
2025-08-28 20:21 Sam James
2025-08-28 13:51 Sam James
2025-08-28  5:32 Sam James
2025-08-27 16:26 Sam James
2025-08-27  4:05 Sam James
2025-08-27  2:49 Sam James
2025-08-25  2:49 Sam James
2025-08-20 23:30 Sam James
2025-08-20 22:17 Sam James
2025-08-20 22:17 Sam James
2025-08-20 20:44 Sam James
2025-08-20  4:39 Sam James
2025-08-19 20:54 Sam James
2025-08-19 17:11 Sam James
2025-08-19 16:28 Sam James
2025-08-19 10:51 Sam James
2025-08-19  3:48 Sam James
2025-08-18 20:21 Sam James
2025-08-18 20:21 Sam James
2025-08-18 20:19 Sam James
2025-08-18 15:39 Sam James
2025-08-17 20:58 Sam James
2025-08-17 19:45 Sam James
2025-08-06 13:19 Sam James
2025-08-06  4:07 Sam James
2025-08-06  1:08 Sam James
2025-08-04 21:43 Sam James
2025-08-04 21:05 Sam James
2025-08-04 15:32 Sam James
2025-08-04 11:06 Sam James
2025-08-03 23:43 Sam James
2025-08-01 11:28 Sam James
2025-08-01  8:17 Sam James
2025-07-31 11:39 Sam James
2025-07-28 12:24 Andreas K. Hüttel
2025-07-24 17:25 Sam James
2025-07-24  4:03 Sam James
2025-07-24  3:46 Sam James
2025-07-23 22:37 Sam James
2025-06-14 21:52 Sam James
2025-06-13  8:00 Sam James
2025-05-14  7:14 Sam James
2025-05-14  3:59 Sam James
2025-05-05  9:46 Sam James
2025-05-05  3:06 Sam James
2025-05-04 10:15 Sam James
2025-04-10 17:35 Sam James
2025-04-09  2:24 Sam James
2025-04-08  0:36 Sam James
2025-03-29 14:18 Sam James
2025-03-12 20:21 Sam James
2025-03-06 12:54 Sam James
2025-03-06  4:54 Sam James
2025-02-03 18:02 Andreas K. Hüttel
2025-01-14  2:09 Sam James
2025-01-13  6:11 Sam James
2025-01-02 13:48 Sam James
2025-01-01 14:05 Sam James
2024-12-26  1:21 Sam James
2024-12-24  6:27 Sam James
2024-12-21  0:09 Sam James
2024-08-03 22:43 Andreas K. Hüttel
2024-06-29 17:05 Andreas K. Hüttel
2024-06-29 16:32 Andreas K. Hüttel
2024-06-29 16:32 Andreas K. Hüttel
2024-06-28 21:48 Andreas K. Hüttel
2023-10-27  0:44 Sam James
2023-10-27  0:44 Sam James
2023-07-30 14:49 Andreas K. Hüttel
2023-07-28 16:23 Andreas K. Hüttel
2023-06-30  9:21 WANG Xuerui
2023-04-02 11:44 Andreas K. Hüttel
2023-01-05 16:22 Andreas K. Hüttel
2023-01-05 16:21 Andreas K. Hüttel
2023-01-03 23:03 Andreas K. Hüttel
2023-01-02 23:50 Andreas K. Hüttel
2022-10-08 12:15 WANG Xuerui
2022-07-29  7:55 WANG Xuerui
2022-01-15 22:27 Andreas K. Hüttel
2021-08-17 20:07 Andreas K. Hüttel
2021-07-30 23:25 Andreas K. Hüttel
2021-07-24 20:57 Andreas K. Hüttel
2021-07-20 19:53 Andreas K. Hüttel
2021-07-20 19:50 Andreas K. Hüttel
2021-07-06  7:04 Sergei Trofimovich
2021-07-06  7:04 Sergei Trofimovich
2021-07-06  7:04 Sergei Trofimovich
2020-07-25 17:27 Andreas K. Hüttel
2020-07-25 12:26 Andreas K. Hüttel
2020-07-25 12:23 Andreas K. Hüttel
2020-07-25 12:20 Andreas K. Hüttel
2020-05-19 21:12 Andreas K. Hüttel

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=1754425251.f81f9f5a26d3b0b70d5ef0fb58e00b5842b9bf68.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.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