]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Cleanup bfd target vectors and ld emulations on Solaris
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 11 Dec 2025 13:43:16 +0000 (14:43 +0100)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 11 Dec 2025 13:43:16 +0000 (14:43 +0100)
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  <ro@CeBiTec.Uni-Bielefeld.DE>

bfd:
* config.bfd <i[3-7]86-*-solaris2*>: Split into ...
<i[3-7]86-*-solaris2.1[01]*> ... this.
(targ_selvecs): Remove iamcu_elf32_vec, i386_coff_vec, i386_pei_vec.
(targ64_selvecs): Remove x86_64_pe_vec, x86_64_pei_vec.
<i[3-7]86-*-solaris2.[0-9]*>: ... and this.
[BFD64] <x86_64-*-solaris2*>: 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.
<sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*>: Split into ...
<sparc-*-solaris2.[7-9]* | sparc-*-solaris2.1[01]*>: ... this.
<sparc-*-solaris2.[0-6]*>: ... this.
[BFD64] <sparc-*-solaris2* | sparcv9-*-solaris2* |
sparc64-*-solaris2*>: Omit sparc-*-solaris2*.
(targ_defvec): Swap with targ_selvecs.

* testsuite/gas/i386/i386.exp: Disable iamcu tests on Solaris.

ld:
* configure.tgt <i[3-7]86-*-solaris2>: Split into ...
<i[3-7]86-*-solaris2.1[01]*>: .. this.
(targ_extra_emuls): Remove elf_i386_ldso and elf_iamcu.
<i[3-7]86-*-solaris2.[0-9]*>: ... and this.
<sparc64-*-solaris2*, sparcv9-*-solaris2*>: Change into ...
<sparc64-*-solaris2.[7-9]* | sparc64-*-solaris2.1[01]* |
sparcv9-*-solaris2.[7-9]* | sparcv9-*-solaris2.1[01]*>: ... this
(targ_extra_emuls): Reorder.
(tdir_elf32_sparc): Remove.
<sparc-*-solaris2.[7-9]* | sparc-*-solaris2.1[01]*>: New case.
<sparc-*-solaris2.[0-6]*, sparc-*-solaris2.[0-6].*>: Change into ...
<sparc-*-solaris2.[0-6]*>: ... this.
<sparc-*-solaris2*>: Remove.
<x86_64-*-solaris2*>: Change into ...
<x86_64-*-solaris2.1[01]*>: ... 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 <sparc*-solaris*> (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.

12 files changed:
bfd/config.bfd
gas/testsuite/gas/i386/i386.exp
ld/configure.tgt
ld/emulparams/elf32_sparc_sol2.sh
ld/emulparams/elf64_sparc.sh
ld/emulparams/elf64_sparc_sol2.sh
ld/emulparams/elf_i386_ldso.sh [deleted file]
ld/emulparams/elf_i386_sol2.sh
ld/emulparams/elf_x86_64.sh
ld/emulparams/elf_x86_64_sol2.sh
ld/emulparams/solaris2.sh
ld/genscripts.sh

index 4a0b7886acc9aae1fecee709d773baeea15f4451..bf6ea9f71e09fa78d98a639f26310cc70a96404f 100644 (file)
@@ -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*)
index 08f3e3c1e3c709451f1fae7fc1289870f5f05e30..58c6d634c73d5d4ecd301f10a28561be5bf270c9 100644 (file)
@@ -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"
index df31897f6d46e25c8ef5e2839d7ad2cf2d2995c4..31fa2d8aded95dcbe9ccd8752118fbfd42b9acbb 100644 (file)
@@ -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'
index 07c8430814dc92777b599cf26e16aacebf937144..e5c9f9a661848fd1463f55587d6c3af85c045a96 100644 (file)
@@ -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\"
index afbf2e6a475ab85a7dbfc48e3df46700bc8531bc..9409b786942a83504fabc0f083fd068ff82ac1c9 100644 (file)
@@ -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
index e17f7873e6474876107bc4c2c09899e7bd435e30..e227b7e9b7e112f54537f1856844e39b0723576e 100644 (file)
@@ -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 (file)
index 081de5f..0000000
+++ /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
index 5e63ca8b3ac84fabbaef2ba19f8728d0b4462374..f1a75366921e026c881527c7ec3e8f49148c14b5 100644 (file)
@@ -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\"
index 4bab1489b94f5abd2f8ba36174ada4e628a7b3e4..fb4fcd6ae1740531aa181e5c5e28c4e4b95b3e37 100644 (file)
@@ -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
index d1d3cc7047352cb7b99e32329fa678099ee5760a..115fdf7ebf6c5dfedd30faf55a309a244c27532e 100644 (file)
@@ -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\"
index aa976f8184a7e340cd2506ebf75ffa07439fc096..2939dfef1070aba60d25b0831bf72148a0f08af8 100644 (file)
@@ -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
index 77a1fb465ad3320afadf2d2dfbd744b3e166bb4e..b1f29c59a60f6f75a93a3403fe3b5be1a3929fca 100755 (executable)
@@ -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