From: Rainer Orth Date: Tue, 27 Jan 2026 17:26:59 +0000 (+0100) Subject: ld: testsuite: Simplify emulation check in libgot tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45df08bfcdaaf54d905b62df78608f052da81f1b;p=thirdparty%2Fbinutils-gdb.git ld: testsuite: Simplify emulation check in libgot tests The x86 libgot-1 tests are the only ones in all testsuites that use a new ld -V -m 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 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. --- diff --git a/ld/testsuite/ld-i386/binutils.exp b/ld/testsuite/ld-i386/binutils.exp index 40bbeacdf15..58583e39660 100644 --- a/ld/testsuite/ld-i386/binutils.exp +++ b/ld/testsuite/ld-i386/binutils.exp @@ -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" \ diff --git a/ld/testsuite/ld-x86-64/binutils.exp b/ld/testsuite/ld-x86-64/binutils.exp index beac28faecb..cc466bdbc6d 100644 --- a/ld/testsuite/ld-x86-64/binutils.exp +++ b/ld/testsuite/ld-x86-64/binutils.exp @@ -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" \ diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 4b8708f789f..851cd89790e 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -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