[PATCH] ld: testsuite: Check target in libgot tests

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Fri Jan 23 10:51:39 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 ...

	Rainer

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


More information about the Binutils mailing list