aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2015-05-11 16:20:57 +0300
committerAlexander Monakov <amonakov@gcc.gnu.org>2015-05-11 16:20:57 +0300
commitb91fd3c76ac503f11d94ff00fd9399e949735148 (patch)
tree532861d0edff899e1bd9fe5d71d6a207bb11a98a /gcc
parent9e4b3dd6bcbbd4cac2d461cef58fc912de8c33cd (diff)
downloadgcc-b91fd3c76ac503f11d94ff00fd9399e949735148.zip
gcc-b91fd3c76ac503f11d94ff00fd9399e949735148.tar.gz
gcc-b91fd3c76ac503f11d94ff00fd9399e949735148.tar.bz2
calls.c (prepare_call_address): Transform PLT call to GOT lookup and indirect call by forcing address into a...
* calls.c (prepare_call_address): Transform PLT call to GOT lookup and indirect call by forcing address into a pseudo with -fno-plt. * common.opt (flag_plt): New option. * doc/invoke.texi (Code Generation Options): Add -fno-plt. ([-fno-plt]): Document. From-SVN: r223003
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/calls.c6
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/doc/invoke.texi12
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 534f6dd..38f929b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2015-05-11 Alexander Monakov <amonakov@ispras.ru>
+
+ * calls.c (prepare_call_address): Transform PLT call to GOT lookup and
+ indirect call by forcing address into a pseudo with -fno-plt.
+ * common.opt (flag_plt): New option.
+ * doc/invoke.texi (Code Generation Options): Add -fno-plt.
+ ([-fno-plt]): Document.
+
2015-05-11 Markus Trippelsdorf <markus@trippelsdorf.de>
PR bootstrap/66105
diff --git a/gcc/calls.c b/gcc/calls.c
index aaac1ad..51b896e 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -225,6 +225,12 @@ prepare_call_address (tree fndecl_or_type, rtx funexp, rtx static_chain_value,
&& targetm.small_register_classes_for_mode_p (FUNCTION_MODE))
? force_not_mem (memory_address (FUNCTION_MODE, funexp))
: memory_address (FUNCTION_MODE, funexp));
+ else if (flag_pic && !flag_plt && fndecl_or_type
+ && TREE_CODE (fndecl_or_type) == FUNCTION_DECL
+ && !targetm.binds_local_p (fndecl_or_type))
+ {
+ funexp = force_reg (Pmode, funexp);
+ }
else if (! sibcallp)
{
if (!NO_FUNCTION_CSE && optimize && ! flag_no_function_cse)
diff --git a/gcc/common.opt b/gcc/common.opt
index 51833c1..6753fd3 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1781,6 +1781,10 @@ fpie
Common Report Var(flag_pie,1) Negative(fPIC)
Generate position-independent code for executables if possible (small mode)
+fplt
+Common Report Var(flag_plt) Init(1) Optimization
+Use PLT for PIC calls (-fno-plt: load the address from GOT at call site)
+
fplugin=
Common Joined RejectNegative Var(common_deferred_options) Defer
Specify a plugin to load
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c332f88..b5721c9 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1128,7 +1128,7 @@ See S/390 and zSeries Options.
-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} @gol
-fno-common -fno-ident @gol
--fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol
+-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol
-fno-jump-tables @gol
-frecord-gcc-switches @gol
-freg-struct-return -fshort-enums @gol
@@ -23782,6 +23782,16 @@ used during linking.
@code{__pie__} and @code{__PIE__}. The macros have the value 1
for @option{-fpie} and 2 for @option{-fPIE}.
+@item -fno-plt
+@opindex fno-plt
+Do not use PLT for external function calls in position-independent code.
+Instead, load callee address at call site from GOT and branch to it.
+This leads to more efficient code by eliminating PLT stubs and exposing
+GOT load to optimizations. On architectures such as 32-bit x86 where
+PLT stubs expect GOT pointer in a specific register, this gives more
+register allocation freedom to the compiler. Lazy binding requires PLT:
+with @option{-fno-plt} all external symbols are resolved at load time.
+
@item -fno-jump-tables
@opindex fno-jump-tables
Do not use jump tables for switch statements even where it would be