aboutsummaryrefslogtreecommitdiff
path: root/gcc/configure
diff options
context:
space:
mode:
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-23 16:30:43 +0000
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-23 16:30:43 +0000
commit6fb2f18178a7a2d8d7a166e8d418cddc7f0d5430 (patch)
treeb69135bb367453ba3dfca8641a5f27c9cdc26160 /gcc/configure
parent88be2b3c486cb31e026fe212db72e7765d278597 (diff)
i386: Access external function via GOT slot for -fno-plt
i386 psABI has been updated to clarify that R_386_GOT32X and R_386_GOT32 relocations can be used to access GOT without base register when PIC is disabled: https://groups.google.com/forum/#!topic/ia32-abi/awsRSvJOJfs 32-bit x86 assembler and linker from binutils 2.26.1 and 2.27 support call/jmp *_start@GOT cmpl $0, bar@GOT for both normal and IFUNC functions. We check if 32-bit x86 assembler and linker have the fix for: https://sourceware.org/bugzilla/show_bug.cgi?id=20244 before accessing external function via GOT slot for -fno-plt in both PIC and non-PIC modes. PR target/66232 PR target/67400 * configure.ac (as_ix86_tls_ldm_opt): Renamed to ... (as_ix86_gas_32_opt): This. (ld_ix86_tls_ldm_opt): Renamed to ... (ld_ix86_gld_32_opt): This. (R_386_TLS_LDM reloc): Updated. (R_386_GOT32X reloc): New assembler/linker check. (HAVE_AS_IX86_GOT32X): New. Defined to 1 if 32-bit assembler and linker support "jmp *_start@GOT" and "cmpl $0, bar@GOT". Otherise, defined to 0. * config.in: Regenerated. * configure: Likewise. * config/i386/i386.c (ix86_force_load_from_GOT_p): Return true if HAVE_AS_IX86_GOT32X is 1 in 32-bit mode. (ix86_legitimate_address_p): Allow UNSPEC_GOT for -fno-plt if ix86_force_load_from_GOT_p returns true. (ix86_print_operand_address_as): Also support UNSPEC_GOT if ix86_force_load_from_GOT_p returns true. (ix86_expand_move): Generate UNSPEC_GOT in 32-bit mode to load the external function address via the GOT slot. (ix86_nopic_noplt_attribute_p): Check both TARGET_64BIT and HAVE_AS_IX86_GOT32X before returning false. (ix86_output_call_insn): Generate "%!jmp/call\t*%p0@GOT" in 32-bit mode if ix86_nopic_noplt_attribute_p returns true. gcc/testsuite/ PR target/66232 PR target/67400 * gcc.target/i386/pr66232-14.c: New file. * gcc.target/i386/pr66232-15.c: Likewise. * gcc.target/i386/pr66232-16.c: Likewise. * gcc.target/i386/pr66232-17.c: Likewise. * gcc.target/i386/pr67400-1.c: Don't disable for ia32. Scan for ia32 if R_386_GOT32X relocation is supported. * gcc.target/i386/pr67400-2.c: Likewise. * gcc.target/i386/pr67400-3.c: Likewise. * gcc.target/i386/pr67400-4.c: Likewise. * gcc.target/i386/pr67400-6.c: Likewise. * gcc.target/i386/pr67400-7.c: Likewise. * lib/target-supports.exp (check_effective_target_got32x_reloc): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237736 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/configure')
-rwxr-xr-xgcc/configure62
1 files changed, 57 insertions, 5 deletions
diff --git a/gcc/configure b/gcc/configure
index bfd2b8c64f5..800ab269e24 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -25899,13 +25899,13 @@ _ACEOF
# Enforce 32-bit output with gas and gld.
if test x$gas = xyes; then
- as_ix86_tls_ldm_opt="--32"
+ as_ix86_gas_opt="--32"
fi
if echo "$ld_ver" | grep GNU > /dev/null; then
if $gcc_cv_ld -V 2>/dev/null | grep elf_i386_sol2 > /dev/null; then
- ld_ix86_tls_ldm_opt="-melf_i386_sol2"
+ ld_ix86_gld_opt="-melf_i386_sol2"
else
- ld_ix86_tls_ldm_opt="-melf_i386"
+ ld_ix86_gld_opt="-melf_i386"
fi
fi
conftest_s='
@@ -25927,7 +25927,7 @@ else
gcc_cv_as_ix86_tlsldm=no
if test x$gcc_cv_as != x; then
$as_echo "$conftest_s" > conftest.s
- if { ac_try='$gcc_cv_as $gcc_cv_as_flags $as_ix86_tls_ldm_opt -o conftest.o conftest.s >&5'
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags $as_ix86_gas_opt -o conftest.o conftest.s >&5'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
@@ -25935,7 +25935,7 @@ else
test $ac_status = 0; }; }
then
if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
- && $gcc_cv_ld $ld_ix86_tls_ldm_opt -o conftest conftest.o $ld_tls_libs -lc > /dev/null 2>&1; then
+ && $gcc_cv_ld $ld_ix86_gld_opt -o conftest conftest.o $ld_tls_libs -lc > /dev/null 2>&1; then
if $gcc_cv_objdump -d conftest 2>/dev/null | grep nop > /dev/null \
|| dis conftest 2>/dev/null | grep nop > /dev/null; then
gcc_cv_as_ix86_tlsldm=yes
@@ -25958,6 +25958,58 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
+ conftest_s='
+ .data
+bar:
+ .byte 1
+ .text
+ .global _start
+_start:
+ cmpl $0, bar@GOT
+ jmp *_start@GOT'
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for R_386_GOT32X reloc" >&5
+$as_echo_n "checking assembler for R_386_GOT32X reloc... " >&6; }
+if test "${gcc_cv_as_ix86_got32x+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_ix86_got32x=no
+ if test x$gcc_cv_as != x; then
+ $as_echo "$conftest_s" > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags $as_ix86_gas_opt -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
+ && test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf --relocs --wide conftest.o 2>&1 \
+ | grep R_386_GOT32X > /dev/null 2>&1 \
+ && $gcc_cv_ld $ld_ix86_gld_opt -o conftest conftest.o > /dev/null 2>&1; then
+ if $gcc_cv_objdump -dw conftest 2>&1 \
+ | grep 0xffffff > /dev/null 2>&1; then
+ gcc_cv_as_ix86_got32x=no
+ else
+ gcc_cv_as_ix86_got32x=yes
+ fi
+ fi
+ rm -f conftest
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_ix86_got32x" >&5
+$as_echo "$gcc_cv_as_ix86_got32x" >&6; }
+
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_AS_IX86_GOT32X `if test x"$gcc_cv_as_ix86_got32x" = xyes; then echo 1; else echo 0; fi`
+_ACEOF
+
;;
ia64*-*-*)