24 lines · c
1// Test that AddressSanitizer does not re-animate dead globals when dead2// stripping is turned on.3//4// This test verifies that an out-of-bounds access on a global variable is5// detected after dead stripping has been performed. This proves that the6// runtime is able to register globals in the __DATA,__asan_globals section.7 8// REQUIRES: osx-ld64-live_support9 10// RUN: %clang_asan %min_macos_deployment_target=10.11 -Xlinker -dead_strip -o %t %s11// RUN: llvm-nm --format=posix %t | FileCheck --check-prefix NM-CHECK %s12// RUN: not %run %t 2>&1 | FileCheck --check-prefix ASAN-CHECK %s13 14int alive[1] = {};15int dead[1] = {};16// NM-CHECK: {{^_alive }}17// NM-CHECK-NOT: {{^_dead }}18 19int main(int argc, char *argv[]) {20 alive[argc] = 0;21 // ASAN-CHECK: {{0x.* is located 0 bytes after global variable}}22 return 0;23}24