Index: compiler-rt/trunk/CMakeLists.txt =================================================================== --- compiler-rt/trunk/CMakeLists.txt +++ compiler-rt/trunk/CMakeLists.txt @@ -94,14 +94,17 @@ if(APPLE AND SANITIZER_MIN_OSX_VERSION AND SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.9") # Mac OS X prior to 10.9 had problems with exporting symbols from # libc++/libc++abi. - set(use_cxxabi_default OFF) -elseif(MSVC) - set(use_cxxabi_default OFF) + set(cxxabi_supported OFF) else() - set(use_cxxabi_default ON) + set(cxxabi_supported ON) endif() -option(SANITIZER_CAN_USE_CXXABI "Sanitizers can use cxxabi" ${use_cxxabi_default}) +option(SANITIZER_ALLOW_CXXABI "Allow use of C++ ABI details in ubsan" ON) + +set(SANITIZE_CAN_USE_CXXABI OFF) +if (cxxabi_supported AND SANITIZER_ALLOW_CXXABI) + set(SANITIZER_CAN_USE_CXXABI ON) +endif() pythonize_bool(SANITIZER_CAN_USE_CXXABI) set(SANITIZER_CXX_ABI "default" CACHE STRING Index: compiler-rt/trunk/lib/ubsan/ubsan_handlers.h =================================================================== --- compiler-rt/trunk/lib/ubsan/ubsan_handlers.h +++ compiler-rt/trunk/lib/ubsan/ubsan_handlers.h @@ -192,6 +192,13 @@ /// \brief Handle control flow integrity failures. RECOVERABLE(cfi_check_fail, CFICheckFailData *Data, ValueHandle Function, uptr VtableIsValid) + +struct ReportOptions; + +extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __ubsan_handle_cfi_bad_type( + CFICheckFailData *Data, ValueHandle Vtable, bool ValidVtable, + ReportOptions Opts); + } #endif // UBSAN_HANDLERS_H Index: compiler-rt/trunk/lib/ubsan/ubsan_handlers.cc =================================================================== --- compiler-rt/trunk/lib/ubsan/ubsan_handlers.cc +++ compiler-rt/trunk/lib/ubsan/ubsan_handlers.cc @@ -652,16 +652,33 @@ } namespace __ubsan { + #ifdef UBSAN_CAN_USE_CXXABI + +#ifdef _WIN32 + +extern "C" void __ubsan_handle_cfi_bad_type_default(CFICheckFailData *Data, + ValueHandle Vtable, + bool ValidVtable, + ReportOptions Opts) { + Die(); +} + +WIN_WEAK_ALIAS(__ubsan_handle_cfi_bad_type, __ubsan_handle_cfi_bad_type_default) +#else SANITIZER_WEAK_ATTRIBUTE -void HandleCFIBadType(CFICheckFailData *Data, ValueHandle Vtable, - bool ValidVtable, ReportOptions Opts); +#endif +void __ubsan_handle_cfi_bad_type(CFICheckFailData *Data, ValueHandle Vtable, + bool ValidVtable, ReportOptions Opts); + #else -static void HandleCFIBadType(CFICheckFailData *Data, ValueHandle Vtable, - bool ValidVtable, ReportOptions Opts) { +static void __ubsan_handle_cfi_bad_type(CFICheckFailData *Data, + ValueHandle Vtable, + bool ValidVtable, ReportOptions Opts) { Die(); } #endif + } // namespace __ubsan void __ubsan::__ubsan_handle_cfi_check_fail(CFICheckFailData *Data, @@ -671,7 +688,7 @@ if (Data->CheckKind == CFITCK_ICall) handleCFIBadIcall(Data, Value, Opts); else - HandleCFIBadType(Data, Value, ValidVtable, Opts); + __ubsan_handle_cfi_bad_type(Data, Value, ValidVtable, Opts); } void __ubsan::__ubsan_handle_cfi_check_fail_abort(CFICheckFailData *Data, @@ -681,7 +698,7 @@ if (Data->CheckKind == CFITCK_ICall) handleCFIBadIcall(Data, Value, Opts); else - HandleCFIBadType(Data, Value, ValidVtable, Opts); + __ubsan_handle_cfi_bad_type(Data, Value, ValidVtable, Opts); Die(); } Index: compiler-rt/trunk/lib/ubsan/ubsan_handlers_cxx.cc =================================================================== --- compiler-rt/trunk/lib/ubsan/ubsan_handlers_cxx.cc +++ compiler-rt/trunk/lib/ubsan/ubsan_handlers_cxx.cc @@ -95,8 +95,8 @@ } namespace __ubsan { -void HandleCFIBadType(CFICheckFailData *Data, ValueHandle Vtable, - bool ValidVtable, ReportOptions Opts) { +void __ubsan_handle_cfi_bad_type(CFICheckFailData *Data, ValueHandle Vtable, + bool ValidVtable, ReportOptions Opts) { SourceLocation Loc = Data->Loc.acquire(); ErrorType ET = ErrorType::CFIBadType; Index: compiler-rt/trunk/test/cfi/target_uninstrumented.cpp =================================================================== --- compiler-rt/trunk/test/cfi/target_uninstrumented.cpp +++ compiler-rt/trunk/test/cfi/target_uninstrumented.cpp @@ -3,6 +3,7 @@ // RUN: %t 2>&1 | FileCheck %s // REQUIRES: cxxabi +// UNSUPPORTED: win32 #include #include Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/PR33221.cpp =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/PR33221.cpp +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/PR33221.cpp @@ -2,6 +2,7 @@ // RUN: %run %t 2>&1 | FileCheck %s // REQUIRES: cxxabi +// UNSUPPORTED: win32 #include Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp @@ -3,6 +3,7 @@ // RUN: %run %t // // REQUIRES: cxxabi +// UNSUPPORTED: win32 struct X { virtual ~X() {} Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-virtual-base-construction.cpp =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-virtual-base-construction.cpp +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-virtual-base-construction.cpp @@ -2,6 +2,7 @@ // RUN: %run %t // REQUIRES: cxxabi +// UNSUPPORTED: win32 int volatile n; Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp @@ -2,6 +2,7 @@ // RUN: not %run %t 2>&1 | FileCheck %s // REQUIRES: cxxabi +// UNSUPPORTED: win32 struct S { virtual int f() { return 0; } }; struct T : virtual S {}; Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp @@ -26,6 +26,7 @@ // RUN: %env_ubsan_opts=suppressions='"%t.loc-supp"' not %run %t x- 2>&1 | FileCheck %s --check-prefix=CHECK-LOC-SUPPRESS // REQUIRES: stable-runtime, cxxabi +// UNSUPPORTED: win32 #include #include #include