diff options
| -rw-r--r-- | compiler-rt/lib/asan/CMakeLists.txt | 22 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/Makefile.mk | 5 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_internal.h | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_new_delete.cc | 7 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/tests/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | compiler-rt/make/platform/clang_darwin.mk | 6 | ||||
| -rw-r--r-- | compiler-rt/make/platform/clang_linux.mk | 19 |
8 files changed, 42 insertions, 22 deletions
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt index 88647b84175..01db51b69da 100644 --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -18,7 +18,6 @@ set(ASAN_SOURCES asan_malloc_linux.cc asan_malloc_mac.cc asan_malloc_win.cc - asan_new_delete.cc asan_poisoning.cc asan_posix.cc asan_report.cc @@ -28,6 +27,9 @@ set(ASAN_SOURCES asan_thread.cc asan_win.cc) +set(ASAN_CXX_SOURCES + asan_new_delete.cc) + set(ASAN_PREINIT_SOURCES asan_preinit.cc) @@ -70,12 +72,12 @@ if(APPLE) foreach(os ${SANITIZER_COMMON_SUPPORTED_DARWIN_OS}) add_compiler_rt_darwin_object_library(RTAsan ${os} ARCH ${ASAN_SUPPORTED_ARCH} - SOURCES ${ASAN_SOURCES} + SOURCES ${ASAN_SOURCES} ${ASAN_CXX_SOURCES} CFLAGS ${ASAN_CFLAGS} DEFS ${ASAN_COMMON_DEFINITIONS}) endforeach() elseif(ANDROID) - add_library(RTAsan.arm.android OBJECT ${ASAN_SOURCES}) + add_library(RTAsan.arm.android OBJECT ${ASAN_SOURCES} ${ASAN_CXX_SOURCES}) set_target_compile_flags(RTAsan.arm.android ${ASAN_CFLAGS}) set_property(TARGET RTAsan.arm.android APPEND PROPERTY COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS}) @@ -84,12 +86,16 @@ else() add_compiler_rt_object_library(RTAsan ${arch} SOURCES ${ASAN_SOURCES} CFLAGS ${ASAN_CFLAGS} DEFS ${ASAN_COMMON_DEFINITIONS}) + add_compiler_rt_object_library(RTAsan_cxx ${arch} + SOURCES ${ASAN_CXX_SOURCES} CFLAGS ${ASAN_CFLAGS} + DEFS ${ASAN_COMMON_DEFINITIONS}) add_compiler_rt_object_library(RTAsan_preinit ${arch} SOURCES ${ASAN_PREINIT_SOURCES} CFLAGS ${ASAN_CFLAGS} DEFS ${ASAN_COMMON_DEFINITIONS}) if (COMPILER_RT_BUILD_SHARED_ASAN) add_compiler_rt_object_library(RTAsan_dynamic ${arch} - SOURCES ${ASAN_SOURCES} CFLAGS ${ASAN_DYNAMIC_CFLAGS} + SOURCES ${ASAN_SOURCES} ${ASAN_CXX_SOURCES} + CFLAGS ${ASAN_DYNAMIC_CFLAGS} DEFS ${ASAN_DYNAMIC_DEFINITIONS}) endif() endforeach() @@ -142,6 +148,12 @@ else() DEFS ${ASAN_COMMON_DEFINITIONS}) add_dependencies(asan clang_rt.asan-${arch}) + add_compiler_rt_runtime(clang_rt.asan_cxx-${arch} ${arch} STATIC + SOURCES $<TARGET_OBJECTS:RTAsan_cxx.${arch}> + CFLAGS ${ASAN_CFLAGS} + DEFS ${ASAN_COMMON_DEFINITIONS}) + add_dependencies(asan clang_rt.asan_cxx-${arch}) + if (COMPILER_RT_BUILD_SHARED_ASAN) add_compiler_rt_runtime(clang_rt.asan-preinit-${arch} ${arch} STATIC SOURCES $<TARGET_OBJECTS:RTAsan_preinit.${arch}> @@ -160,6 +172,8 @@ else() endif() if (UNIX AND NOT ${arch} STREQUAL "i386") + add_sanitizer_rt_symbols(clang_rt.asan_cxx-${arch}) + add_dependencies(asan clang_rt.asan_cxx-${arch}-symbols) add_sanitizer_rt_symbols(clang_rt.asan-${arch} asan.syms.extra) add_dependencies(asan clang_rt.asan-${arch}-symbols) endif() diff --git a/compiler-rt/lib/asan/Makefile.mk b/compiler-rt/lib/asan/Makefile.mk index 6e8d33540d7..0dafefc2fd8 100644 --- a/compiler-rt/lib/asan/Makefile.mk +++ b/compiler-rt/lib/asan/Makefile.mk @@ -11,6 +11,8 @@ ModuleName := asan SubDirs := CCSources := $(foreach file,$(wildcard $(Dir)/*.cc),$(notdir $(file))) +CXXOnlySources := asan_new_delete.cc +COnlySources := $(filter-out $(CXXOnlySources),$(CCSources)) SSources := $(foreach file,$(wildcard $(Dir)/*.S),$(notdir $(file))) Sources := $(CCSources) $(SSources) ObjNames := $(CCSources:%.cc=%.o) $(SSources:%.S=%.o) @@ -23,4 +25,5 @@ Dependencies += $(wildcard $(Dir)/../interception/*.h) Dependencies += $(wildcard $(Dir)/../sanitizer_common/*.h) # Define a convenience variable for all the asan functions. -AsanFunctions := $(CCSources:%.cc=%) $(SSources:%.S=%) +AsanFunctions := $(COnlySources:%.cc=%) $(SSources:%.S=%) +AsanCXXFunctions := $(CXXOnlySources:%.cc=%) diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h index 0c2afdace18..12e68e3283a 100644 --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -71,7 +71,6 @@ void AsanInitFromRtl(); // asan_rtl.cc void NORETURN ShowStatsAndAbort(); -void ReplaceOperatorsNewAndDelete(); // asan_malloc_linux.cc / asan_malloc_mac.cc void ReplaceSystemMalloc(); diff --git a/compiler-rt/lib/asan/asan_new_delete.cc b/compiler-rt/lib/asan/asan_new_delete.cc index 63a8730b273..1a9abad1818 100644 --- a/compiler-rt/lib/asan/asan_new_delete.cc +++ b/compiler-rt/lib/asan/asan_new_delete.cc @@ -20,13 +20,6 @@ #include <stddef.h> -namespace __asan { -// This function is a no-op. We need it to make sure that object file -// with our replacements will actually be loaded from static ASan -// run-time library at link-time. -void ReplaceOperatorsNewAndDelete() { } -} - using namespace __asan; // NOLINT // This code has issues on OSX. diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 831654e276a..fffbba86c02 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -595,7 +595,6 @@ static void AsanInitInternal() { InitializeAsanInterceptors(); ReplaceSystemMalloc(); - ReplaceOperatorsNewAndDelete(); uptr shadow_start = kLowShadowBeg; if (kLowShadowBeg) diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt index 05ef5d05250..c0ca6dd8c39 100644 --- a/compiler-rt/lib/asan/tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/tests/CMakeLists.txt @@ -48,7 +48,7 @@ set(ASAN_UNITTEST_INSTRUMENTED_CFLAGS ) # Unit tests require libstdc++. -set(ASAN_UNITTEST_COMMON_LINKFLAGS -lstdc++) +set(ASAN_UNITTEST_COMMON_LINKFLAGS --driver-mode=g++ -lstdc++) # x86_64 FreeBSD 9.2 additionally requires libc++ to build the tests. if(CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE") list(APPEND ASAN_UNITTEST_COMMON_LINKFLAGS "-lc++") @@ -181,6 +181,7 @@ macro(add_asan_tests_for_arch_and_kind arch kind) else() set(ASAN_TEST_RUNTIME_OBJECTS $<TARGET_OBJECTS:RTAsan.${arch}> + $<TARGET_OBJECTS:RTAsan_cxx.${arch}> $<TARGET_OBJECTS:RTInterception.${arch}> $<TARGET_OBJECTS:RTLSanCommon.${arch}> $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> diff --git a/compiler-rt/make/platform/clang_darwin.mk b/compiler-rt/make/platform/clang_darwin.mk index 32803afc4c6..e9021fc5131 100644 --- a/compiler-rt/make/platform/clang_darwin.mk +++ b/compiler-rt/make/platform/clang_darwin.mk @@ -227,11 +227,13 @@ FUNCTIONS.profile_osx := GCDAProfiling InstrProfiling InstrProfilingBuffer \ InstrProfilingRuntime FUNCTIONS.profile_ios := $(FUNCTIONS.profile_osx) -FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(InterceptionFunctions) \ +FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(AsanCXXFunctions) \ + $(InterceptionFunctions) \ $(SanitizerCommonFunctions) \ $(AsanDynamicFunctions) -FUNCTIONS.asan_iossim_dynamic := $(AsanFunctions) $(InterceptionFunctions) \ +FUNCTIONS.asan_iossim_dynamic := $(AsanFunctions) $(AsanCXXFunctions) \ + $(InterceptionFunctions) \ $(SanitizerCommonFunctions) \ $(AsanDynamicFunctions) diff --git a/compiler-rt/make/platform/clang_linux.mk b/compiler-rt/make/platform/clang_linux.mk index 7612d47ff0a..b4ee85d342d 100644 --- a/compiler-rt/make/platform/clang_linux.mk +++ b/compiler-rt/make/platform/clang_linux.mk @@ -49,23 +49,27 @@ endif # Build runtime libraries for i386. ifeq ($(call contains,$(SupportedArches),i386),true) -Configs += full-i386 profile-i386 san-i386 asan-i386 ubsan-i386 ubsan_cxx-i386 +Configs += full-i386 profile-i386 san-i386 asan-i386 asan_cxx-i386 \ + ubsan-i386 ubsan_cxx-i386 Arch.full-i386 := i386 Arch.profile-i386 := i386 Arch.san-i386 := i386 Arch.asan-i386 := i386 +Arch.asan_cxx-i386 := i386 Arch.ubsan-i386 := i386 Arch.ubsan_cxx-i386 := i386 endif # Build runtime libraries for x86_64. ifeq ($(call contains,$(SupportedArches),x86_64),true) -Configs += full-x86_64 profile-x86_64 san-x86_64 asan-x86_64 tsan-x86_64 \ - msan-x86_64 ubsan-x86_64 ubsan_cxx-x86_64 dfsan-x86_64 lsan-x86_64 +Configs += full-x86_64 profile-x86_64 san-x86_64 asan-x86_64 asan_cxx-x86_64 \ + tsan-x86_64 msan-x86_64 ubsan-x86_64 ubsan_cxx-x86_64 dfsan-x86_64 \ + lsan-x86_64 Arch.full-x86_64 := x86_64 Arch.profile-x86_64 := x86_64 Arch.san-x86_64 := x86_64 Arch.asan-x86_64 := x86_64 +Arch.asan_cxx-x86_64 := x86_64 Arch.tsan-x86_64 := x86_64 Arch.msan-x86_64 := x86_64 Arch.ubsan-x86_64 := x86_64 @@ -96,6 +100,8 @@ CFLAGS.san-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS) -fno-rtti CFLAGS.san-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti CFLAGS.asan-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS) -fno-rtti CFLAGS.asan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti +CFLAGS.asan_cxx-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS) -fno-rtti +CFLAGS.asan_cxx-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti CFLAGS.tsan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti CFLAGS.msan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti CFLAGS.ubsan-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS) -fno-rtti @@ -131,8 +137,11 @@ FUNCTIONS.asan-i386 := $(AsanFunctions) $(InterceptionFunctions) \ $(SanitizerCommonFunctions) FUNCTIONS.asan-x86_64 := $(AsanFunctions) $(InterceptionFunctions) \ $(SanitizerCommonFunctions) $(LsanCommonFunctions) -FUNCTIONS.asan-arm-android := $(AsanFunctions) $(InterceptionFunctions) \ - $(SanitizerCommonFunctions) +FUNCTIONS.asan_cxx-i386 := $(AsanCXXFunctions) +FUNCTIONS.asan_cxx-x86_64 := $(AsanCXXFunctions) +FUNCTIONS.asan-arm-android := $(AsanFunctions) $(AsanCXXFunctions) \ + $(InterceptionFunctions) \ + $(SanitizerCommonFunctions) FUNCTIONS.tsan-x86_64 := $(TsanFunctions) $(InterceptionFunctions) \ $(SanitizerCommonFunctions) FUNCTIONS.msan-x86_64 := $(MsanFunctions) $(InterceptionFunctions) \ |

