]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/test/asan/TestCases/Darwin/dead-strip.c
New upstream version 1.28.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / asan / TestCases / Darwin / dead-strip.c
CommitLineData
5bcae85e
SL
1// Test that AddressSanitizer does not re-animate dead globals when dead
2// stripping is turned on.
3//
4// This test verifies that an out-of-bounds access on a global variable is
5// detected after dead stripping has been performed. This proves that the
6// runtime is able to register globals in the __DATA,__asan_globals section.
7
8// REQUIRES: osx-ld64-live_support
2c00a5a8 9// UNSUPPORTED: ios
7cac9316 10// RUN: %clang_asan -mmacosx-version-min=10.11 -Xlinker -dead_strip -o %t %s
5bcae85e
SL
11// RUN: llvm-nm -format=posix %t | FileCheck --check-prefix NM-CHECK %s
12// RUN: not %run %t 2>&1 | FileCheck --check-prefix ASAN-CHECK %s
13
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 to the right of global variable}}
22 return 0;
23}