]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/asan/TestCases/Linux/asan_prelink_test.cc
New upstream version 1.12.0+dfsg1
[rustc.git] / src / compiler-rt / test / asan / TestCases / Linux / asan_prelink_test.cc
CommitLineData
1a4d82fc
JJ
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
92a42be0 10// RUN: %env_asan_opts=verbosity=1 %run %t 2>&1 | FileCheck %s
1a4d82fc 11
92a42be0 12// GNU driver doesn't handle .so files properly.
5bcae85e 13// REQUIRES: x86_64-target-arch, Clang
1a4d82fc
JJ
14#if BUILD_SO
15int G;
16int *getG() {
17 return &G;
18}
19#else
20#include <stdio.h>
21extern int *getG();
22int main(int argc, char **argv) {
23 long p = (long)getG();
24 printf("SO mapped at %lx\n", p & ~0xffffffffUL);
25 *getG() = 0;
26}
27#endif
28// CHECK: 0x003000000000, 0x004fffffffff{{.*}} MidMem
29// CHECK: SO mapped at 3600000000