commit: 26475f8373c26cd537cbe26ad884db9c1fa6fcd4
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 8 13:19:15 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 8 17:39:18 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=26475f83
eclass/tests: dot-a: add another strip vs index testcase
This is in addition to 44699664fa7aba134c327acb38c40851e0813ff4 and
1b826e95ac66bf54e532bb155261f4a39419efa9. It's an explicit, simple version
of the original testcase Markus gave on the bug (just with --strip-unneeded
instead of --strip-debug/-d).
Signed-off-by: Sam James <sam <AT> gentoo.org>
eclass/tests/dot-a.sh | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/eclass/tests/dot-a.sh b/eclass/tests/dot-a.sh
index 96b8c3a130a7..07416494441d 100755
--- a/eclass/tests/dot-a.sh
+++ b/eclass/tests/dot-a.sh
@@ -419,6 +419,8 @@ test_strip_lto() {
# one needs -ffat-lto-objects for our purposes in dot-a.eclass,
# but still, strip shouldn't break a non-fat object, and we want
# to know if that regresses.
+ #
+ # See test_strip_index as well.
tbegin "whether strip ignores LTO static archives"
ret=0
(
@@ -606,6 +608,29 @@ test_strip_cross() {
tend ${ret} "strip broke binary for a foreign architecture"
}
+test_strip_index() {
+ # Check specifically for whether we mangle the index in an archive
+ # which was the original testcase given in
https://sourceware.org/PR21479.
+ tbegin "whether strip breaks index on LTO static archive"
+ ret=0
+ (
+ rm foo.a foo.a.bak 2>/dev/null
+ _create_test_progs
+
+ $(tc-getCC) a.c -o a.o -c -flto -ggdb3 || return 1
+ $(tc-getAR) qD foo.a a.o 2>/dev/null || return 1
+ cp foo.a foo.a.bak || return 1
+ $(tc-getSTRIP) --enable-deterministic-archives -p
--strip-unneeded foo.a || return 1
+
+ # They should NOT differ after stripping because it
+ # can't be safely stripped without special arguments.
+ cmp -s foo.a foo.a.bak || return 1
+
+ return 0
+ ) || ret=1
+ tend ${ret} "strip broke index on LTO static archive"
+}
+
_repeat_tests_with_compilers() {
# Call test_lto_guarantee_fat and test_strip_lto_bytecode with
# various compilers and linkers.
@@ -666,4 +691,5 @@ test_strip_lto
test_strip_lto_mixed
test_strip_nolto
test_strip_cross
+test_strip_index
texit