1 // RUN: %clangxx_asan -O0 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t
2 // RUN: not %t 2>&1 | FileCheck %s
3 // RUN: %clangxx_asan -O1 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t
4 // RUN: not %t 2>&1 | FileCheck %s
5 // RUN: %clangxx_asan -O2 -fsanitize-address-zero-base-shadow -fPIE -pie %s -o %t
6 // RUN: not %t 2>&1 | FileCheck %s
7
8 // Zero-base shadow only works on x86_64 and i386.
9 // REQUIRES: i386-supported-target, asan-32-bits
10
11 #include <string.h>
main(int argc,char ** argv)12 int main(int argc, char **argv) {
13 char x[10];
14 memset(x, 0, 10);
15 int res = x[argc * 10]; // BOOOM
16 // CHECK: {{READ of size 1 at 0x.* thread T0}}
17 // CHECK: {{ #0 0x.* in main .*zero-base-shadow32.cc:}}[[@LINE-2]]
18 // CHECK: {{Address 0x.* is .* frame}}
19 // CHECK: main
20
21 // Check that shadow for stack memory occupies lower part of address space.
22 // CHECK: =>0x1
23 return res;
24 }
25