From: Rainer Orth Date: Thu, 11 Dec 2025 13:43:16 +0000 (+0100) Subject: Cleanup bfd target vectors and ld emulations on Solaris X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d0f24dfbdafc52d54316d3bfd688cbf8f8ae037;p=thirdparty%2Fbinutils-gdb.git Cleanup bfd target vectors and ld emulations on Solaris This patch is a major cleanup of the Solaris configurations of both bfd and ld. The Solaris cases in both bfd/config.bfd and ld/configure.tgt have seen a major cleanup, making the support for various Solaris versions explicit, correcting several inconsistencies, and making it easier to remove support for some versions in the future. * All 32-bit-only configurations (Solaris < 7 on SPARC, Solaris < 10 on x86) only include the 32-bit target vectors and linker emulations. * For 32-bit-default targets on 64-bit systems (Solaris >= 7 on SPARC, Solaris >= 10 on x86), the 32-bit target vectors and linker emulations are the default while supporting the 64-bit ones. * For 64-bit-default targets on 64-bit systems, it's the other way round. They default to 64-bit target vectors etc. while also supporting the 32-bit ones. * Added a warning to all Solaris cases in config.bfd not to include the non-*_sol2 vectors to avoid the ambiguity reported in PR binutils/27666. * On x86, the iamcu target vectors and linker emulations have been removed: Solaris never supported the Intel MCU. * On x86, the PE and PEI target vectors have been removed: they were only supported in binutils proper. Their only use would be on EFI files e.g. in GRUB, which doesn't justify their inclusion. * With iamcu support gone, a few gas tests had to be disabled as on VxWorks. * The 32-bit Solaris/x86 ld configuration currently includes the elf_i386_ldso emulation, which was never a emulation in its own right but just an implementation detail of the elf_i386_sol2 emulation. Instead, the settings that are not already provided by sourced .sh files are moved into elf_i386_sol2.sh. Many settings became superfluous by just sourcing elf_i386.sh as is already done in elf_x86_64_sol2.sh, massively simplifying the emulation. * Solaris-specific settings in generic emulparams scripts have been moved to the *_sol2.sh files. * NATIVE_LIB_DIRS in ld/configure.tgt now uses the default setting: /usr/ccs/lib contains just a bunch of symlinks into /usr/lib at least since Solaris 8. * ld/emulparams/solaris2.sh now sets ELF_INTERPRETER_NAME to /usr/lib/amd64/ld.so.1, matching both the native linker and elf_i386_sol2.sh. * The SEARCH_DIR statements in linker scripts on 64-bit targets contained both the native (64-bit) and non-default (32-bit) directies. The latter are completely pointless and are omitted using a new LIBPATH_SKIP_NONNATIVE setting. Tested on {amd64,i386}-pc-solaris2.11 and {sparcv9,sparc}-sun-solaris2.11, and {x86_64,i686}-pc-linux-gnu as well as with gcc trunk bootstraps on the Solaris targets. On those, I've compared the gas/ld and gas/gld 2.45.50 testresults with 2.45 ones. 2025-09-09 Rainer Orth bfd: * config.bfd : Split into ... ... this. (targ_selvecs): Remove iamcu_elf32_vec, i386_coff_vec, i386_pei_vec. (targ64_selvecs): Remove x86_64_pe_vec, x86_64_pei_vec. : ... and this. [BFD64] : Change into x86_64-*-solaris2.1[01]*. (targ_defvecs): Change to x86_64_elf64_sol2_vec. (targ_selvecs): Remove iamcu_elf32_vec, i386_coff_vec, i386_pei_vec, x86_64_pe_vec, x86_64_pei_vec. : Split into ... : ... this. : ... this. [BFD64] : Omit sparc-*-solaris2*. (targ_defvec): Swap with targ_selvecs. * testsuite/gas/i386/i386.exp: Disable iamcu tests on Solaris. ld: * configure.tgt : Split into ... : .. this. (targ_extra_emuls): Remove elf_i386_ldso and elf_iamcu. : ... and this. : Change into ... : ... this (targ_extra_emuls): Reorder. (tdir_elf32_sparc): Remove. : New case. : Change into ... : ... this. : Remove. : Change into ... : ... this. (targ_extra_emuls): Reorder. Remove elf_i386_ldso, elf_iamcu. (tdir_elf_i386): Remove. (NATIVE_LIB_DIRS): Remove Solaris handling. * emulparams/elf32_sparc_sol2.sh (ELF_INTERPRETER_NAME): New variable. * emulparams/elf64_sparc.sh (LIBPATH_SUFFIX): Move ... * emulparams/elf64_sparc_sol2.sh: ... here. (LIBPATH_SKIP_NONNATIVE): New variable. (ELF_INTERPRETER_NAME): Likewise. * emulparams/elf_i386_ldso.sh: Merge into ... * emulparams/elf_i386_sol2.sh: ... this. Remove duplicate variables. Source elf_i386.sh instead of elf_i386_ldso.sh. * emulparams/elf_x86_64.sh <*-*-solaris2*> (ELF_INTERPRETER_NAME): Move ... * emulparams/elf_x86_64_sol2.sh: ... here. Use /usr/lib/amd64/ld.so.1. (LIBPATH_SKIP_NONNATIVE): New variable. * emulparams/solaris2.sh: Fix comment. * genscripts.sh: Fix typos. Heed LIBPATH_SKIP_NONNATIVE. --- diff --git a/bfd/config.bfd b/bfd/config.bfd index 4a0b7886acc..bf6ea9f71e0 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -594,16 +594,21 @@ case "${targ}" in targ_defvec=i386_elf32_vec targ_selvecs="iamcu_elf32_vec i386_coff_vec" ;; - i[3-7]86-*-solaris2*) + i[3-7]86-*-solaris2.1[01]*) + # PR 27666: Do not include i386_elf32_vec or x86_64_elf64_vec. targ_defvec=i386_elf32_sol2_vec - targ_selvecs="iamcu_elf32_vec i386_coff_vec i386_pei_vec" - targ64_selvecs="x86_64_elf64_sol2_vec x86_64_pe_vec x86_64_pei_vec" + targ64_selvecs=x86_64_elf64_sol2_vec want64=true ;; -#ifdef BFD64 - x86_64-*-solaris2*) + i[3-7]86-*-solaris2.[0-9]*) + # PR 27666: Do not include i386_elf32_vec here. targ_defvec=i386_elf32_sol2_vec - targ_selvecs="x86_64_elf64_sol2_vec iamcu_elf32_vec i386_coff_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec" + ;; +#ifdef BFD64 + x86_64-*-solaris2.1[01]*) + # PR 27666: Do not include i386_elf32_vec or x86_64_elf64_vec. + targ_defvec=x86_64_elf64_sol2_vec + targ_selvecs=i386_elf32_sol2_vec want64=true ;; #endif @@ -1332,16 +1337,22 @@ case "${targ}" in targ_selvecs="sh_coff_vec sh_coff_le_vec sh_coff_small_vec sh_coff_small_le_vec" targ_underscore=yes ;; - - sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*) + sparc-*-solaris2.[7-9]* | sparc-*-solaris2.1[01]*) + # PR 27666: Do not include sparc_elf32_vec or sparc_elf64_vec here. + targ_defvec=sparc_elf32_sol2_vec + targ64_selvecs=sparc_elf64_sol2_vec + want64=true + ;; + sparc-*-solaris2.[0-6]*) # PR 27666: Do not include sparc_elf32_vec here. targ_defvec=sparc_elf32_sol2_vec ;; #ifdef BFD64 - sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*) + sparcv9-*-solaris2.[7-9]* | sparcv9-*-solaris2.1[01]* | \ + sparc64-*-solaris2.[7-9]* | sparc64-*-solaris2.1[01]*) # PR 27666: Do not include sparc_elf32_vec or sparc_elf64_vec here. - targ_defvec=sparc_elf32_sol2_vec - targ_selvecs="sparc_elf64_sol2_vec" + targ_defvec=sparc_elf64_sol2_vec + targ_selvecs=sparc_elf32_sol2_vec want64=true ;; sparc64-*-haiku*) diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 08f3e3c1e3c..58c6d634c73 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -807,7 +807,7 @@ if [gas_32_check] then { run_list_test "code64-inval" "-I${srcdir}/$subdir -al" } - if {![istarget "*-*-vxworks*"]} then { + if {!([istarget "*-*-solaris2*"] || [istarget "*-*-vxworks*"])} then { run_dump_test "iamcu-1" run_dump_test "iamcu-2" run_dump_test "iamcu-3" diff --git a/ld/configure.tgt b/ld/configure.tgt index df31897f6d4..31fa2d8aded 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -373,12 +373,14 @@ i[3-7]86-*-linux-*) targ_emul=elf_i386 i[3-7]86-*-redox*) targ_emul=elf_i386 targ_extra_emuls=elf_x86_64 ;; -i[3-7]86-*-solaris2*) targ_emul=elf_i386_sol2 - targ_extra_emuls="elf_i386_ldso elf_i386 elf_iamcu elf_x86_64_sol2 elf_x86_64" +i[3-7]86-*-solaris2.1[01]*) + targ_emul=elf_i386_sol2 + targ_extra_emuls="elf_x86_64_sol2 elf_i386 elf_x86_64" targ_extra_libpath=$targ_extra_emuls ;; -i[3-7]86-*-solaris*) targ_emul=elf_i386_ldso - targ_extra_emuls="elf_i386" +i[3-7]86-*-solaris2.[0-9]*) + targ_emul=elf_i386_sol2 + targ_extra_emuls=elf_i386 targ_extra_libpath=$targ_extra_emuls ;; i[3-7]86-*-netbsd* | \ @@ -916,11 +918,11 @@ sparc64-*-linux-*) targ_emul=elf64_sparc sparc64-*-*bsd*) targ_emul=elf64_sparc targ_extra_emuls="elf32_sparc" ;; -sparc64-*-solaris2* | sparcv9-*-solaris2*) +sparc64-*-solaris2.[7-9]* | sparc64-*-solaris2.1[01]* | \ +sparcv9-*-solaris2.[7-9]* | sparcv9-*-solaris2.1[01]*) targ_emul=elf64_sparc_sol2 - targ_extra_emuls="elf64_sparc elf32_sparc_sol2 elf32_sparc" + targ_extra_emuls="elf32_sparc_sol2 elf64_sparc elf32_sparc" targ_extra_libpath=$targ_extra_emuls - tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'` ;; sparc64-*-haiku*) targ_emul=elf64_sparc ;; @@ -931,14 +933,14 @@ sparc*-*-linux-*) targ_emul=elf32_sparc targ_extra_libpath=elf64_sparc tdir_elf64_sparc=`echo ${targ_alias} | sed -e 's/32//'` ;; -sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*) +sparc-*-solaris2.[7-9]* | sparc-*-solaris2.1[01]*) targ_emul=elf32_sparc_sol2 - targ_extra_emuls=elf32_sparc - ;; -sparc-*-solaris2*) targ_emul=elf32_sparc_sol2 - targ_extra_emuls="elf32_sparc elf64_sparc_sol2 elf64_sparc" + targ_extra_emuls="elf64_sparc_sol2 elf32_sparc elf64_sparc" targ_extra_libpath=$targ_extra_emuls - tdir_elf64_sparc=`echo ${targ_alias} | sed -e 's/32//'` + ;; +sparc-*-solaris2.[0-6]*) + targ_emul=elf32_sparc_sol2 + targ_extra_emuls=elf32_sparc ;; sparc*-*-vxworks*) targ_emul=elf32_sparc_vxworks ;; @@ -1006,10 +1008,10 @@ x86_64-*-linux-*) targ_emul=elf_x86_64 x86_64-*-redox*) targ_emul=elf_x86_64 targ_extra_emuls=elf_i386 ;; -x86_64-*-solaris2*) targ_emul=elf_x86_64_sol2 - targ_extra_emuls="elf_x86_64 elf_i386_sol2 elf_i386_ldso elf_i386 elf_iamcu" +x86_64-*-solaris2.1[01]*) + targ_emul=elf_x86_64_sol2 + targ_extra_emuls="elf_i386_sol2 elf_x86_64 elf_i386" targ_extra_libpath=$targ_extra_emuls - tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;; x86_64-*-netbsd* | x86_64-*-openbsd*) targ_emul=elf_x86_64 @@ -1107,10 +1109,6 @@ i[3-7]86-*-sysv4*) NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib' ;; -i[3-7]86-*-solaris*) - NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib' - ;; - i[3-7]86-pc-interix*) NATIVE_LIB_DIRS='/usr/local/lib $$INTERIX_ROOT/usr/lib /lib /usr/lib' ;; @@ -1119,10 +1117,6 @@ ia64-*-aix*) NATIVE_LIB_DIRS='/usr/local/lib /usr/lib/ia64l64 /lib /usr/lib' ;; -sparc*-*-solaris2*) - NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib' - ;; - spu-*-elf*) # This allows one to build a pair of PPU/SPU toolchains with common sysroot. NATIVE_LIB_DIRS='/lib' diff --git a/ld/emulparams/elf32_sparc_sol2.sh b/ld/emulparams/elf32_sparc_sol2.sh index 07c8430814d..e5c9f9a6618 100644 --- a/ld/emulparams/elf32_sparc_sol2.sh +++ b/ld/emulparams/elf32_sparc_sol2.sh @@ -2,3 +2,4 @@ source_sh ${srcdir}/emulparams/elf32_sparc.sh source_sh ${srcdir}/emulparams/solaris2.sh EXTRA_EM_FILE=solaris2 OUTPUT_FORMAT="elf32-sparc-sol2" +ELF_INTERPRETER_NAME=\"/usr/lib/ld.so.1\" diff --git a/ld/emulparams/elf64_sparc.sh b/ld/emulparams/elf64_sparc.sh index afbf2e6a475..9409b786942 100644 --- a/ld/emulparams/elf64_sparc.sh +++ b/ld/emulparams/elf64_sparc.sh @@ -25,18 +25,16 @@ if test `echo "$host" | sed -e 's/64//;s/v[789]//'` \ esac fi -# Linux and Solaris modify the default library search path +# Linux modifies the default library search path # to first include a 64-bit specific directory. It's put # in slightly different places on the two systems. # Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first -# on Linux and /lib/sparcv9, /usr/lib/sparcv9 etc. on Solaris. +# on Linux. case "$EMULATION_NAME" in *64*) case "$target" in sparc*-linux*) LIBPATH_SUFFIX=64 ;; - sparc*-solaris*) - LIBPATH_SUFFIX=/sparcv9 ;; esac ;; esac diff --git a/ld/emulparams/elf64_sparc_sol2.sh b/ld/emulparams/elf64_sparc_sol2.sh index e17f7873e64..e227b7e9b7e 100644 --- a/ld/emulparams/elf64_sparc_sol2.sh +++ b/ld/emulparams/elf64_sparc_sol2.sh @@ -3,3 +3,6 @@ source_sh ${srcdir}/emulparams/solaris2.sh TEXT_START_ADDR=0x100000000 EXTRA_EM_FILE=solaris2 OUTPUT_FORMAT="elf64-sparc-sol2" +LIBPATH_SUFFIX=/sparcv9 +LIBPATH_SKIP_NONNATIVE=yes +ELF_INTERPRETER_NAME=\"/usr/lib/sparcv9/ld.so.1\" diff --git a/ld/emulparams/elf_i386_ldso.sh b/ld/emulparams/elf_i386_ldso.sh deleted file mode 100644 index 081de5f8e71..00000000000 --- a/ld/emulparams/elf_i386_ldso.sh +++ /dev/null @@ -1,17 +0,0 @@ -source_sh ${srcdir}/emulparams/plt_unwind.sh -source_sh ${srcdir}/emulparams/extern_protected_data.sh -source_sh ${srcdir}/emulparams/dynamic_undefined_weak.sh -source_sh ${srcdir}/emulparams/call_nop.sh -SCRIPT_NAME=elf -OUTPUT_FORMAT="elf32-i386" -EXTRA_EM_FILE="elf-x86" -NO_RELA_RELOCS=yes -TEXT_START_ADDR=0x08048000 -MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" -COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" -ARCH=i386 -MACHINE= -TEMPLATE_NAME=elf -GENERATE_SHLIB_SCRIPT=yes -ELF_INTERPRETER_NAME=\"/usr/lib/ld.so.1\" -NO_SMALL_DATA=yes diff --git a/ld/emulparams/elf_i386_sol2.sh b/ld/emulparams/elf_i386_sol2.sh index 5e63ca8b3ac..f1a75366921 100644 --- a/ld/emulparams/elf_i386_sol2.sh +++ b/ld/emulparams/elf_i386_sol2.sh @@ -1,4 +1,5 @@ -source_sh ${srcdir}/emulparams/elf_i386_ldso.sh +source_sh ${srcdir}/emulparams/elf_i386.sh source_sh ${srcdir}/emulparams/solaris2.sh EXTRA_EM_FILE="solaris2-x86" OUTPUT_FORMAT="elf32-i386-sol2" +ELF_INTERPRETER_NAME=\"/usr/lib/ld.so.1\" diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh index 4bab1489b94..fb4fcd6ae17 100644 --- a/ld/emulparams/elf_x86_64.sh +++ b/ld/emulparams/elf_x86_64.sh @@ -44,8 +44,8 @@ if [ "x${host}" = "x${target}" ]; then esac fi -# Linux/Solaris modify the default library search path to first include -# a 64-bit specific directory. +# Linux modifies the default library search path to first include a 64-bit +# specific directory. case "$target" in x86_64*-linux*|i[3-7]86-*-linux-*) case "$EMULATION_NAME" in @@ -54,8 +54,4 @@ case "$target" in ;; esac ;; - *-*-solaris2*) - LIBPATH_SUFFIX=/amd64 - ELF_INTERPRETER_NAME=\"/lib/amd64/ld.so.1\" - ;; esac diff --git a/ld/emulparams/elf_x86_64_sol2.sh b/ld/emulparams/elf_x86_64_sol2.sh index d1d3cc70473..115fdf7ebf6 100644 --- a/ld/emulparams/elf_x86_64_sol2.sh +++ b/ld/emulparams/elf_x86_64_sol2.sh @@ -2,3 +2,6 @@ source_sh ${srcdir}/emulparams/elf_x86_64.sh source_sh ${srcdir}/emulparams/solaris2.sh EXTRA_EM_FILE="solaris2-x86-64" OUTPUT_FORMAT="elf64-x86-64-sol2" +LIBPATH_SUFFIX=/amd64 +LIBPATH_SKIP_NONNATIVE=yes +ELF_INTERPRETER_NAME=\"/usr/lib/amd64/ld.so.1\" diff --git a/ld/emulparams/solaris2.sh b/ld/emulparams/solaris2.sh index aa976f8184a..2939dfef107 100644 --- a/ld/emulparams/solaris2.sh +++ b/ld/emulparams/solaris2.sh @@ -8,5 +8,5 @@ # File, p.63. TEXT_START_SYMBOLS='_START_ = .;' OTHER_END_SYMBOLS='_END_ = .;' -# Beginning with Solaris 11.x and Solaris 12, there's PIE support. +# Beginning with Solaris 11.2, there's PIE support. GENERATE_PIE_SCRIPT=yes diff --git a/ld/genscripts.sh b/ld/genscripts.sh index 77a1fb465ad..b1f29c59a60 100755 --- a/ld/genscripts.sh +++ b/ld/genscripts.sh @@ -185,7 +185,7 @@ fi # Otherwise, the default is set here. # # The format is the usual list of colon-separated directories. -# To force a logically empty LIB_PATH, do LIBPATH=":". +# To force a logically empty LIB_PATH, do LIB_PATH=":". # # If we are using a sysroot, prefix library paths with "=" to indicate this. # @@ -233,7 +233,8 @@ append_to_lib_path() fi ;; esac done - if test "${skip_lib}" = "no"; then + + if test "${skip_lib}" = "no" && test "${LIBPATH_SKIP_NONNATIVE}" != "yes"; then case :${lib_path1}:${lib_path2}: in *:${lib}:*) ;; *::) lib_path2=${lib} ;; @@ -245,7 +246,7 @@ append_to_lib_path() } # Always search $(tooldir)/lib, aka /usr/local/TARGET/lib when native -# except when LIBPATH=":". +# except when LIB_PATH=":". if [ "${LIB_PATH}" != ":" ] ; then libs= if [ "x${TOOL_LIB}" = "x" ] ; then