1 // RUN: %clangxx -DFUNC=zzzz %s -shared -o %t.so -fPIC 2 // RUN: %clangxx_asan -DFUNC=main %s -o %t -Wl,-R. %t.so 3 // RUN: %t 4 5 // This test ensures that we call __asan_init early enough. 6 // We build a shared library w/o asan instrumentation 7 // and the binary with asan instrumentation. 8 // Both files include the same header (emulated by -DFUNC here) 9 // with C++ template magic which runs global initializer at library load time. 10 // The function get() is instrumented with asan, but called 11 // before the usual constructors are run. 12 // So, we must make sure that __asan_init is executed even earlier. 13 // 14 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56393 15 16 struct A { 17 int foo() const { return 0; } 18 }; 19 A get () { return A(); } 20 template <class> struct O { 21 static A const e; 22 }; 23 template <class T> A const O <T>::e = get(); 24 int FUNC() { 25 return O<int>::e.foo(); 26 } 27 28