45 lines · c
1// RUN: %clangxx_asan -xc++ -shared -fPIC -o %t.so - < %s2// RUN: %clang_asan %s -o %t.out -ldl3//4// RUN: env ASAN_OPTIONS=verbosity=1 not %t.out %t.so 2>&1 | FileCheck %s5//6// CHECK: AddressSanitizer: failed to intercept '__cxa_throw'7//8// This tests assumes static linking of the asan runtime.9// UNSUPPORTED: asan-dynamic-runtime10 11#ifdef __cplusplus12 13static void foo(void) {14 int i = 0;15 throw(i);16}17 18extern "C" {19int bar(void);20};21int bar(void) {22 try {23 foo();24 } catch (int i) {25 return i;26 }27 return -1;28}29 30#else31 32#include <assert.h>33#include <dlfcn.h>34 35int main(int argc, char **argv) {36 int (*bar)(void);37 void *handle = dlopen(argv[1], RTLD_LAZY);38 assert(handle);39 bar = dlsym(handle, "bar");40 assert(bar);41 return bar();42}43 44#endif45