]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/init-order-dlopen.cc
2 // https://code.google.com/p/address-sanitizer/issues/detail?id=178
4 // Assume we're on Darwin and try to pass -U to the linker. If this flag is
5 // unsupported, don't use it.
6 // RUN: %clangxx_asan -O0 %p/SharedLibs/init-order-dlopen-so.cc \
7 // RUN: -fPIC -shared -o %t-so.so -Wl,-U,_inc_global || \
8 // RUN: %clangxx_asan -O0 %p/SharedLibs/init-order-dlopen-so.cc \
9 // RUN: -fPIC -shared -o %t-so.so
10 // If the linker doesn't support --export-dynamic (which is ELF-specific),
11 // try to link without that option.
12 // FIXME: find a better solution.
13 // RUN: %clangxx_asan -O0 %s -lpthread -ldl -o %t -Wl,--export-dynamic || \
14 // RUN: %clangxx_asan -O0 %s -lpthread -ldl -o %t
15 // RUN: ASAN_OPTIONS=strict_init_order=true %run %t 2>&1 | FileCheck %s
30 __attribute__((visibility("default")))
36 void *global_poller(void *arg
) {
45 int main(int argc
, char *argv
[]) {
47 pthread_create(&p
, 0, global_poller
, 0);
48 string path
= string(argv
[0]) + "-so.so";
49 if (0 == dlopen(path
.c_str(), RTLD_NOW
)) {
50 fprintf(stderr
, "dlerror: %s\n", dlerror());