]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: testsuite: Simplify emulation check in libgot tests
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 27 Jan 2026 17:26:59 +0000 (18:26 +0100)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 27 Jan 2026 17:26:59 +0000 (18:26 +0100)
The x86 libgot-1 tests are the only ones in all testsuites that use a
new ld -V -m<emul under test> idiom to check whether to run the tests.

Rather than open-coding the check everywhere while relying on that
idiom, this patch introduces a new proc to directly check the ld -V
output for the emulation in question.

Tested on {x86_64,i686}-pc-linux-gnu and {amd64,i386}-pc-solaris2.11.

2026-01-24  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

ld:
* testsuite/lib/ld-lib.exp (ld_supports_emul): New proc.
* testsuite/ld-i386/binutils.exp: Use it.
* testsuite/ld-x86-64/binutils.exp: Likewise.

ld/testsuite/ld-i386/binutils.exp
ld/testsuite/ld-x86-64/binutils.exp
ld/testsuite/lib/ld-lib.exp

index 40bbeacdf155e73c2d91ced4bf95ffb8e9b11e9e..58583e3966074e17b7333eb1b4fd3e56ac860d04 100644 (file)
@@ -27,9 +27,7 @@ if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
     return
 }
 
-# Tests here need -melf_i386 support.
-set status [catch "exec $LD -V -melf_i386" got]
-if { $status == 0 } {
+if [ld_supports_emul "elf_i386"] {
     run_ld_link_tests [list \
        [list \
            "Build libgot-1-i386.so" \
index beac28faecb4aa16f95793c16e4a2dbe672a60c6..cc466bdbc6d9b66f4a6e934d18b5f8c773c084be 100644 (file)
@@ -27,9 +27,7 @@ if { ![istarget "x86_64-*-*"] } {
     return
 }
 
-# Tests here need -melf_x86_64 support.
-set status [catch "exec $LD -V -melf_x86_64" got]
-if { $status == 0 } {
+if [ld_supports_emul "elf_x86_64"] {
     run_ld_link_tests [list \
        [list \
            "Build libgot-1-x64.so" \
@@ -46,9 +44,7 @@ if { $status == 0 } {
     ]
 }
 
-# Tests here need -melf32_x86_64 support.
-set status [catch "exec $LD -V -melf32_x86_64" got]
-if { $status == 0 } {
+if [ld_supports_emul "elf32_x86_64"] {
     run_ld_link_tests [list \
        [list \
            "Build libgot-1-x32.so" \
index 4b8708f789f67422789608bc1686a1e0b221e09b..851cd89790e82028f8c8483c762818f2b626b55d 100644 (file)
@@ -65,6 +65,17 @@ proc default_ld_version { ld } {
     }
 }
 
+# Check if ld supports emul.
+#
+proc ld_supports_emul { emul } {
+    global ld
+
+    set ld_output [remote_exec host $ld "-V"]
+    set ld_output [lindex $ld_output 1]
+
+    return [regexp "$emul\[\n\r\]" $ld_output]
+}
+
 proc run_host_cmd { prog command } {
     global link_output
     global gcc_B_opt