forked from OSchip/llvm-project
[ASan/Win] Handle SEH exceptions even with -GS
This is a follow-up to r213654, r213656, r213667 and r213668. llvm-svn: 214861
This commit is contained in:
parent
e56de69500
commit
0575694729
|
@ -75,7 +75,7 @@ struct FunctionInterceptor<0> {
|
|||
// Special case of hooks -- ASan own interface functions. Those are only called
|
||||
// after __asan_init, thus an empty implementation is sufficient.
|
||||
#define INTERFACE_FUNCTION(name) \
|
||||
extern "C" void name() { \
|
||||
extern "C" __declspec(noinline) void name() { \
|
||||
volatile int prevent_icf = (__LINE__ << 8); (void)prevent_icf; \
|
||||
__debugbreak(); \
|
||||
} \
|
||||
|
@ -325,6 +325,14 @@ WRAP_W_W(_expand_dbg)
|
|||
INTERCEPT_LIBRARY_FUNCTION(atoi);
|
||||
INTERCEPT_LIBRARY_FUNCTION(atol);
|
||||
INTERCEPT_LIBRARY_FUNCTION(_except_handler3);
|
||||
|
||||
// _except_handler4 checks -GS cookie which is different for each module, so we
|
||||
// can't use INTERCEPT_LIBRARY_FUNCTION(_except_handler4).
|
||||
INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
|
||||
__asan_handle_no_return();
|
||||
return REAL(_except_handler4)(a, b, c, d);
|
||||
}
|
||||
|
||||
INTERCEPT_LIBRARY_FUNCTION(frexp);
|
||||
INTERCEPT_LIBRARY_FUNCTION(longjmp);
|
||||
INTERCEPT_LIBRARY_FUNCTION(memchr);
|
||||
|
@ -348,6 +356,7 @@ INTERCEPT_LIBRARY_FUNCTION(wcslen);
|
|||
// is defined.
|
||||
void InterceptHooks() {
|
||||
INTERCEPT_HOOKS();
|
||||
INTERCEPT_FUNCTION(_except_handler4);
|
||||
}
|
||||
|
||||
// We want to call __asan_init before C/C++ initializers/constructors are
|
||||
|
|
|
@ -308,6 +308,12 @@ INTERCEPTOR(int, _except_handler3, void *a, void *b, void *c, void *d) {
|
|||
__asan_handle_no_return();
|
||||
return REAL(_except_handler3)(a, b, c, d);
|
||||
}
|
||||
|
||||
INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
|
||||
CHECK(REAL(_except_handler4));
|
||||
__asan_handle_no_return();
|
||||
return REAL(_except_handler4)(a, b, c, d);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ASAN_INTERCEPT_MLOCKX
|
||||
|
@ -745,6 +751,7 @@ void InitializeWindowsInterceptors() {
|
|||
ASAN_INTERCEPT_FUNC(CreateThread);
|
||||
ASAN_INTERCEPT_FUNC(RaiseException);
|
||||
ASAN_INTERCEPT_FUNC(_except_handler3);
|
||||
ASAN_INTERCEPT_FUNC(_except_handler4);
|
||||
}
|
||||
|
||||
} // namespace __asan
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
// build a large project using "clang-cl -fallback -fsanitize=address".
|
||||
//
|
||||
// RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t
|
||||
//
|
||||
// Check both -GS and -GS- builds:
|
||||
// RUN: cl -LD -c %s -Fo%t.obj
|
||||
// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll %t.obj
|
||||
// RUN: %run %t %t.dll
|
||||
//
|
||||
// RUN: cl -LD -GS- -c %s -Fo%t.obj
|
||||
// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll %t.obj
|
||||
// RUN: %run %t %t.dll
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
// the rest is built with Clang. This represents the typical scenario when we
|
||||
// build a large project using "clang-cl -fallback -fsanitize=address".
|
||||
//
|
||||
// FIXME: Investigate why -GS- is required.
|
||||
// Check both -GS and -GS- builds:
|
||||
// RUN: cl -c %s -Fo%t.obj
|
||||
// RUN: %clangxx_asan -o %t.exe %s %t.obj
|
||||
// RUN: %run %t.exe
|
||||
//
|
||||
// RUN: cl -GS- -c %s -Fo%t.obj
|
||||
// RUN: %clangxx_asan -o %t.exe %s %t.obj
|
||||
// RUN: %run %t.exe
|
||||
|
|
Loading…
Reference in New Issue