[binutils-gdb] gas: Default to -mrelax-relocations=no on Solaris/x86 [PR19520]
Rainer Orth
ro@sourceware.org
Thu Nov 6 16:18:46 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=70abf8984bdea3b67cf64bdceb94c2055bb8f4d7
commit 70abf8984bdea3b67cf64bdceb94c2055bb8f4d7
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date: Thu Nov 6 17:18:16 2025 +0100
gas: Default to -mrelax-relocations=no on Solaris/x86 [PR19520]
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.
Diff:
---
gas/config.in | 3 ---
gas/config/tc-i386.c | 9 ++++++++
gas/configure | 38 ++------------------------------
gas/configure.ac | 29 ------------------------
gas/doc/c-i386.texi | 3 +--
gas/testsuite/gas/i386/gotx-default.d | 11 +++++++++
gas/testsuite/gas/i386/gotx.s | 4 ++++
gas/testsuite/gas/i386/i386.exp | 3 +++
gas/testsuite/gas/i386/no-gotx-default.d | 12 ++++++++++
9 files changed, 42 insertions(+), 70 deletions(-)
diff --git a/gas/config.in b/gas/config.in
index d6ce237ec90..1bfbee9a348 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -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
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 615824026c8..44c8ae3a25b 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -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;
diff --git a/gas/configure b/gas/configure
index 104fdb109dd..33d199db363 100755
--- a/gas/configure
+++ b/gas/configure
@@ -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
diff --git a/gas/configure.ac b/gas/configure.ac
index 4c7df3d8491..61ed65fcf8b 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -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
diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi
index 6598a04e6ef..b03ac64a78a 100644
--- a/gas/doc/c-i386.texi
+++ b/gas/doc/c-i386.texi
@@ -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
index 00000000000..8fb7ad746ad
--- /dev/null
+++ b/gas/testsuite/gas/i386/gotx-default.d
@@ -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
index 00000000000..d0bdae0028b
--- /dev/null
+++ b/gas/testsuite/gas/i386/gotx.s
@@ -0,0 +1,4 @@
+ .text
+ .global _start
+_start:
+ jmp *_start@GOT(%ebx)
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 1baa6b96942..9b23a7b671d 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -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
index 00000000000..ffeb2a96cf2
--- /dev/null
+++ b/gas/testsuite/gas/i386/no-gotx-default.d
@@ -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
More information about the Binutils-cvs
mailing list