[PATCH] x86/Solaris: address two ld test FAILs

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Fri Dec 12 10:45:40 GMT 2025


Hi Jan,

> ld's ld-{i386,x86_64}/libgot-1-* tests want to use plain ELF linker
> targets. Those won't work though if selected only in ld's configure.tgt
> (via targ_extra_emuls). They would also need enabling in BFD, but
> adjustments there were done in the opposite direction pretty recently.
> ---
> I further question the setting of want64 for i[3-7]86-*-solaris2* - that's
> inconsistent with all other ix86 targets. Of course then the respective
> targ_extra_emuls here also needs to change to targ64_extra_emuls.
>
> Why is it that ASSOCIATED_VECS is set only for --enable-targets=all? The
> different behavior of bfd_check_format_matches() with and without it set,
> when multiple targets match, looks like a pretty obvious problem to me.

as I already mentioned in passing when H.J. suggested a similar patch
(although x86-only) that we cannot yet remove the non-_sol2 emulatations
on Solaris for a pretty ugly reason: current libtool has this snippet in
m4/libtool.m4:

    case `$FILECMD conftest.o` in
    *64-bit*)
      case $lt_cv_prog_gnu_ld in
      yes*)
        case $host in
        i?86-*-solaris*|x86_64-*-solaris*)
          LD="${LD-ld} -m elf_x86_64"
          ;;
        sparc*-*-solaris*)
          LD="${LD-ld} -m elf64_sparc"
          ;;
        esac
        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
          LD=${LD-ld}_sol2
        fi
        ;;

The consequence is that in 64-bit mode it tries to run

gld -m elf_x86_64 -V

to determine if the *_sol2 emulations are present.  However, this fails:

gld: unrecognised emulation mode: elf_x86_64
Supported emulations: elf_i386_sol2 elf_x86_64_sol2

badly breaking the check for shared library support.  Since this is
widely deployed, there needs to be a way around this.

I've come up with the following solution so far: since the output of gld
-V is equivalent irrespective of the emulation specified

$ gld -m elf_x86_64_sol2 -V
GNU ld (GNU Binutils) 2.45.50.20251126
  Supported emulations:
   elf_i386_sol2
   elf_x86_64_sol2
$ gld -m elf_i386_sol2 -V
GNU ld (GNU Binutils) 2.45.50.20251126
  Supported emulations:
   elf_i386_sol2
   elf_x86_64_sol2

(except for the ordering), there's little point of heeding the emulation
*in this particular case* at all.  If we ignore -m with -V, the above
continues to work.  Implementing this is a bit ugly since the -m option
is handled separately very early on, way before -V is checked for.  I've
come up with the following:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ld-V-memul-ignore.patch
Type: text/x-patch
Size: 490 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20251212/dd79afc0/attachment.bin>
-------------- next part --------------

to address this.  I have no idea if this is acceptable, but it would
avoid the issue above nicely in a minimally intrusive way.

Even with this patch, I'm still struggeling with the *_sol2 removal,
which may well be due to the issues you point out above.  I'm looking
into as we speak.

	Rainer

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


More information about the Binutils mailing list