1 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
4 // RUN: %clangxx -DFUNC=zzzz %s -shared -o %t.so -fPIC
5 // RUN: %clangxx_asan -DFUNC=main %s -o %t -Wl,-R. %t.so
8 // GNU driver doesn't handle .so files properly.
11 // This test ensures that we call __asan_init early enough.
12 // We build a shared library w/o asan instrumentation
13 // and the binary with asan instrumentation.
14 // Both files include the same header (emulated by -DFUNC here)
15 // with C++ template magic which runs global initializer at library load time.
16 // The function get() is instrumented with asan, but called
17 // before the usual constructors are run.
18 // So, we must make sure that __asan_init is executed even earlier.
20 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56393
23 int foo() const { return 0; }
25 A get () { return A(); }
26 template <class> struct O {
29 template <class T> A const O <T>::e = get();
31 return O<int>::e.foo();