[binutils-gdb] LD/testsuite: Fix archive verification for Alpha/VMS

Maciej W. Rozycki macro@sourceware.org
Mon Dec 15 19:11:25 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7b12694de97f19d18de2d6019743f0ff3e64420f

commit 7b12694de97f19d18de2d6019743f0ff3e64420f
Author: Maciej W. Rozycki <macro@redhat.com>
Date:   Mon Dec 15 19:04:30 2025 +0000

    LD/testsuite: Fix archive verification for Alpha/VMS
    
    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.

Diff:
---
 ld/testsuite/ld-archive/archive.exp | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/ld/testsuite/ld-archive/archive.exp b/ld/testsuite/ld-archive/archive.exp
index 0d63df704ec..b8685e94f42 100644
--- a/ld/testsuite/ld-archive/archive.exp
+++ b/ld/testsuite/ld-archive/archive.exp
@@ -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
 }


More information about the Binutils-cvs mailing list