aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/config/s390/s390.md7
-rw-r--r--gcc/explow.c3
-rw-r--r--gcc/explow.h4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/s390/stack-clash-3.c17
6 files changed, 42 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c1ee99e..0b326ee 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+
+ * config/s390/s390.md ("allocate_stack"): Call
+ anti_adjust_stack_and_probe_stack_clash when stack clash
+ protection is enabled.
+ * explow.c (anti_adjust_stack_and_probe_stack_clash): Remove
+ prototype. Remove static.
+ * explow.h (anti_adjust_stack_and_probe_stack_clash): Add
+ prototype.
+
2020-05-13 Kelvin Nilsen <kelvin@gcc.gnu.org>
* config/rs6000/altivec.h (vec_extractl): New #define.
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index cf53ef1..908de58 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -11007,7 +11007,12 @@
rtx temp = gen_reg_rtx (Pmode);
emit_move_insn (temp, s390_back_chain_rtx ());
- anti_adjust_stack (operands[1]);
+
+ if (flag_stack_clash_protection)
+ anti_adjust_stack_and_probe_stack_clash (operands[1]);
+ else
+ anti_adjust_stack (operands[1]);
+
emit_move_insn (s390_back_chain_rtx (), temp);
emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
diff --git a/gcc/explow.c b/gcc/explow.c
index b838f03..15c9cfb 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -43,7 +43,6 @@ along with GCC; see the file COPYING3. If not see
#include "output.h"
static rtx break_out_memory_refs (rtx);
-static void anti_adjust_stack_and_probe_stack_clash (rtx);
/* Truncate and perhaps sign-extend C as appropriate for MODE. */
@@ -1948,7 +1947,7 @@ emit_stack_clash_protection_probe_loop_end (rtx loop_lab, rtx end_loop,
allocate/probe beyond that because this probing style does not
guarantee signal handling capability if the guard is hit. */
-static void
+void
anti_adjust_stack_and_probe_stack_clash (rtx size)
{
/* First ensure SIZE is Pmode. */
diff --git a/gcc/explow.h b/gcc/explow.h
index cc44bf8..0df8c62 100644
--- a/gcc/explow.h
+++ b/gcc/explow.h
@@ -69,6 +69,10 @@ extern void anti_adjust_stack (rtx);
/* Add some bytes to the stack while probing it. An rtx says how many. */
extern void anti_adjust_stack_and_probe (rtx, bool);
+/* Add some bytes to the stack while probing it. An rtx says how
+ many. Add additional probes to prevent stack clashing attacks. */
+extern void anti_adjust_stack_and_probe_stack_clash (rtx);
+
/* Support for building allocation/probing loops for stack-clash
protection of dyamically allocated stack space. */
extern void compute_stack_clash_protection_loop_data (rtx *, rtx *, rtx *,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 916bc2d..bb3e4c8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+
+ * gcc.target/s390/stack-clash-3.c: New test.
+
2020-05-13 Kelvin Nilsen <kelvin@gcc.gnu.org>
* gcc.target/powerpc/vec-extracth-0.c: New.
diff --git a/gcc/testsuite/gcc.target/s390/stack-clash-3.c b/gcc/testsuite/gcc.target/s390/stack-clash-3.c
new file mode 100644
index 0000000..929d3fb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/stack-clash-3.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=z900 -fstack-clash-protection -mbackchain" } */
+
+extern void bar (char *);
+
+void
+foo ()
+{
+ char * mem = __builtin_alloca (20000);
+ bar (mem);
+}
+
+/* For alloca a common code routine emits the probes. Make sure the
+ "probe_stack" expander is used in that case. We want to use mem
+ compares instead of stores. */
+/* { dg-final { scan-assembler-times "cg\t" 5 { target lp64 } } } */
+/* { dg-final { scan-assembler-times "c\t" 5 { target { ! lp64 } } } } */