brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 5fe728b Raw
42 lines · cpp
1// Test the ignorelist functionality of ASan2 3// RUN: echo "fun:*brokenFunction*" > %tmp4// RUN: echo "global:*badGlobal*" >> %tmp5// RUN: echo "src:*ignorelist-extra.cpp" >> %tmp6// RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O0 %s -o %t \7// RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&18// RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O1 %s -o %t \9// RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&110// RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O2 %s -o %t \11// RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&112// RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O3 %s -o %t \13// RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&114 15// badGlobal is accessed improperly, but we ignorelisted it. Align16// it to make sure memory past the end of badGlobal will be in17// the same page.18 19// XFAIL: msvc20#include "defines.h"21ATTRIBUTE_ALIGNED(16) int badGlobal;22int readBadGlobal() {23  return (&badGlobal)[1];24}25 26// A function which is broken, but excluded in the ignorelist.27int brokenFunction(int argc) {28  char x[10] = {0};29  return x[argc * 10];  // BOOM30}31 32// This function is defined in Helpers/ignorelist-extra.cpp, a source file which33// is ignorelisted by name34int externalBrokenFunction(int x);35 36int main(int argc, char **argv) {37  brokenFunction(argc);38  int x = readBadGlobal();39  externalBrokenFunction(argc);40  return 0;41}42