summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp
diff options
context:
space:
mode:
authorOliver Stannard <oliver.stannard@arm.com>2018-09-13 10:25:36 +0000
committerOliver Stannard <oliver.stannard@arm.com>2018-09-13 10:25:36 +0000
commit1a7f6a9239dcbf44b462d425f48ae11ed5e9ce0e (patch)
treea8f67ecf9dd98df7f040f2a83ab7119169f70d97 /test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp
parent41cad03f423feaa28eced143fb8cdac7f88226c7 (diff)
[AArch64] Enable return address signing for static ctors
Functions generated by clang and included in the .init_array section (such as static constructors) do not follow the usual code path for adding target-specific function attributes, so we have to add the return address signing attribute here too, as is currently done for the sanitisers. Differential revision: https://reviews.llvm.org/D51418 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342126 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp')
-rw-r--r--test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp b/test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp
new file mode 100644
index 0000000000..de24eeea98
--- /dev/null
+++ b/test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang -target aarch64-arm-none-eabi -S -emit-llvm -o - -msign-return-address=none %s | \
+// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NONE
+// RUN: %clang -target aarch64-arm-none-eabi -S -emit-llvm -o - -msign-return-address=non-leaf %s | \
+// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-PARTIAL
+// RUN: %clang -target aarch64-arm-none-eabi -S -emit-llvm -o - -msign-return-address=all %s | \
+// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ALL
+
+struct Foo {
+ Foo() {}
+ ~Foo() {}
+};
+
+Foo f;
+
+// CHECK: @llvm.global_ctors {{.*}}i32 65535, void ()* @[[CTOR_FN:.*]], i8* null
+
+// CHECK: @[[CTOR_FN]]() #[[ATTR:[0-9]*]]
+
+// CHECK-NONE-NOT: attributes #[[ATTR]] = { {{.*}} "sign-return-address"={{.*}} }}
+// CHECK-PARTIAL: attributes #[[ATTR]] = { {{.*}} "sign-return-address"="non-leaf" {{.*}}}
+// CHECK-ALL: attributes #[[ATTR]] = { {{.*}} "sign-return-address"="all" {{.*}} }