PR 33801 strip doesn't remove .gnu.lto_.opts

Alan Modra amodra@gmail.com
Sun Jan 18 02:36:08 GMT 2026


OK, so people want to be able to partly destroy gcc slim LTO object
files.  I don't see why not, despite HJ's policy-setting slim lto
strip -R tests.  I also don't see why it matters that objcopy/strip
won't similarly break LLVM objects (pr33271).

So out goes the slim lto strip -R tests, and the strip-debug test
expecting slim lto files won't be modified in any way.  strip-debug
now removes a FILE symbol, which isn't unreasonable.

	PR 33801
	PR 33271
	PR 33246
binutils/
	* objcopy.c (copy_archive, copy_file): Do not special case
	gcc LTO IR files.
ld/
	* testsuite/ld-plugin/lto-binutils.exp: Remove slim lto strip -R
	tests.
	(run_pr33246_test): Don't compare slim object files after
	strip-debug.
	* testsuite/ld-plugin/strip-1a-s-all.nd: Delete.

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 5f44c6295f2..c237f24adf1 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3771,9 +3771,6 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
 	  goto cleanup_and_exit;
 	}
 
-      /* Copy slim LTO IR file as unknown object.  */
-      if (this_element->lto_type == lto_slim_ir_object)
-	ok_object = false;
       if (ok_object)
 	{
 	  ok = copy_object (this_element, output_element, input_arch);
@@ -4067,9 +4064,6 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
  	  return;
  	}
 
-      /* Copy slim LTO IR file as unknown file.  */
-      if (ibfd->lto_type == lto_slim_ir_object)
-	ok_object = false;
       if (ok_object
 	  ? !copy_object (ibfd, obfd, input_arch)
 	  : !copy_unknown_file (ibfd, obfd,
diff --git a/ld/testsuite/ld-plugin/lto-binutils.exp b/ld/testsuite/ld-plugin/lto-binutils.exp
index 77da082822b..14c8d7b1240 100644
--- a/ld/testsuite/ld-plugin/lto-binutils.exp
+++ b/ld/testsuite/ld-plugin/lto-binutils.exp
@@ -254,23 +254,6 @@ run_lto_binutils_test [list \
     ] \
 ]
 
-run_lto_binutils_test [list \
-    [list \
-	"strip" \
-	"-R .gnu.*lto_* -N __gnu_lto_v1" \
-	"strip-1a.o" \
-	"strip-1a-s-all.o" \
-	{{nm -n strip-1a-s-all.nd}} \
-    ] \
-    [list \
-	"strip" \
-	"-R .gnu.*lto_* -N __gnu_lto_v1" \
-	"libstrip-1a.a" \
-	"libstrip-1a-s-all.a" \
-	{{nm -n strip-1a-s-all.nd}} \
-    ] \
-]
-
 run_cc_link_tests [list \
     [list \
 	"Build strip-1a (strip-1a.o)" \
@@ -449,7 +432,7 @@ proc run_pr33246_test { llvm fat } {
 	    fail "$testname (strip $obj)"
 	    return
 	}
-    } else {
+    } elseif { "$llvm" == "-llvm" } {
 	set cmd "cmp $obj ${obj}.strip"
 	send_log "$cmd\n"
 	verbose "$cmd" 1
@@ -508,7 +491,7 @@ proc run_pr33246_test { llvm fat } {
 	    fail "$testname (strip $archive)"
 	    return
 	}
-    } else {
+    } elseif { "$llvm" == "-llvm" } {
 	set cmd "cmp $archive ${archive}.strip"
 	send_log "$cmd\n"
 	verbose "$cmd" 1
diff --git a/ld/testsuite/ld-plugin/strip-1a-s-all.nd b/ld/testsuite/ld-plugin/strip-1a-s-all.nd
deleted file mode 100644
index 52265c2eb3d..00000000000
--- a/ld/testsuite/ld-plugin/strip-1a-s-all.nd
+++ /dev/null
@@ -1,6 +0,0 @@
-#...
- + U foo2
- + U foo3
-0+ T foo1
-0+ T main
-#pass

-- 
Alan Modra


More information about the Binutils mailing list