summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-01-22 10:45:20 +0000
committerAlexey Samsonov <samsonov@google.com>2013-01-22 10:45:20 +0000
commit1e63b085757a47d2180f8acb4c0ce4ce40b233db (patch)
tree91af973ef4534f955463a7ba24ab8d2ff0beadec
parent6c03b6d005de74891f94baf347df9629fb743ef8 (diff)
downloadbcm5719-llvm-1e63b085757a47d2180f8acb4c0ce4ce40b233db.tar.gz
bcm5719-llvm-1e63b085757a47d2180f8acb4c0ce4ce40b233db.zip
ASan: add output test for -fsanitize-address-zero-based-shadow option on Linux
llvm-svn: 173146
-rw-r--r--compiler-rt/lib/asan/lit_tests/Linux/zero-base-shadow.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/Linux/zero-base-shadow.cc b/compiler-rt/lib/asan/lit_tests/Linux/zero-base-shadow.cc
new file mode 100644
index 00000000000..d6ea1aa02c1
--- /dev/null
+++ b/compiler-rt/lib/asan/lit_tests/Linux/zero-base-shadow.cc
@@ -0,0 +1,27 @@
+// RUN: %clangxx_asan -m64 -O0 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t && %t 2>&1 | %symbolize > %t.out
+// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-64 < %t.out
+// RUN: %clangxx_asan -m64 -O1 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t && %t 2>&1 | %symbolize > %t.out
+// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-64 < %t.out
+// RUN: %clangxx_asan -m64 -O2 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t && %t 2>&1 | %symbolize > %t.out
+// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-64 < %t.out
+// RUN: %clangxx_asan -m32 -O0 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t && %t 2>&1 | %symbolize > %t.out
+// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-32 < %t.out
+// RUN: %clangxx_asan -m32 -O1 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t && %t 2>&1 | %symbolize > %t.out
+// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-32 < %t.out
+// RUN: %clangxx_asan -m32 -O2 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t && %t 2>&1 | %symbolize > %t.out
+// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-32 < %t.out
+
+#include <string.h>
+int main(int argc, char **argv) {
+ char x[10];
+ memset(x, 0, 10);
+ int res = x[argc * 10]; // BOOOM
+ // CHECK: {{READ of size 1 at 0x.* thread T0}}
+ // CHECK: {{ #0 0x.* in _?main .*zero-base-shadow.cc:}}[[@LINE-2]]
+ // CHECK: {{Address 0x.* is .* frame <main>}}
+
+ // Check that shadow for stack memory occupies lower part of address space.
+ // CHECK-64: =>0x0f{{.*}}
+ // CHECK-32: =>0x1f{{.*}}
+ return res;
+}
OpenPOWER on IntegriCloud