diff options
author | Alan Modra <amodra@gmail.com> | 2018-11-29 15:23:49 +1030 |
---|---|---|
committer | Alan Modra <amodra@gcc.gnu.org> | 2018-11-29 15:23:49 +1030 |
commit | 3f79c0ad268bc64d0cc231ba6d51098983bdb67b (patch) | |
tree | 668438f0c9105e410904a6b0788446c72d448890 /gcc/configure | |
parent | ece3bca2bd08bd02028f9ac6b0a2b6b8fa111305 (diff) |
[RS6000] inline plt call sequences
Finally, the point of the previous patches in this series, support for
inline PLT calls, keyed off -fno-plt. This emits code using new
relocations that tie all insns in the sequence together, so that the
linker can edit the sequence back to a direct call should the call
target turn out to be local. An example of ELFv2 code to call puts is
as follows:
.reloc .,R_PPC64_PLTSEQ,puts
std 2,24(1)
.reloc .,R_PPC64_PLT16_HA,puts
addis 12,2,0
.reloc .,R_PPC64_PLT16_LO_DS,puts
ld 12,0(12)
.reloc .,R_PPC64_PLTSEQ,puts
mtctr 12
.reloc .,R_PPC64_PLTCALL,puts
bctrl
ld 2,24(1)
"addis 12,2,puts@plt@ha" and "ld 12,puts@plt@l(12)" are also supported
by the assembler. gcc instead uses the explicit R_PPC64_PLT16_HA and
R_PPC64_PLT16_LO_DS relocs because when the call is to __tls_get_addr
an extra reloc is emitted at every place where one is shown above, to
specify the __tls_get_addr arg. The linker expects the extra reloc to
come first. .reloc enforces that ordering.
The patch also changes code emitted for longcalls if the assembler
supports the new marker relocs, so that these too can be edited. One
side effect of longcalls using PLT16 relocs is that they can now be
resolved lazily by ld.so.
I don't support lazy inline PLT calls for ELFv1, because ELFv1 would
need barriers to reliably load both the function address and toc
pointer from the PLT. ELFv1 -fno-plt uses the longcall sequence
instead, which isn't edited by GNU ld.
* config.in (HAVE_AS_PLTSEQ): Add.
* config/rs6000/predicates.md (indirect_call_operand): New.
* config/rs6000/rs6000-protos.h (rs6000_pltseq_template),
(rs6000_sibcall_sysv): Declare.
* config/rs6000/rs6000.c (init_cumulative_args): Set cookie
CALL_LONG for -fno-plt.
(print_operand <T, z, 0>): Handle UNSPEC_PLTSEQ.
(rs6000_indirect_call_template_1): Emit .reloc directives for
UNSPEC_PLTSEQ calls.
(rs6000_pltseq_template): New function.
(rs6000_longcall_ref): Add arg parameter. Use PLT16 insns if
relocs supported by assembler. Move SYMBOL_REF test to callers.
(rs6000_call_aix): Adjust rs6000_longcall_ref call. Package
insns in UNSPEC_PLTSEQ, preserving original func_desc.
(rs6000_call_sysv): Likewise.
(rs6000_sibcall_sysv): New function.
* config/rs6000/rs6000.h (HAVE_AS_PLTSEQ): Provide default.
* config/rs6000/rs6000.md (UNSPEC_PLTSEQ, UNSPEC_PLT16_HA,
UNSPEC_PLT16_LO): New.
(pltseq_tocsave, pltseq_plt16_ha, pltseq_plt16_lo, pltseq_mtctr): New.
(call_indirect_nonlocal_sysv): Don't differentiate zero from non-zero
cookie in constraints. Test explicitly for flags in length attr.
Handle unspec operand 1.
(call_value_indirect_nonlocal_sysv): Likewise.
(call_indirect_aix, call_value_indirect_aix): Handle unspec operand 1.
(call_indirect_elfv2, call_value_indirect_elfv2): Likewise.
(sibcall, sibcall_value): Use rs6000_sibcall_sysv.
(sibcall_indirect_nonlocal_sysv): New pattern.
(sibcall_value_indirect_nonlocal_sysv): Likewise.
(sibcall_nonlocal_sysv, sibcall_value_nonlocal_sysv): Remove indirect
call alternatives.
* configure.ac: Check for gas plt sequence marker support.
* configure: Regenerate.
From-SVN: r266605
Diffstat (limited to 'gcc/configure')
-rwxr-xr-x | gcc/configure | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/gcc/configure b/gcc/configure index 3a20399adba..bdaa6fa0c3e 100755 --- a/gcc/configure +++ b/gcc/configure @@ -24393,12 +24393,12 @@ foo: .long 25 ;; or1k*-*-*) conftest_s=' - .section ".tdata","awT",@progbits -foo: .long 25 - .text - l.movhi r3, tpoffha(foo) - l.add r3, r3, r10 - l.lwz r4, tpofflo(foo)(r3)' + .section ".tdata","awT",@progbits +foo: .long 25 + .text + l.movhi r3, tpoffha(foo) + l.add r3, r3, r10 + l.lwz r4, tpofflo(foo)(r3)' tls_first_major=2 tls_first_minor=30 tls_as_opt=--fatal-warnings @@ -26942,6 +26942,42 @@ $as_echo "#define HAVE_AS_ENTRY_MARKERS 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for plt sequence marker support" >&5 +$as_echo_n "checking assembler for plt sequence marker support... " >&6; } +if ${gcc_cv_as_powerpc_pltseq_markers+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_powerpc_pltseq_markers=no + if test $in_tree_gas = yes; then + if test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 31 \) \* 1000 + 0` + then gcc_cv_as_powerpc_pltseq_markers=yes +fi + elif test x$gcc_cv_as != x; then + $as_echo ' .reloc .,R_PPC_PLTSEQ; nop' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -a32 --fatal-warnings -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 + gcc_cv_as_powerpc_pltseq_markers=yes + 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_powerpc_pltseq_markers" >&5 +$as_echo "$gcc_cv_as_powerpc_pltseq_markers" >&6; } +if test $gcc_cv_as_powerpc_pltseq_markers = yes; then + +$as_echo "#define HAVE_AS_PLTSEQ 1" >>confdefs.h + +fi + + case $target in *-*-aix*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for AIX .ref support" >&5 |