]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LD/testsuite: Add tests for mapless archive rejection
authorMaciej W. Rozycki <macro@redhat.com>
Tue, 21 Oct 2025 20:02:38 +0000 (21:02 +0100)
committerMaciej W. Rozycki <macro@redhat.com>
Tue, 21 Oct 2025 20:02:38 +0000 (21:02 +0100)
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 [new file with mode: 0644]
ld/testsuite/ld-archive/abct.ed [new file with mode: 0644]
ld/testsuite/ld-archive/archive.exp

diff --git a/ld/testsuite/ld-archive/abc.ed b/ld/testsuite/ld-archive/abc.ed
new file mode 100644 (file)
index 0000000..10a696e
--- /dev/null
@@ -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 (file)
index 0000000..c19b479
--- /dev/null
@@ -0,0 +1 @@
+[^\n]*: tmpdir/abnt.a: error adding symbols: archive has no index; run ranlib to add one
index 0e942a4c4ae8c343068798924391d5e49dab394a..a3dafcc8dabbf48c211d24e62bd4ee4291316d36 100644 (file)
 #
 
 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" \
+    ] \
+]