]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LD/testsuite: Fix archive verification for Alpha/VMS
authorMaciej W. Rozycki <macro@redhat.com>
Mon, 15 Dec 2025 19:04:30 +0000 (19:04 +0000)
committerMaciej W. Rozycki <macro@redhat.com>
Mon, 15 Dec 2025 19:04:30 +0000 (19:04 +0000)
As from commit a2298f23f2e2 ("PR 33385 vms archives") the handling of
Alpha/VMS archives has been recently unbroken, after 7 years, revealing
issues with archive tests added with commit 435223a9ae70 ("LD/testsuite:
Add tests for archive handling"), the change of the failure mode of
which went unnoticed.

In particular there is no NM support for executables and archives always
have an index by the nature of the format; cf. `_bfd_vms_lib_archive_p':
"The map is always present."

Address these peculiarities by excluding NM tests for the executables
produced and by omitting mapless archive rejection tests just as with
XCOFF targets, removing all the test failures:

alpha-dec-vms  -FAIL: Regular archive link
alpha-dec-vms  -FAIL: Thin archive link
alpha-dec-vms  -FAIL: Regular archive plus regular link
alpha-dec-vms  -FAIL: Regular archive plus thin link
alpha-dec-vms  -FAIL: Thin archive plus regular link
alpha-dec-vms  -FAIL: Thin archive plus thin link
alpha-dec-vms  -FAIL: Regular archive w/o index link
alpha-dec-vms  -FAIL: Thin archive w/o index link

Factor out code to filter out unwanted tests to a procedure for a better
structure of the code.

ld/testsuite/ld-archive/archive.exp

index 0d63df704ec0197d4a2996c39c5814cc6514be40..b8685e94f42eb6df99971b447e994d05efae6d47 100644 (file)
@@ -38,12 +38,27 @@ if { [is_xcoff_format] } {
     append LDFLAGS " -bexpall"
 }
 
-# For MS-DOS there's no way to keep symbols, so just check for success.
+# With Alpha/VMS NM doesn't handle executables and for MS-DOS there's no way
+# to keep symbols, so filter out any NM tests.
+proc ld_archive_filter_tests { arg } {
+    if { ![istarget "*-*-msdos"] && ![istarget "alpha*-*-*vms*"] } {
+       return $arg
+    } else {
+       set tests {}
+       foreach test $arg {
+           if { [lindex $test 0] != "nm" } {
+               lappend tests $test
+           }
+       }
+       return $tests
+    }
+}
+
 run_ld_link_tests [list \
     [list "Regular archive link" \
        "-e ff" "tmpdir/ab.a" \
        "" {abc.s} \
-       [expr { [istarget "*-*-msdos"] ? {} : {{nm "" abc.nd}} }] \
+       [ld_archive_filter_tests {{nm "" abc.nd}}] \
        "abc" \
     ] \
 ]
@@ -54,7 +69,7 @@ run_ld_link_tests [list \
     [list "Thin archive link" \
        "-e ff" "tmpdir/abt.a" \
        "" {abc.s} \
-       [expr { [istarget "*-*-msdos"] ? {} : {{nm "" abc.nd}} }] \
+       [ld_archive_filter_tests {{nm "" abc.nd}}] \
        "abtc" \
     ] \
 ]
@@ -62,7 +77,7 @@ run_ld_link_tests [list \
     [list "Regular archive plus regular link" \
        "-e ff" "tmpdir/ab.a tmpdir/cd.a" \
        "" {abcde.s} \
-       [expr { [istarget "*-*-msdos"] ? {} : {{nm "" abcde.nd}} }] \
+       [ld_archive_filter_tests {{nm "" abcde.nd}}] \
        "abcde" \
     ] \
 ]
@@ -73,7 +88,7 @@ run_ld_link_tests [list \
     [list "Regular archive plus thin link" \
        "-e ff" "tmpdir/ab.a tmpdir/cdt.a" \
        "" {abcde.s} \
-       [expr { [istarget "*-*-msdos"] ? {} : {{nm "" abcde.nd}} }] \
+       [ld_archive_filter_tests {{nm "" abcde.nd}}] \
        "abcdte" \
     ] \
 ]
@@ -84,7 +99,7 @@ run_ld_link_tests [list \
     [list "Thin archive plus regular link" \
        "-e ff" "tmpdir/abt.a tmpdir/cd.a" \
        "" {abcde.s} \
-       [expr { [istarget "*-*-msdos"] ? {} : {{nm "" abcde.nd}} }] \
+       [ld_archive_filter_tests {{nm "" abcde.nd}}] \
        "abtcde" \
     ] \
 ]
@@ -95,15 +110,16 @@ run_ld_link_tests [list \
     [list "Thin archive plus thin link" \
        "-e ff" "tmpdir/abt.a tmpdir/cdt.a" \
        "" {abcde.s} \
-       [expr { [istarget "*-*-msdos"] ? {} : {{nm "" abcde.nd}} }] \
+       [ld_archive_filter_tests {{nm "" abcde.nd}}] \
        "abtcdte" \
     ] \
 ]
 
 set LDFLAGS $old_ldflags
 
-# XCOFF targets currently accept archives w/o index.
-if { [is_xcoff_format] } {
+# Alpha/VMS archives always have an index and XCOFF targets currently
+# accept archives without one.
+if { [istarget "alpha*-*-*vms*"] || [is_xcoff_format] } {
     return
 }