2 // https://code.google.com/p/address-sanitizer/issues/detail?id=178
4 // RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
5 // RUN: %clangxx_asan -O0 %s %libdl -Wl,--export-dynamic -o %t
6 // RUN: %env_asan_opts=strict_init_order=true %run %t 2>&1
8 // dlopen() can not be intercepted on Android, making strict_init_order nearly
10 // UNSUPPORTED: android
12 #if defined(SHARED_LIB)
16 Bar(int val
) : val(val
) { printf("Bar::Bar(%d)\n", val
); }
21 Bar
global_bar(get_foo_val());
27 Foo() : val(42) { printf("Foo::Foo()\n"); }
34 return global_foo
.val
;
37 int main(int argc
, char *argv
[]) {
38 std::string path
= std::string(argv
[0]) + "-so.so";
39 void *handle
= dlopen(path
.c_str(), RTLD_NOW
);
41 printf("error in dlopen(): %s\n", dlerror());
44 printf("%d\n", get_foo_val());