From: Maciej W. Rozycki Date: Tue, 21 Oct 2025 20:02:38 +0000 (+0100) Subject: LD/testsuite: Add tests for mapless archive rejection X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37ffcc8891d6f0bc953d9434d4c5ba057f60f369;p=thirdparty%2Fbinutils-gdb.git 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 --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" \ + ] \ +]