]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: Default to -mrelax-relocations=no on Solaris/x86 [PR19520]
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 6 Nov 2025 16:18:16 +0000 (17:18 +0100)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 6 Nov 2025 16:18:16 +0000 (17:18 +0100)
I recently noticed a complex case statement in gas/configure.ac controlling
the setting of ac_default_x86_relax_relocations on Solaris/x86.  Since it
included all versions of Solaris, it could be massively simplified.

Looking closer however, I found that it was introduced in

commit 0cb4071ef9e10f703220f5e731141bf438aca16e
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Feb 3 08:25:15 2016 -0800

    Add -mrelax-relocations= to x86 assembler

based on PR gas/19520.  This PR reported that the new R_386_GOT32X
etc. relocations weren't supported on older versions of Solaris,
breaking gcc bootstrap.  In response, they were disabled on all Solaris
versions except Solaris 12, where they had been implemented in the
native toolchain based on my findings.

However, Solaris 12 has been rechristened to 11.4 before release,
effectively disabling DEFAULT_GENERATE_X86_RELAX_RELOCATIONS on all
versions of Solaris/x86.

Since Solaris 11.4 cannot be distinguished from earlier versions in
cross configurations, this patch fixes this by removing
--enable-x86-relax-relocations completely, instead disabling
DEFAULT_GENERATE_X86_RELAX_RELOCATIONS in tc-i386.c on Solaris.  It also
adds testcases to verify the -mrelax-relocations default.

Tested on {i386,amd64}-pc-solaris2.11 and {i686,x86_64}-pc-linux-gnu.

2025-10-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gas:
PR gas/19520
* configure.ac (ac_default_x86_relax_relocations): Remove.
<i386-*-solaris2* | x86_64-*-solaris2>: Likewise.
* configure: Regenerate.
* config.in: Regenerate.
* config/tc-i386.c (DEFAULT_GENERATE_X86_RELAX_RELOCATIONS): Define.
* doc/c-i386.texi (i386-Options, -mrelax-relocations): Remove
--enable-x86-relax-relocations reference.
* testsuite/gas/i386/gotx.s: New source.
* testsuite/gas/i386/gotx-default.d: New test.
* testsuite/gas/i386/no-gotx-default.d: Likewise.
* testsuite/gas/i386/i386.exp: Run them.

gas/config.in
gas/config/tc-i386.c
gas/configure
gas/configure.ac
gas/doc/c-i386.texi
gas/testsuite/gas/i386/gotx-default.d [new file with mode: 0644]
gas/testsuite/gas/i386/gotx.s [new file with mode: 0644]
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/no-gotx-default.d [new file with mode: 0644]

index d6ce237ec90f5f2382c900d5e0ff754bb9a5892f..1bfbee9a348e0182ba6ee642a213e2a9e884fdf8 100644 (file)
@@ -42,9 +42,6 @@
    type by default. */
 #undef DEFAULT_GENERATE_ELF_STT_COMMON
 
-/* Define to 1 if you want to generate x86 relax relocations by default. */
-#undef DEFAULT_GENERATE_X86_RELAX_RELOCATIONS
-
 /* Define to 1 if you want to fix Loongson3 LLSC Errata by default. */
 #undef DEFAULT_MIPS_FIX_LOONGSON3_LLSC
 
index 615824026c86a238f75d2fd6ff3f7d699941ef60..44c8ae3a25b0b02d440b3463a308035c92a20182 100644 (file)
@@ -750,6 +750,15 @@ lfence_before_ret;
 
 /* 1 if the assembler should generate relax relocations.  */
 
+#ifdef TE_SOLARIS
+/* PR gas/19520: The Solaris/x86 linker cannot handle relax relocations
+   before Solaris 11.4 which cannot easily be detected in cross
+   configurations.  */
+#define DEFAULT_GENERATE_X86_RELAX_RELOCATIONS 0
+#else
+#define DEFAULT_GENERATE_X86_RELAX_RELOCATIONS 1
+#endif
+
 static int generate_relax_relocations
   = DEFAULT_GENERATE_X86_RELAX_RELOCATIONS;
 
index 104fdb109ddad95834e512e98665f9f6b495b082..33d199db363071350ad6290e68b76c28ba096600 100755 (executable)
@@ -818,7 +818,6 @@ enable_targets
 enable_checking
 enable_compressed_debug_sections
 enable_default_compressed_debug_sections_algorithm
-enable_x86_relax_relocations
 enable_x86_tls_check
 enable_elf_stt_common
 enable_default_sframe
@@ -1494,8 +1493,6 @@ Optional Features:
   --enable-default-compressed-debug-sections-algorithm={zlib,zstd}
                           Default compression algorithm for
                           --enable-compressed-debug-sections.
-  --enable-x86-relax-relocations
-                          generate x86 relax relocations by default
   --enable-x86-tls-check  check x86 TLS relocation by default
   --enable-elf-stt-common generate ELF common symbols with STT_COMMON type by
                           default
@@ -11153,7 +11150,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11156 "configure"
+#line 11153 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11259,7 +11256,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11262 "configure"
+#line 11259 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11942,17 +11939,6 @@ if test "${enable_default_compressed_debug_sections_algorithm+set}" = set; then
 esac
 fi
 
-# PR gas/19520
-# Decide if x86 assembler should generate relax relocations.
-ac_default_x86_relax_relocations=unset
-# Provide a configure time option to override our default.
-# Check whether --enable-x86_relax_relocations was given.
-if test "${enable_x86_relax_relocations+set}" = set; then :
-  enableval=$enable_x86_relax_relocations; case "${enableval}" in
-  no)  ac_default_x86_relax_relocations=0 ;;
-esac
-fi
-
 # PR gas/32022
 # Decide if x86 assembler should check TLS relocation.
 ac_default_x86_tls_check=unset
