summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjiwang <jiwang@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-29 11:47:48 +0000
committerjiwang <jiwang@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-29 11:47:48 +0000
commit783f362b434198d2e78c390f2de49c676f241559 (patch)
tree58ea11f59eb7d734feba66f5e7ad492c76b250ab
parenta05069906de6b07ced274c83057cd94d5d3ed99e (diff)
downloadgcc-783f362b434198d2e78c390f2de49c676f241559.tar.gz
[Patch] New hook TARGET_STACK_PROTECT_RUNTIME_ENABLED_P to disable SSP runtime
gcc/ * target.def (stack_protect_runtime_enabled_p): New. * function.c (expand_function_end): Guard stack_protect_epilogue with targetm.stack_protect_runtime_enabled_p. * cfgexpand.c (pass_expand::execute): Likewise. * calls.c (expand_call): Likewise. * doc/tm.texi.in (TARGET_STACK_PROTECT_RUNTIME_ENABLED_P): Add it. * doc/tm.texi: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242955 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/calls.c4
-rw-r--r--gcc/cfgexpand.c2
-rw-r--r--gcc/doc/tm.texi4
-rw-r--r--gcc/doc/tm.texi.in2
-rw-r--r--gcc/function.c2
-rw-r--r--gcc/target.def9
7 files changed, 30 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c1dd877bd3d..b7ccbd88550 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2016-11-29 Jiong Wang <jiong.wang@arm.com>
+
+ * target.def (stack_protect_runtime_enabled_p): New.
+ * function.c (expand_function_end): Guard stack_protect_epilogue with
+ targetm.stack_protect_runtime_enabled_p.
+ * cfgexpand.c (pass_expand::execute): Likewise.
+ * calls.c (expand_call): Likewise.
+ * doc/tm.texi.in (TARGET_STACK_PROTECT_RUNTIME_ENABLED_P): Add it.
+ * doc/tm.texi: Regenerate.
+
2016-11-29 Richard Biener <rguenther@suse.de>
PR middle-end/78546
diff --git a/gcc/calls.c b/gcc/calls.c
index c916e0725dc..21385ce0e12 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -3083,7 +3083,9 @@ expand_call (tree exp, rtx target, int ignore)
if (pass && (flags & ECF_MALLOC))
start_sequence ();
- if (pass == 0 && crtl->stack_protect_guard)
+ if (pass == 0
+ && crtl->stack_protect_guard
+ && targetm.stack_protect_runtime_enabled_p ())
stack_protect_epilogue ();
adjusted_args_size = args_size;
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 9cca6111ee4..c3aca593e53 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -6334,7 +6334,7 @@ pass_expand::execute (function *fun)
/* Initialize the stack_protect_guard field. This must happen after the
call to __main (if any) so that the external decl is initialized. */
- if (crtl->stack_protect_guard)
+ if (crtl->stack_protect_guard && targetm.stack_protect_runtime_enabled_p ())
stack_protect_prologue ();
expand_phi_nodes (&SA);
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index ebcadacbe9a..7559c122107 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4946,6 +4946,10 @@ The default version of this hook invokes a function called
normally defined in @file{libgcc2.c}.
@end deftypefn
+@deftypefn {Target Hook} bool TARGET_STACK_PROTECT_RUNTIME_ENABLED_P (void)
+Returns true if the target wants GCC's default stack protect runtime support, otherwise return false. The default implementation always returns true.
+@end deftypefn
+
@deftypefn {Common Target Hook} bool TARGET_SUPPORTS_SPLIT_STACK (bool @var{report}, struct gcc_options *@var{opts})
Whether this target supports splitting the stack when the options described in @var{opts} have been passed. This is called after options have been parsed, so the target may reject splitting the stack in some configurations. The default version of this hook returns false. If @var{report} is true, this function may issue a warning or error; if @var{report} is false, it must simply return a value
@end deftypefn
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 95f5fd9f284..bc6d3cbce02 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3820,6 +3820,8 @@ generic code.
@hook TARGET_STACK_PROTECT_FAIL
+@hook TARGET_STACK_PROTECT_RUNTIME_ENABLED_P
+
@hook TARGET_SUPPORTS_SPLIT_STACK
@node Miscellaneous Register Hooks
diff --git a/gcc/function.c b/gcc/function.c
index c5a538f249b..0829fbe0d01 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5635,7 +5635,7 @@ expand_function_end (void)
emit_insn (gen_blockage ());
/* If stack protection is enabled for this function, check the guard. */
- if (crtl->stack_protect_guard)
+ if (crtl->stack_protect_guard && targetm.stack_protect_runtime_enabled_p ())
stack_protect_epilogue ();
/* If we had calls to alloca, and this machine needs
diff --git a/gcc/target.def b/gcc/target.def
index 85a0ac03092..417cd0256c5 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4039,6 +4039,15 @@ normally defined in @file{libgcc2.c}.",
tree, (void),
default_external_stack_protect_fail)
+/* This target hook allows the operating system to disable the default stack
+ protector runtime support. */
+DEFHOOK
+(stack_protect_runtime_enabled_p,
+ "Returns true if the target wants GCC's default stack protect runtime support,\
+ otherwise return false. The default implementation always returns true.",
+ bool, (void),
+ hook_bool_void_true)
+
DEFHOOK
(can_use_doloop_p,
"Return true if it is possible to use low-overhead loops (@code{doloop_end}\n\