Move ASan lit-tests under test/asan
[blocksruntime.git] / test / asan / TestCases / Linux / asan_prelink_test.cc
blob0f158c1bb3dde76af443d496f54e122511cd2f62
1 // Test if asan works with prelink.
2 // It does not actually use prelink, but relies on ld's flag -Ttext-segment
3 // or gold's flag -Ttext (we try the first flag first, if that fails we
4 // try the second flag).
5 //
6 // RUN: %clangxx_asan -c %s -o %t.o
7 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so -Wl,-Ttext-segment=0x3600000000 ||\
8 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so -Wl,-Ttext=0x3600000000
9 // RUN: %clangxx_asan %t.o %t.so -Wl,-R. -o %t
10 // RUN: ASAN_OPTIONS=verbosity=1 %t 2>&1 | FileCheck %s
12 // REQUIRES: x86_64-supported-target, asan-64-bits
13 #if BUILD_SO
14 int G;
15 int *getG() {
16 return &G;
18 #else
19 #include <stdio.h>
20 extern int *getG();
21 int main(int argc, char **argv) {
22 long p = (long)getG();
23 printf("SO mapped at %lx\n", p & ~0xffffffffUL);
24 *getG() = 0;
26 #endif
27 // CHECK: 0x003000000000, 0x004fffffffff{{.*}} MidMem
28 // CHECK: SO mapped at 3600000000