[PATCH v2] ld: testsuite: Simplify emulation check in libgot tests

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Mon Jan 26 10:13:45 GMT 2026


Hi Maciej,

> On Sun, 25 Jan 2026, Rainer Orth wrote:
>
>> This way, you'd always prefer the native emulations, not a hardcoded one
>> like elf32_sparc.  The latter is only used in the ld testsuite, while
>> gcc always uses elf32_sparc_sol2.  I'm not interested in test results
>> that don't match actual use.  Those are irrelevant IMO.
>
>  This makes sense if you don't use multilibs.  With MIPS targets secondary 
> linker emulations are often used with non-default multilibs, which can be 
> a mixture of 32-bit and 64-bit ones, more than one of each, so it makes 
> perfect sense to have them covered in the testsuite as well.

well, the proposed implementation clearly concentrates on biarch and
monoarch targets.  In that case, we have two questions to ask:

* Does the target support any 32 or 64-bit emulation?

* If so, which emulation name should be used?

  E.g. on SPARC there are biarch targets (Solaris and Linux for example)
  that use either elf32_sparc_sol2 or elf32_sparc for 32-bit,
  elf64_sparc_sol2, elf64_sparc_sol2 or elf64_sparc for 64-bit, and
  monoarch targets like sparc-*-elf* which only support elf32_sparc.

That logic could be concentrated in one place and the result used as
needed.

In the x86 case, we have something similar: biarch targets using
different names for their native 32 and 64-bit emulations, and monoarch
targets that use a different naming scheme, like LynxOS which uses
i386lynx for its 32-bit emulation, which prompted this approach in the
first place.

Those questions can be answered programmatically from the ld -V output,
similar to what I suggested.

However, I suspect even beyond that need, something like the MIPS case
could be handled in a similar way: extracting supported emulations from
ld -V.  The method to do this and the set of emulations to check for is
wider than in the SPARC and x86 cases, but a similar approach might be
possible.

Just a thought: I'm well aware that MIPS is a complicated beast, even
back in the times when I dealt with IRIX 6 with its O32, N32, and N64
ABIs.  You'd have to decide if the target under test would support N64
at all: some CPUs did, others did not.

Just food for thought...

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


More information about the Binutils mailing list