aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2020-09-24 10:06:11 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2020-09-24 10:06:11 +0100
commit59c8329389751ec39985a89a673768b4d4fdb338 (patch)
tree331b704f8b3c2a5679398aeaed017d865ccf037b /gcc
parente94797250b403d66cb3624a594e41faf0dd76617 (diff)
downloadgcc-59c8329389751ec39985a89a673768b4d4fdb338.zip
gcc-59c8329389751ec39985a89a673768b4d4fdb338.tar.gz
gcc-59c8329389751ec39985a89a673768b4d4fdb338.tar.bz2
arm: Add a couple of extra stack-protector tests
These tests were inspired by corresponding aarch64 ones. They already pass. gcc/testsuite/ * gcc.target/arm/stack-protector-5.c: New test. * gcc.target/arm/stack-protector-6.c: Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.target/arm/stack-protector-5.c21
-rw-r--r--gcc/testsuite/gcc.target/arm/stack-protector-6.c8
2 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/arm/stack-protector-5.c b/gcc/testsuite/gcc.target/arm/stack-protector-5.c
new file mode 100644
index 0000000..b808b11
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/stack-protector-5.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-fstack-protector-all -O2" } */
+
+void __attribute__ ((noipa))
+f (void)
+{
+ volatile int x;
+ asm volatile ("" :::
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "r12", "r14");
+}
+
+/* The register clobbers above should not generate any single LDRs or STRs;
+ all registers should be pushed and popped using register lists. The only
+ STRs should therefore be those associated with the stack protector tests
+ themselves.
+
+ Make sure the address of the canary is not spilled and reloaded,
+ since that would give the attacker an opportunity to change the
+ canary value. */
+/* { dg-final { scan-assembler-times {\tstr\t} 1 } } */
diff --git a/gcc/testsuite/gcc.target/arm/stack-protector-6.c b/gcc/testsuite/gcc.target/arm/stack-protector-6.c
new file mode 100644
index 0000000..f8eec87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/stack-protector-6.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-fstack-protector-all -O2 -fpic" } */
+
+#include "stack-protector-5.c"
+
+/* See the comment in stack-protector-5.c. */
+/* { dg-final { scan-assembler-times {\tstr\t} 1 } } */