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.
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
/* 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;
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
--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
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
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
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
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*)
;;
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
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
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*)
;;
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
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
--- /dev/null
+#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
--- /dev/null
+ .text
+ .global _start
+_start:
+ jmp *_start@GOT(%ebx)
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"
--- /dev/null
+#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