On Fri, Aug 8, 2025 at 6:26 AM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> When GNU binutils is configured with --enable-targets=all on Linux,
> "ld -V" will report both elf_x86_64_sol2 and elf_i386_sol2 as supported
> emulations.  But they should only be used for Solaris 2 targets.  Check
> for Solaris 2 targets before using sol2 linker emulations.
>
>         PR target/121457
>         * configure: Regenerated.
>         * configure.ac (ld_ix86_gld_32_opt): Se to -melf_i386_sol2 only
>         for Solaris 2 targets.
>         (ld_ix86_gld_64_opt): Set to -melf_x86_64_sol2 only for Solaris
>         2 targets.
>
> Signed-off-by: H.J. Lu <hjl.to...@gmail.com>

> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 2c43b38178c..9817ab280eb 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -5009,13 +5009,16 @@ foo:    nop
>      if test x$gas = xyes; then
>        as_ix86_gas_32_opt="--32"
>      fi
> -    if echo "$ld_ver" | grep GNU > /dev/null; then
> -      if $gcc_cv_ld -V 2>/dev/null | grep elf_i386_sol2 > /dev/null; then
> -        ld_ix86_gld_32_opt="-melf_i386_sol2"
> -      else
> -        ld_ix86_gld_32_opt="-melf_i386"
> -      fi
> -    fi
> +    ld_ix86_gld_32_opt="-melf_i386"

Please do not overwrite the default ...

> +    case "$target" in
> +      *-*-solaris2*)
> +       if echo "$ld_ver" | grep GNU > /dev/null; then
> +         if $gcc_cv_ld -V 2>/dev/null | grep elf_i386_sol2 > /dev/null; then
> +           ld_ix86_gld_32_opt="-melf_i386_sol2"
> +         fi
> +       fi
> +       ;;

... but use the default *) case as the case in other examples
throughout configure.ac

> +    esac
>
>      gcc_GAS_CHECK_FEATURE([R_386_TLS_GD_PLT reloc],
>          gcc_cv_as_ix86_tlsgdplt,
> @@ -5107,13 +5110,16 @@ _start:
>
>      # Check if gas and gld support "addq %r23,foo@GOTTPOFF(%rip), %r15"
>      # with R_X86_64_CODE_6_GOTTPOFF relocation.
> -    if echo "$ld_ver" | grep GNU > /dev/null; then
> -      if $gcc_cv_ld -V 2>/dev/null | grep elf_x86_64_sol2 > /dev/null; then
> -        ld_ix86_gld_64_opt="-melf_x86_64_sol2"
> -      else
> -        ld_ix86_gld_64_opt="-melf_x86_64"
> -      fi
> -    fi
> +    ld_ix86_gld_64_opt="-melf_x86_64"
> +    case "$target" in
> +      *-*-solaris2*)
> +       if echo "$ld_ver" | grep GNU > /dev/null; then
> +         if $gcc_cv_ld -V 2>/dev/null | grep elf_x86_64_sol2 > /dev/null; 
> then
> +           ld_ix86_gld_64_opt="-melf_x86_64_sol2"
> +         fi
> +       fi
> +       ;;

Also here.

> +    esac
>      # Enforce 64-bit output with gas and gld.
>      if test x$gas = xyes; then
>        as_ix86_gas_64_opt="--64"
> --
> 2.50.1
>

Reply via email to