brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1005 B · ca20a89 Raw
32 lines · cpp
1// RUN: mkdir -p %t.dir && cd %t.dir2// RUN: %clangxx -DFUNC=zzzz %s -shared -o %dynamiclib -fPIC3// RUN: %clangxx_asan -DFUNC=main %s -o %t.dir/EXE %ld_flags_rpath_exe4// RUN: %run %t.dir/EXE5 6// GNU driver doesn't handle .so files properly.7// REQUIRES: Clang8 9// This test ensures that we call __asan_init early enough.10// We build a shared library w/o asan instrumentation11// and the binary with asan instrumentation.12// Both files include the same header (emulated by -DFUNC here)13// with C++ template magic which runs global initializer at library load time.14// The function get() is instrumented with asan, but called15// before the usual constructors are run.16// So, we must make sure that __asan_init is executed even earlier.17//18// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5639319 20struct A {21  int foo() const { return 0; }22};23A get () { return A(); }24template <class> struct O {25  static A const e;26};27template <class T> A const O <T>::e = get();28int FUNC() {29  return O<int>::e.foo();30}31 32