[PATCH v2 05/16] LD/testsuite: Expand archive verification to group feature

Maciej W. Rozycki macro@orcam.me.uk
Thu Nov 6 21:19:19 GMT 2025


From: Maciej W. Rozycki <macro@redhat.com>

Expand archive verification to cover the group feature.  Linker error 
messages for unsatisfied symbol references vary between targets a bit, 
in particular `arc-*-*' produce duplicate messages and `alpha*-*-osf*' 
and `alpha*-*-linux*ecoff*' add a "final link failed" message.  Factor 
this in with the error pattern list to match.  Usual XFAIL annotations
apply.
---
New change in v2.
---
 ld/testsuite/ld-archive/abcg.vd     |   28 +++++++++++++++++++++
 ld/testsuite/ld-archive/abcn.ed     |    6 ++++
 ld/testsuite/ld-archive/abtctg.vd   |   28 +++++++++++++++++++++
 ld/testsuite/ld-archive/archive.exp |   48 +++++++++++++++++++++++++++++++++++-
 4 files changed, 109 insertions(+), 1 deletion(-)

binutils-ld-test-archive-group.diff
Index: binutils-gdb/ld/testsuite/ld-archive/abcg.vd
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-archive/abcg.vd
@@ -0,0 +1,28 @@
+#...
+using ..ternal linker script:.*
+==================================================
+#...
+==================================================
+.*: mode .*
+attempt to open tmpdir/ab\.a succeeded
+tmpdir/ab\.a
+attempt to open tmpdir/abc\.a succeeded
+tmpdir/abc\.a
+Archive member included to satisfy reference by file \(symbol\)
+
+tmpdir/abc\.a\(abc\.o(:?bj)?\) +\(ff\)
+\(tmpdir/abc\.a\)abc\.o(:?bj)?
+tmpdir/ab\.a
+tmpdir/ab\.a\(a\.o(:?bj)?\) +tmpdir/abc\.a\(abc\.o(:?bj)?\) \(aa\)
+\(tmpdir/ab\.a\)a\.o(:?bj)?
+tmpdir/ab\.a\(b\.o(:?bj)?\) +tmpdir/abc\.a\(abc\.o(:?bj)?\) \(bb\)
+\(tmpdir/ab\.a\)b\.o(:?bj)?
+tmpdir/abc\.a
+!(:?\()?tmpdir/.*
+#...
+START GROUP
+LOAD tmpdir/ab\.a
+LOAD tmpdir/abc\.a
+END GROUP
+!LOAD .*
+#pass
Index: binutils-gdb/ld/testsuite/ld-archive/abcn.ed
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-archive/abcn.ed
@@ -0,0 +1,6 @@
+#?.*: in function `cc':
+.*: undefined reference to `aa'
+#?.*: undefined reference to `aa'
+.*: undefined reference to `bb'
+#?.*: undefined reference to `bb'
+#?.*: final link failed
Index: binutils-gdb/ld/testsuite/ld-archive/abtctg.vd
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-archive/abtctg.vd
@@ -0,0 +1,28 @@
+#...
+using ..ternal linker script:.*
+==================================================
+#...
+==================================================
+.*: mode .*
+attempt to open tmpdir/abt\.a succeeded
+tmpdir/abt\.a
+attempt to open tmpdir/abct\.a succeeded
+tmpdir/abct\.a
+Archive member included to satisfy reference by file \(symbol\)
+
+tmpdir/abc\.o +\(ff\)
+tmpdir/abc\.o
+tmpdir/abt\.a
+tmpdir/a\.o +tmpdir/abc\.o \(aa\)
+tmpdir/a\.o
+tmpdir/b\.o +tmpdir/abc\.o \(bb\)
+tmpdir/b\.o
+tmpdir/abct\.a
+!(:?\()?tmpdir/.*
+#...
+START GROUP
+LOAD tmpdir/abt\.a
+LOAD tmpdir/abct\.a
+END GROUP
+!LOAD .*
+#pass
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
@@ -20,7 +20,8 @@
 
 remote_file host delete \
     "tmpdir/ab.a" "tmpdir/cd.a" "tmpdir/abt.a" "tmpdir/cdt.a" \
-    "tmpdir/abn.a" "tmpdir/abnt.a"
+    "tmpdir/abn.a" "tmpdir/abnt.a" "tmpdir/abc.a" "tmpdir/abct.a" \
+    "tmpdir/abcn.a" "tmpdir/abcnt.a"
 
 run_ld_link_tests {
     {"First regular archive create"     ""   "" "" {a.s b.s x.s} {} "ab.a"   }
@@ -29,6 +30,10 @@ run_ld_link_tests {
     {"Second thin archive create"       "T"  "" "" {c.s d.s y.s} {} "cdt.a"  }
     {"Regular archive w/o index create" "S"  "" "" {a.s b.s x.s} {} "abn.a"  }
     {"Thin archive w/o index create"    "ST" "" "" {a.s b.s x.s} {} "abnt.a" }
+    {"Other regular archive create"           ""   "" "" {abc.s} {} "abc.a"  }
+    {"Other thin archive create"              "T"  "" "" {abc.s} {} "abct.a" }
+    {"Other regular archive w/o index create" "S"  "" "" {abc.s} {} "abcn.a" }
+    {"Other thin archive w/o index create"    "ST" "" "" {abc.s} {} "abcnt.a"}
 }
 
 set old_ldflags $LDFLAGS
@@ -110,6 +115,47 @@ run_ld_link_tests [list \
     ] \
 ]
 
+# Group archive tests.
+run_ld_link_tests [list \
+    [list "Regular non-group archive link reject" \
+	"-e ff tmpdir/ab.a" "tmpdir/abc.a" \
+	"" {} \
+	{{ld abcn.ed}} \
+	"abcn" \
+    ] \
+    [list "Thin non-group archive link reject" \
+	"-e ff tmpdir/abt.a" "tmpdir/abct.a" \
+	"" {} \
+	{{ld abcn.ed}} \
+	"abtctn" \
+    ] \
+    [list "Regular group archive link accept" \
+	"-e ff -\\( tmpdir/ab.a" "tmpdir/abc.a -\\) --verbose --print-map" \
+	"" {} \
+	[ld_archive_filter_tests {{ld abcg.vd} \
+				  {nm "" abc.nd} \
+				  {nm "" nx.nd}}] \
+	"abcg" \
+    ] \
+]
+setup_xfail "binutils/33484" "alpha*-*-linux*ecoff*" "alpha*-*-osf*"
+setup_xfail "binutils/33485" "cris-*-*aout*" "i\[3-7\]86-*-bsd*" \
+    "i\[3-7\]86-*-msdos*" "ns32k-*-*" "pdp11-*-*"
+setup_xfail "binutils/33600" "alpha*-*-*vms*"
+if { [is_xcoff_format] } {
+    setup_xfail "binutils/33600" "*-*-*"
+}
+run_ld_link_tests [list \
+    [list "Thin group archive link accept" \
+	"-e ff -\\( tmpdir/abt.a" "tmpdir/abct.a -\\) --verbose --print-map" \
+	"" {} \
+	[ld_archive_filter_tests {{ld abtctg.vd} \
+				  {nm "" abc.nd} \
+				  {nm "" nx.nd}}] \
+	"abtctg" \
+    ] \
+]
+
 # Dual archive tests.
 run_ld_link_tests [list \
     [list "Regular archive plus regular link" \


More information about the Binutils mailing list