diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-03-20 23:49:17 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-03-20 23:49:17 +0000 |
commit | 3e587a4f631c1b7338d4f2a29df74b704b8bb1ca (patch) | |
tree | c0b0cf95f41a5813e7c53ad12ce714172dfda953 | |
parent | edcb288a81c4e6abd6537342295750d9d1223349 (diff) | |
download | compiler-rt-3e587a4f631c1b7338d4f2a29df74b704b8bb1ca.tar.gz |
Split ubsan runtime into three pieces (compiler-rt part):
* libclang_rt-san-* is sanitizer_common, and is linked in only if no other
sanitizer runtime is present.
* libclang_rt-ubsan-* is the piece of the runtime which doesn't depend on
a C++ ABI library, and is always linked in.
* libclang_rt-ubsan_cxx-* is the piece of the runtime which depends on a
C++ ABI library, and is only linked in when linking a C++ binary.
The Darwin ubsan runtime is unchanged.
For more details, see Clang change r177605.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177606 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/sanitizer_common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/ubsan/CMakeLists.txt | 18 | ||||
-rw-r--r-- | lib/ubsan/Makefile.mk | 5 | ||||
-rw-r--r-- | make/platform/clang_linux.mk | 26 |
4 files changed, 39 insertions, 12 deletions
diff --git a/lib/sanitizer_common/CMakeLists.txt b/lib/sanitizer_common/CMakeLists.txt index e89e207f4..4ef258f1c 100644 --- a/lib/sanitizer_common/CMakeLists.txt +++ b/lib/sanitizer_common/CMakeLists.txt @@ -74,6 +74,8 @@ else() foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH}) add_compiler_rt_object_library(RTSanitizerCommon ${arch} SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS}) + add_compiler_rt_static_runtime(clang_rt.san-${arch} ${arch} + SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS}) list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${arch}) endforeach() endif() diff --git a/lib/ubsan/CMakeLists.txt b/lib/ubsan/CMakeLists.txt index b549153e5..3dd8613be 100644 --- a/lib/ubsan/CMakeLists.txt +++ b/lib/ubsan/CMakeLists.txt @@ -3,9 +3,12 @@ set(UBSAN_SOURCES ubsan_diag.cc ubsan_handlers.cc + ubsan_value.cc + ) + +set(UBSAN_CXX_SOURCES ubsan_handlers_cxx.cc ubsan_type_hash.cc - ubsan_value.cc ) include_directories(..) @@ -21,18 +24,25 @@ if(APPLE) # Build universal binary on APPLE. add_compiler_rt_osx_static_runtime(clang_rt.ubsan_osx ARCH ${UBSAN_SUPPORTED_ARCH} - SOURCES ${UBSAN_SOURCES} + SOURCES ${UBSAN_SOURCES} ${UBSAN_CXX_SOURCES} $<TARGET_OBJECTS:RTSanitizerCommon.osx> CFLAGS ${UBSAN_CFLAGS}) list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan_osx) else() # Build separate libraries for each target. foreach(arch ${UBSAN_SUPPORTED_ARCH}) + # Main UBSan runtime. add_compiler_rt_static_runtime(clang_rt.ubsan-${arch} ${arch} SOURCES ${UBSAN_SOURCES} - $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> CFLAGS ${UBSAN_CFLAGS}) - list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-${arch}) + # C++-specific parts of UBSan runtime. Requires a C++ ABI library. + add_compiler_rt_static_runtime(clang_rt.ubsan_cxx-${arch} ${arch} + SOURCES ${UBSAN_CXX_SOURCES} + CFLAGS ${UBSAN_CFLAGS}) + list(APPEND UBSAN_RUNTIME_LIBRARIES + clang_rt.san-${arch} + clang_rt.ubsan-${arch} + clang_rt.ubsan_cxx-${arch}) endforeach() endif() diff --git a/lib/ubsan/Makefile.mk b/lib/ubsan/Makefile.mk index 5702e0e75..d5561f41b 100644 --- a/lib/ubsan/Makefile.mk +++ b/lib/ubsan/Makefile.mk @@ -11,6 +11,8 @@ ModuleName := ubsan SubDirs := Sources := $(foreach file,$(wildcard $(Dir)/*.cc),$(notdir $(file))) +CXXSources := ubsan_type_hash.cc ubsan_handlers_cxx.cc +CSources := $(filter-out $(CXXSources),$(Sources)) ObjNames := $(Sources:%.cc=%.o) Implementation := Generic @@ -20,4 +22,5 @@ Dependencies := $(wildcard $(Dir)/*.h) Dependencies += $(wildcard $(Dir)/../sanitizer_common/*.h) # Define a convenience variable for all the ubsan functions. -UbsanFunctions := $(Sources:%.cc=%) +UbsanFunctions := $(CSources:%.cc=%) +UbsanCXXFunctions := $(CXXSources:%.cc=%) diff --git a/make/platform/clang_linux.mk b/make/platform/clang_linux.mk index d3ddc7138..441ad7912 100644 --- a/make/platform/clang_linux.mk +++ b/make/platform/clang_linux.mk @@ -51,23 +51,27 @@ endif # Build runtime libraries for i386. ifeq ($(call contains,$(SupportedArches),i386),true) -Configs += full-i386 profile-i386 asan-i386 ubsan-i386 +Configs += full-i386 profile-i386 san-i386 asan-i386 ubsan-i386 ubsan_cxx-i386 Arch.full-i386 := i386 Arch.profile-i386 := i386 +Arch.san-i386 := i386 Arch.asan-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 asan-x86_64 tsan-x86_64 msan-x86_64 \ - ubsan-x86_64 +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 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.tsan-x86_64 := x86_64 Arch.msan-x86_64 := x86_64 Arch.ubsan-x86_64 := x86_64 +Arch.ubsan_cxx-x86_64 := x86_64 endif ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),) @@ -86,14 +90,18 @@ CFLAGS.full-i386 := $(CFLAGS) -m32 CFLAGS.full-x86_64 := $(CFLAGS) -m64 CFLAGS.profile-i386 := $(CFLAGS) -m32 CFLAGS.profile-x86_64 := $(CFLAGS) -m64 +CFLAGS.san-i386 := $(CFLAGS) -m32 -fPIE -fno-builtin -fno-rtti +CFLAGS.san-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin -fno-rtti CFLAGS.asan-i386 := $(CFLAGS) -m32 -fPIE -fno-builtin -fno-rtti \ -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=1 CFLAGS.asan-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin -fno-rtti \ -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=1 CFLAGS.tsan-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin -fno-rtti CFLAGS.msan-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin -fno-rtti -CFLAGS.ubsan-i386 := $(CFLAGS) -m32 -fPIE -fno-builtin -CFLAGS.ubsan-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin +CFLAGS.ubsan-i386 := $(CFLAGS) -m32 -fPIE -fno-builtin -fno-rtti +CFLAGS.ubsan-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin -fno-rtti +CFLAGS.ubsan_cxx-i386 := $(CFLAGS) -m32 -fPIE -fno-builtin +CFLAGS.ubsan_cxx-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin SHARED_LIBRARY.asan-arm-android := 1 ANDROID_COMMON_FLAGS := -target arm-linux-androideabi \ @@ -116,6 +124,8 @@ FUNCTIONS.full-i386 := $(CommonFunctions) $(ArchFunctions.i386) FUNCTIONS.full-x86_64 := $(CommonFunctions) $(ArchFunctions.x86_64) FUNCTIONS.profile-i386 := GCDAProfiling FUNCTIONS.profile-x86_64 := GCDAProfiling +FUNCTIONS.san-i386 := $(SanitizerCommonFunctions) +FUNCTIONS.san-x86_64 := $(SanitizerCommonFunctions) FUNCTIONS.asan-i386 := $(AsanFunctions) $(InterceptionFunctions) \ $(SanitizerCommonFunctions) FUNCTIONS.asan-x86_64 := $(AsanFunctions) $(InterceptionFunctions) \ @@ -126,8 +136,10 @@ FUNCTIONS.tsan-x86_64 := $(TsanFunctions) $(InterceptionFunctions) \ $(SanitizerCommonFunctions) FUNCTIONS.msan-x86_64 := $(MsanFunctions) $(InterceptionFunctions) \ $(SanitizerCommonFunctions) -FUNCTIONS.ubsan-i386 := $(UbsanFunctions) $(SanitizerCommonFunctions) -FUNCTIONS.ubsan-x86_64 := $(UbsanFunctions) $(SanitizerCommonFunctions) +FUNCTIONS.ubsan-i386 := $(UbsanFunctions) +FUNCTIONS.ubsan-x86_64 := $(UbsanFunctions) +FUNCTIONS.ubsan_cxx-i386 := $(UbsanCXXFunctions) +FUNCTIONS.ubsan_cxx-x86_64 := $(UbsanCXXFunctions) # Always use optimized variants. OPTIMIZED := 1 |