[PATCH v2] ld: testsuite: Simplify emulation check in libgot tests
Rainer Orth
ro@CeBiTec.Uni-Bielefeld.DE
Sat Jan 24 10:04:03 GMT 2026
Hi Alan,
>> On Thu, Jan 22, 2026 at 05:04:39PM +0100, Rainer Orth wrote:
>>> The x86 libgot-1 tests are the only ones in all testsuites that use a
>>> new ld -V -m<emul> idiom to check whether to run the tests. The
>>> emulations in question are supported on all ELF x86 targets., All other
>>> tests just check the target, so this patch follows this precedent.
>>>
>>> Tested on {x86_64,i686}-pc-linux-gnu and {amd64,i386}-pc-solaris2.11.
>>>
>>> Ok for trunk?
>>
>> No. Your assertion about -melf_i386 being supported on all ELF x86
>> targets is false.
>>
>> $ i386-lynxos/ld/ld-new -melf_i386 -V
>> /build/gas/i386-lynxos/ld/ld-new: unrecognised emulation mode: elf_i386
>> Supported emulations: i386lynx
>> $ i686-nto/ld/ld-new -melf_i386 -V
>> /build/gas/i686-nto/ld/ld-new: unrecognised emulation mode: elf_i386
>> Supported emulations: i386nto
>
> ah, I see. ISTM that there are more such targets:
>
> elf_i386_be.sh:OUTPUT_FORMAT="elf32-i386"
> elf_i386_haiku.sh:OUTPUT_FORMAT="elf32-i386"
> elf_i386_vxworks.sh:OUTPUT_FORMAT="elf32-i386-vxworks"
> i386lynx.sh:OUTPUT_FORMAT="elf32-i386"
> i386moss.sh:OUTPUT_FORMAT="elf32-i386"
> i386nto.sh:OUTPUT_FORMAT="elf32-i386"
>
> This would amount to all of
>
> i[3-7]86-*-beos*
> i[3-7]86-*-haiku*
> i[3-7]86-*-lynxos*
> i[3-7]86-*-moss*
> i[3-7]86-*-nto-qnx*
> i[3-7]86-*-vxworks*
>
> While we could skip them at the top of ld-i386/binutils.exp, I wonder a
> couple of things here:
>
> * Would this test work with -melf_i386 replaced by e.g. -mi386lynx?
>
> * If so, would it be acceptable to replace the hardcoded -melf_i386 with
> something like -m [elf_i386_emul] with
>
> proc elf_i386_emul { } {
> if [istarget i?86-*-lynx*] {
> return i386lynx
> }
> is [istarget i?86-*-nto*] {
> return i386nto
> }
> return elf_i386
> }
>
> augmented to more targets as needed? This is inspired by
> ld-aarch64/lib/aarch64-elf-lib.exp (aarch64_choose_ilp32_emul).
>
> * Would this idiom work all over the testsuite? I.e. would tests
> currently hardcoding -melf_i386 work on all (or at least more) i?86 ELF
> targets?
>
> * If this works here, it might even be possible to do the same for
> -melf_x86_64 ...
while I still like this approach because it allows to extend test
coverage to i386 ELF targets without -melf_i386, I primarily would like
to go this way to enable removing the non-*_sol2 emulations from native
Solaris gld. They are never used outside of the ld testsuite, and I'd
rather test the native elf_i386_sol2 etc. emulations that *are* actually
used.
I guess I'll try this in ld-sparc first, where hardcoded
-melf32_sparc/elf64_sparc are only used 54 times, rather than
-melf_i386/elf_x86_64 (869 times).
I guess I'll try setting emul32/emul64 once in ld-lib.exp, then replace
all hardcoded instances of -m<emul> by $emul32/$emul64.
However, for the moment we can still do better, as shown below.
I still wonder, though, why this is the only place that needs to check
for -melf_i386 support when that is not supported on several i386 ELF
targets.
---------------------------------------------------------------------------
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.
Ok for trunk?
This was shamelessly stolen and adapted from
ld-mips-elf/mips-elf-flags.exp (check_ld_support_32bit). This should be
able to use
ld_supports_emul ".*elf32.*"
instead, but I cannot test this so I'm leaving it alone.
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: solx86-ld-testsuite-libgot-target.patch
Type: text/x-patch
Size: 1844 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260124/1acde487/attachment-0001.bin>
More information about the Binutils
mailing list