[binutils-gdb] LD/testsuite: Add tests for mapless archive rejection
Maciej W. Rozycki
macro@sourceware.org
Tue Oct 21 20:05:44 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=37ffcc8891d6f0bc953d9434d4c5ba057f60f369
commit 37ffcc8891d6f0bc953d9434d4c5ba057f60f369
Author: Maciej W. Rozycki <macro@redhat.com>
Date: Tue Oct 21 21:02:38 2025 +0100
LD/testsuite: Add tests for mapless archive rejection
Verify that archives are rejected in the link, regular and thin, that
have no symbol map included. Exclude XCOFF targets from verification
which have handling for such archives implemented and therefore accept
them. These targets will be handled with a follow-up change.
Diff:
---
ld/testsuite/ld-archive/abc.ed | 1 +
ld/testsuite/ld-archive/abct.ed | 1 +
ld/testsuite/ld-archive/archive.exp | 25 ++++++++++++++++++++++++-
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/ld/testsuite/ld-archive/abc.ed b/ld/testsuite/ld-archive/abc.ed
new file mode 100644
index 00000000000..10a696e755e
--- /dev/null
+++ b/ld/testsuite/ld-archive/abc.ed
@@ -0,0 +1 @@
+[^\n]*: tmpdir/abn.a: error adding symbols: archive has no index; run ranlib to add one
diff --git a/ld/testsuite/ld-archive/abct.ed b/ld/testsuite/ld-archive/abct.ed
new file mode 100644
index 00000000000..c19b479dfc2
--- /dev/null
+++ b/ld/testsuite/ld-archive/abct.ed
@@ -0,0 +1 @@
+[^\n]*: tmpdir/abnt.a: error adding symbols: archive has no index; run ranlib to add one
diff --git a/ld/testsuite/ld-archive/archive.exp b/ld/testsuite/ld-archive/archive.exp
index 0e942a4c4ae..a3dafcc8dab 100644
--- a/ld/testsuite/ld-archive/archive.exp
+++ b/ld/testsuite/ld-archive/archive.exp
@@ -19,13 +19,16 @@
#
remote_file host delete \
- "tmpdir/ab.a" "tmpdir/cd.a" "tmpdir/abt.a" "tmpdir/cdt.a"
+ "tmpdir/ab.a" "tmpdir/cd.a" "tmpdir/abt.a" "tmpdir/cdt.a" \
+ "tmpdir/abn.a" "tmpdir/abnt.a"
run_ld_link_tests {
{"First regular archive create" "" "" "" {a.s b.s} {} "ab.a" }
{"Second regular archive create" "" "" "" {c.s d.s} {} "cd.a" }
{"First thin archive create" "T" "" "" {a.s b.s} {} "abt.a" }
{"Second thin archive create" "T" "" "" {c.s d.s} {} "cdt.a" }
+ {"Regular archive w/o index create" "S" "" "" {a.s b.s} {} "abn.a" }
+ {"Thin archive w/o index create" "ST" "" "" {a.s b.s} {} "abnt.a"}
}
set old_ldflags $LDFLAGS
@@ -98,3 +101,23 @@ run_ld_link_tests [list \
]
set LDFLAGS $old_ldflags
+
+# XCOFF targets currently accept archives w/o index.
+if { [is_xcoff_format] } {
+ return
+}
+
+run_ld_link_tests [list \
+ [list "Regular archive w/o index link" \
+ "-e ff" "tmpdir/abn.a" \
+ "" {abc.s} \
+ {{ld abc.ed}} \
+ "abnc" \
+ ] \
+ [list "Thin archive w/o index link" \
+ "-e ff" "tmpdir/abnt.a" \
+ "" {abc.s} \
+ {{ld abct.ed}} \
+ "abnct" \
+ ] \
+]
More information about the Binutils-cvs
mailing list