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