[PATCH 2/8] LD/testsuite: Add tests for mapless archive rejection
Maciej W. Rozycki
macro@orcam.me.uk
Fri Sep 26 23:53:18 GMT 2025
From: Maciej W. Rozycki <macro@redhat.com>
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.
---
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(-)
binutils-ld-test-ar-noindex.diff
Index: binutils-gdb/ld/testsuite/ld-archive/abc.ed
===================================================================
--- /dev/null
+++ binutils-gdb/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
Index: binutils-gdb/ld/testsuite/ld-archive/abct.ed
===================================================================
--- /dev/null
+++ binutils-gdb/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
Index: binutils-gdb/ld/testsuite/ld-archive/archive.exp
===================================================================
--- binutils-gdb.orig/ld/testsuite/ld-archive/archive.exp
+++ binutils-gdb/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
mailing list