1// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 2// XFAIL: android 3// 4// RUN: %clangxx -DFUNC=zzzz %s -shared -o %t.so -fPIC 5// RUN: %clangxx_asan -DFUNC=main %s -o %t -Wl,-R. %t.so 6// RUN: %run %t 7 8// GNU driver doesn't handle .so files properly. 9// REQUIRES: Clang 10 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. 19// 20// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56393 21 22struct A { 23 int foo() const { return 0; } 24}; 25A get () { return A(); } 26template <class> struct O { 27 static A const e; 28}; 29template <class T> A const O <T>::e = get(); 30int FUNC() { 31 return O<int>::e.foo(); 32} 33 34