aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2020-09-23 19:21:56 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2020-09-23 19:21:56 +0100
commit0f0b00033a71ff728d6fab6f9d674fb6b3ba4980 (patch)
tree2b191f4474bd308e0a82c494b54e363e60440071 /gcc
parentf65ebb5210e2fded0f7b339219685f4480124f0c (diff)
downloadgcc-0f0b00033a71ff728d6fab6f9d674fb6b3ba4980.zip
gcc-0f0b00033a71ff728d6fab6f9d674fb6b3ba4980.tar.gz
gcc-0f0b00033a71ff728d6fab6f9d674fb6b3ba4980.tar.bz2
aarch64: Add a couple of extra stack-protector tests
These tests were inspired by corresponding arm ones. They already pass. gcc/testsuite/ * gcc.target/aarch64/stack-protector-3.c: New test. * gcc.target/aarch64/stack-protector-4.c: Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.target/aarch64/stack-protector-3.c45
-rw-r--r--gcc/testsuite/gcc.target/aarch64/stack-protector-4.c6
2 files changed, 51 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/aarch64/stack-protector-3.c b/gcc/testsuite/gcc.target/aarch64/stack-protector-3.c
new file mode 100644
index 0000000..909e26c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/stack-protector-3.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-require-effective-target fstack_protector } */
+/* { dg-options "-fstack-protector-all -O2" } */
+
+extern volatile long *stack_chk_guard_ptr;
+
+void __attribute__ ((noipa))
+f (void)
+{
+ volatile int x;
+ /* Munging the contents of __stack_chk_guard should trigger a
+ stack-smashing failure for this function. */
+ *stack_chk_guard_ptr += 1;
+}
+
+#define CHECK(REG) "\tcmp\tx0, " #REG "\n\tbeq\t1f\n"
+
+asm (
+" .pushsection .data\n"
+" .align 3\n"
+"stack_chk_guard_ptr:\n"
+#if __ILP32__
+" .word __stack_chk_guard\n"
+#else
+" .xword __stack_chk_guard\n"
+#endif
+" .weak __stack_chk_guard\n"
+"__stack_chk_guard:\n"
+" .word 0xdead4321\n"
+" .word 0xbeef8765\n"
+" .text\n"
+" .type __stack_chk_fail, %function\n"
+"__stack_chk_fail:\n"
+" mov x0, #0\n"
+" b exit\n"
+" .size __stack_chk_fail, .-__stack_chk_fail\n"
+" .popsection"
+);
+
+int
+main (void)
+{
+ f ();
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/stack-protector-4.c b/gcc/testsuite/gcc.target/aarch64/stack-protector-4.c
new file mode 100644
index 0000000..6334dd0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/stack-protector-4.c
@@ -0,0 +1,6 @@
+/* { dg-do run } */
+/* { dg-require-effective-target fstack_protector } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-fstack-protector-all -O2 -fpic" } */
+
+#include "stack-protector-3.c"