1// Test the ignorelist functionality of ASan
2
3// RUN: echo "fun:*brokenFunction*" > %tmp
4// RUN: echo "global:*badGlobal*" >> %tmp
5// RUN: echo "src:*ignorelist-extra.cpp" >> %tmp
6// RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O0 %s -o %t \
7// RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1
8// RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O1 %s -o %t \
9// RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1
10// RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O2 %s -o %t \
11// RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1
12// RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O3 %s -o %t \
13// RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1
14
15// badGlobal is accessed improperly, but we ignorelisted it. Align
16// it to make sure memory past the end of badGlobal will be in
17// the same page.
18__attribute__((aligned(16))) int badGlobal;
19int readBadGlobal() {
20 return (&badGlobal)[1];
21}
22
23// A function which is broken, but excluded in the ignorelist.
24int brokenFunction(int argc) {
25 char x[10] = {0};
26 return x[argc * 10]; // BOOM
27}
28
29// This function is defined in Helpers/ignorelist-extra.cpp, a source file which
30// is ignorelisted by name
31int externalBrokenFunction(int x);
32
33int main(int argc, char **argv) {
34 brokenFunction(argc);
35 int x = readBadGlobal();
36 externalBrokenFunction(x: argc);
37 return 0;
38}
39

source code of compiler-rt/test/asan/TestCases/ignorelist.cpp