]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LD/testsuite: Expand archive verification to group feature
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)
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.

ld/testsuite/ld-archive/abcg.vd [new file with mode: 0644]
ld/testsuite/ld-archive/abcn.ed [new file with mode: 0644]
ld/testsuite/ld-archive/abtctg.vd [new file with mode: 0644]
ld/testsuite/ld-archive/archive.exp

diff --git a/ld/testsuite/ld-archive/abcg.vd b/ld/testsuite/ld-archive/abcg.vd
new file mode 100644 (file)
index 0000000..40c7c88
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-archive/abcn.ed b/ld/testsuite/ld-archive/abcn.ed
new file mode 100644 (file)
index 0000000..2a5376a
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-archive/abtctg.vd b/ld/testsuite/ld-archive/abtctg.vd
new file mode 100644 (file)
index 0000000..9ad6e77
--- /dev/null
@@ -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 490db9e7b34becb9842a535b5f178126be5fec1e..861405b2ae8a35f16601d0d3db98f3779fcd5822 100644 (file)
@@ -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" \