@@ -12540,17 +12526,6 @@ $as_echo "#define STRICTCOFF 1" >>confdefs.h
        fi
        ;;
 
-      i386-*-solaris2 \
-      | x86_64-*-solaris2 \
-      | i386-*-solaris2.[0-9] \
-      | i386-*-solaris2.1[01] \
-      | x86_64-*-solaris2.1[01])
-       if test ${this_target} = $target \
-          && test ${ac_default_x86_relax_relocations} = unset; then
-         ac_default_x86_relax_relocations=0
-       fi
-       ;;
-
       microblaze*)
         ;;
 
@@ -13071,15 +13046,6 @@ $as_echo "$with_priv_spec" >&6; }
 
 done
 
-if test ${ac_default_x86_relax_relocations} = unset; then
-  ac_default_x86_relax_relocations=1
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define DEFAULT_GENERATE_X86_RELAX_RELOCATIONS $ac_default_x86_relax_relocations
-_ACEOF
-
-
 if test ${ac_default_x86_tls_check} = unset; then
   ac_default_x86_tls_check=1
 fi
index 4c7df3d8491c2ae5424d152aa7402720778f7fa9..61ed65fcf8bef79bde617691b99ead9ad0a1bd9b 100644 (file)
@@ -84,17 +84,6 @@ AC_ARG_ENABLE(default_compressed_debug_sections_algorithm,
    zstd) ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_ZSTD ;;
 esac])dnl
 
-# PR gas/19520
-# Decide if x86 assembler should generate relax relocations.
-ac_default_x86_relax_relocations=unset
-# Provide a configure time option to override our default.
-AC_ARG_ENABLE(x86_relax_relocations,
-             AS_HELP_STRING([--enable-x86-relax-relocations],
-             [generate x86 relax relocations by default]),
-[case "${enableval}" in
-  no)  ac_default_x86_relax_relocations=0 ;;
-esac])dnl
-
 # PR gas/32022
 # Decide if x86 assembler should check TLS relocation.
 ac_default_x86_tls_check=unset
@@ -276,17 +265,6 @@ for this_target in $target $canon_targets ; do
        fi
        ;;
 
-      i386-*-solaris2 \
-      | x86_64-*-solaris2 \
-      | i386-*-solaris2.[[0-9]] \
-      | i386-*-solaris2.1[[01]] \
-      | x86_64-*-solaris2.1[[01]])
-       if test ${this_target} = $target \
-          && test ${ac_default_x86_relax_relocations} = unset; then
-         ac_default_x86_relax_relocations=0
-       fi
-       ;;
-
       microblaze*)
         ;;
 
@@ -735,13 +713,6 @@ changequote([,])dnl
 
 done
 
-if test ${ac_default_x86_relax_relocations} = unset; then
-  ac_default_x86_relax_relocations=1
-fi
-AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_X86_RELAX_RELOCATIONS,
-  $ac_default_x86_relax_relocations,
-  [Define to 1 if you want to generate x86 relax relocations by default.])
-
 if test ${ac_default_x86_tls_check} = unset; then
   ac_default_x86_tls_check=1
 fi
index 6598a04e6ef97a6683a921e1ce633f542e4311e7..b03ac64a78ad50e2adf744358b85b2f9952c8100 100644 (file)
@@ -478,8 +478,7 @@ relocations, R_386_GOT32X, in 32-bit mode, or R_X86_64_GOTPCRELX and
 R_X86_64_REX_GOTPCRELX, in 64-bit mode.
 @option{-mrelax-relocations=@var{yes}} will generate relax relocations.
 @option{-mrelax-relocations=@var{no}} will not generate relax
-relocations.  The default can be controlled by a configure option
-@option{--enable-x86-relax-relocations}.
+relocations.
 
 @cindex @samp{-mtls-check=} option, i386
 @cindex @samp{-mtls-check=} option, x86-64
diff --git a/gas/testsuite/gas/i386/gotx-default.d b/gas/testsuite/gas/i386/gotx-default.d
new file mode 100644 (file)
index 0000000..8fb7ad7
--- /dev/null
@@ -0,0 +1,11 @@
+#source: gotx.s
+#objdump: -dwr
+#xfail: *-*-solaris*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <_start>:
+[      ]*[a-f0-9]+:    ff a3 00 00 00 00       jmp    \*0x0\(%ebx\)    2: R_386_GOT32X _start
diff --git a/gas/testsuite/gas/i386/gotx.s b/gas/testsuite/gas/i386/gotx.s
new file mode 100644 (file)
index 0000000..d0bdae0
--- /dev/null
@@ -0,0 +1,4 @@
+       .text
+       .global _start
+_start:
+       jmp *_start@GOT(%ebx)
index 1baa6b96942a985e297115bc02189150b58de2eb..9b23a7b671dc3f276583d418bd96133f50b27947 100644 (file)
@@ -777,6 +777,9 @@ if [gas_32_check] then {
 
        run_dump_test "no-got"
 
+       run_dump_test "gotx-default"
+       run_dump_test "no-gotx-default"
+
        run_dump_test "addend"
        run_dump_test "nop-3"
        run_dump_test "nop-4"
diff --git a/gas/testsuite/gas/i386/no-gotx-default.d b/gas/testsuite/gas/i386/no-gotx-default.d
new file mode 100644 (file)
index 0000000..ffeb2a9
--- /dev/null
@@ -0,0 +1,12 @@
+#source: gotx.s
+#objdump: -dwr
+#xfail: *-*-*
+#noxfail: *-*-solaris*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <_start>:
+[      ]*[a-f0-9]+:    ff a3 00 00 00 00       jmp    \*0x0\(%ebx\)    2: R_386_GOT32  _start