diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2018-03-22 15:04:31 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2018-03-22 15:04:31 +0000 |
commit | 988fab3f66efb04310b703d7028267dbf59adf01 (patch) | |
tree | 09ff98406698aa9d2d2a3821d16696a60a01a76a | |
parent | 53b2c3329a1cd8d8806afb3ec74648641e606f7b (diff) | |
download | bcm5719-llvm-988fab3f66efb04310b703d7028267dbf59adf01.tar.gz bcm5719-llvm-988fab3f66efb04310b703d7028267dbf59adf01.zip |
[sanitizer] Split coverage into separate RT in sanitizer_common
Summary:
`sanitizer_common`'s coverage support is fairly well separated, and libcdep by
default. Several sanitizers don't make use of coverage, and as far as I can
tell do no benefit from the extra dependencies pulled in by the coverage public
interface functions.
The following sanitizers call `InitializeCoverage` explicitely: MSan, ASan,
LSan, HWAsan, UBSan. On top of this, any sanitizer bundling RTUBSan should
add the coverage RT as well: ASan, Scudo, UBSan, CFI (diag), TSan, MSan, HWAsan.
So in the end the following have no need: DFSan, ESan, CFI, SafeStack (nolibc
anyway), XRay, and the upcoming Scudo minimal runtime.
I tested this with all the sanitizers check-* with gcc & clang, and in
standalone on Linux & Android, and there was no issue. I couldn't test this on
Mac, Fuchsia, BSDs, & Windows for lack of an environment, so adding a bunch of
people for additional scrunity. I couldn't test HWAsan either.
Reviewers: eugenis, vitalybuka, alekseyshl, flowerhack, kubamracek, dberris, rnk, krytarowski
Reviewed By: vitalybuka, alekseyshl, flowerhack, dberris
Subscribers: mgorny, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D44701
llvm-svn: 328204
-rw-r--r-- | compiler-rt/lib/asan/CMakeLists.txt | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | compiler-rt/lib/cfi/CMakeLists.txt | 1 | ||||
-rw-r--r-- | compiler-rt/lib/hwasan/CMakeLists.txt | 6 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/CMakeLists.txt | 2 | ||||
-rw-r--r-- | compiler-rt/lib/msan/CMakeLists.txt | 1 | ||||
-rw-r--r-- | compiler-rt/lib/sanitizer_common/CMakeLists.txt | 16 | ||||
-rw-r--r-- | compiler-rt/lib/scudo/CMakeLists.txt | 2 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/CMakeLists.txt | 2 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | compiler-rt/lib/ubsan/CMakeLists.txt | 4 |
11 files changed, 34 insertions, 6 deletions
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt index fbd72f69298..31747adfcbc 100644 --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -125,6 +125,7 @@ if(APPLE) RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTLSanCommon RTUbsan CFLAGS ${ASAN_DYNAMIC_CFLAGS} @@ -138,6 +139,7 @@ else() RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTLSanCommon RTUbsan) diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt index 7c2cf5b1b57..3b1ceddc11a 100644 --- a/compiler-rt/lib/asan/tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/tests/CMakeLists.txt @@ -251,6 +251,7 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID) $<TARGET_OBJECTS:RTInterception.osx> $<TARGET_OBJECTS:RTSanitizerCommon.osx> $<TARGET_OBJECTS:RTSanitizerCommonLibc.osx> + $<TARGET_OBJECTS:RTSanitizerCommonCoverage.osx> $<TARGET_OBJECTS:RTLSanCommon.osx> $<TARGET_OBJECTS:RTUbsan.osx>) else() @@ -260,6 +261,7 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID) $<TARGET_OBJECTS:RTInterception.${arch}> $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> + $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}> $<TARGET_OBJECTS:RTLSanCommon.${arch}> $<TARGET_OBJECTS:RTUbsan.${arch}> $<TARGET_OBJECTS:RTUbsan_cxx.${arch}>) @@ -283,6 +285,7 @@ if(ANDROID) $<TARGET_OBJECTS:RTInterception.${arch}> $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> + $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}> $<TARGET_OBJECTS:RTUbsan.${arch}> $<TARGET_OBJECTS:RTUbsan_cxx.${arch}> ${COMPILER_RT_GTEST_SOURCE} diff --git a/compiler-rt/lib/cfi/CMakeLists.txt b/compiler-rt/lib/cfi/CMakeLists.txt index 6c531445626..934f1211867 100644 --- a/compiler-rt/lib/cfi/CMakeLists.txt +++ b/compiler-rt/lib/cfi/CMakeLists.txt @@ -30,6 +30,7 @@ if(OS_NAME MATCHES "Linux") OBJECT_LIBS RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTUbsan CFLAGS ${CFI_CFLAGS} ${CFI_DIAG_CFLAGS} PARENT_TARGET cfi) diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt index 15013c09cdf..34f5f15b9f2 100644 --- a/compiler-rt/lib/hwasan/CMakeLists.txt +++ b/compiler-rt/lib/hwasan/CMakeLists.txt @@ -78,7 +78,8 @@ foreach(arch ${HWASAN_SUPPORTED_ARCH}) RTInterception RTSanitizerCommon RTSanitizerCommonLibc - RTUbsan + RTSanitizerCommonCoverage + RTUbsan CFLAGS ${HWASAN_RTL_CFLAGS} PARENT_TARGET hwasan) add_compiler_rt_runtime(clang_rt.hwasan_cxx @@ -112,7 +113,8 @@ foreach(arch ${HWASAN_SUPPORTED_ARCH}) RTInterception RTSanitizerCommon RTSanitizerCommonLibc - RTUbsan + RTSanitizerCommonCoverage + RTUbsan # The only purpose of RTHWAsan_dynamic_version_script_dummy is to # carry a dependency of the shared runtime on the version script. # Replacing it with a straightforward diff --git a/compiler-rt/lib/lsan/CMakeLists.txt b/compiler-rt/lib/lsan/CMakeLists.txt index 60da3e18687..86b2bc1e3ad 100644 --- a/compiler-rt/lib/lsan/CMakeLists.txt +++ b/compiler-rt/lib/lsan/CMakeLists.txt @@ -43,6 +43,7 @@ if(COMPILER_RT_HAS_LSAN) RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSanitizerCommonCoverage CFLAGS ${LSAN_CFLAGS} LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS} LINK_LIBS ${LSAN_LINK_LIBS} @@ -56,6 +57,7 @@ if(COMPILER_RT_HAS_LSAN) $<TARGET_OBJECTS:RTInterception.${arch}> $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> + $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}> $<TARGET_OBJECTS:RTLSanCommon.${arch}> CFLAGS ${LSAN_CFLAGS} PARENT_TARGET lsan) diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt index 61c7bd7e58b..ebe0b64d176 100644 --- a/compiler-rt/lib/msan/CMakeLists.txt +++ b/compiler-rt/lib/msan/CMakeLists.txt @@ -40,6 +40,7 @@ foreach(arch ${MSAN_SUPPORTED_ARCH}) $<TARGET_OBJECTS:RTInterception.${arch}> $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> + $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}> $<TARGET_OBJECTS:RTUbsan.${arch}> CFLAGS ${MSAN_RTL_CFLAGS} PARENT_TARGET msan) diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt index ca82458887c..563dca3f720 100644 --- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt @@ -64,10 +64,6 @@ set(SANITIZER_NOLIBC_SOURCES set(SANITIZER_LIBCDEP_SOURCES sanitizer_common_libcdep.cc sanitizer_allocator_checks.cc - sancov_flags.cc - sanitizer_coverage_fuchsia.cc - sanitizer_coverage_libcdep_new.cc - sanitizer_coverage_win_sections.cc sanitizer_linux_libcdep.cc sanitizer_mac_libcdep.cc sanitizer_posix_libcdep.cc @@ -77,6 +73,12 @@ set(SANITIZER_LIBCDEP_SOURCES sanitizer_symbolizer_posix_libcdep.cc sanitizer_unwind_linux_libcdep.cc) +set(SANITIZER_COVERAGE_SOURCES + sancov_flags.cc + sanitizer_coverage_fuchsia.cc + sanitizer_coverage_libcdep_new.cc + sanitizer_coverage_win_sections.cc) + # Explicitly list all sanitizer_common headers. Not all of these are # included in sanitizer_common source files, but we need to depend on # headers when building our custom unit tests. @@ -208,6 +210,12 @@ add_compiler_rt_object_libraries(RTSanitizerCommonLibc SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS} DEFS ${SANITIZER_COMMON_DEFINITIONS}) +add_compiler_rt_object_libraries(RTSanitizerCommonCoverage + ${OS_OPTION} + ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} + SOURCES ${SANITIZER_COVERAGE_SOURCES} + CFLAGS ${SANITIZER_CFLAGS} + DEFS ${SANITIZER_COMMON_DEFINITIONS}) set(SANITIZER_NO_WEAK_HOOKS_CFLAGS ${SANITIZER_CFLAGS}) list(APPEND SANITIZER_NO_WEAK_HOOKS_CFLAGS "-DSANITIZER_SUPPORTS_WEAK_HOOKS=0") diff --git a/compiler-rt/lib/scudo/CMakeLists.txt b/compiler-rt/lib/scudo/CMakeLists.txt index 0aba0cad1b7..97a26fa4230 100644 --- a/compiler-rt/lib/scudo/CMakeLists.txt +++ b/compiler-rt/lib/scudo/CMakeLists.txt @@ -51,6 +51,7 @@ if(COMPILER_RT_HAS_SCUDO) SOURCES ${SCUDO_SOURCES} OBJECT_LIBS RTSanitizerCommonNoTermination RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTInterception RTUbsan CFLAGS ${SCUDO_CFLAGS} @@ -70,6 +71,7 @@ if(COMPILER_RT_HAS_SCUDO) SOURCES ${SCUDO_SOURCES} ${SCUDO_CXX_SOURCES} OBJECT_LIBS RTSanitizerCommonNoTermination RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTInterception RTUbsan RTUbsan_cxx diff --git a/compiler-rt/lib/tsan/CMakeLists.txt b/compiler-rt/lib/tsan/CMakeLists.txt index 11ec9d8cff8..9dbd6e9204f 100644 --- a/compiler-rt/lib/tsan/CMakeLists.txt +++ b/compiler-rt/lib/tsan/CMakeLists.txt @@ -114,6 +114,7 @@ if(APPLE) OBJECT_LIBS RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTUbsan CFLAGS ${TSAN_RTL_CFLAGS} LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS} @@ -163,6 +164,7 @@ else() $<TARGET_OBJECTS:RTInterception.${arch}> $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> + $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}> $<TARGET_OBJECTS:RTUbsan.${arch}> CFLAGS ${TSAN_RTL_CFLAGS} PARENT_TARGET tsan) diff --git a/compiler-rt/lib/tsan/tests/CMakeLists.txt b/compiler-rt/lib/tsan/tests/CMakeLists.txt index ad8d02ed331..a451febef18 100644 --- a/compiler-rt/lib/tsan/tests/CMakeLists.txt +++ b/compiler-rt/lib/tsan/tests/CMakeLists.txt @@ -22,6 +22,7 @@ if(APPLE) $<TARGET_OBJECTS:RTInterception.osx> $<TARGET_OBJECTS:RTSanitizerCommon.osx> $<TARGET_OBJECTS:RTSanitizerCommonLibc.osx> + $<TARGET_OBJECTS:RTSanitizerCommonCoverage.osx> $<TARGET_OBJECTS:RTUbsan.osx>) set(TSAN_TEST_RUNTIME RTTsanTest) add_library(${TSAN_TEST_RUNTIME} STATIC ${TSAN_TEST_RUNTIME_OBJECTS}) diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt index 911bd3ebc6b..04618030ecc 100644 --- a/compiler-rt/lib/ubsan/CMakeLists.txt +++ b/compiler-rt/lib/ubsan/CMakeLists.txt @@ -76,6 +76,7 @@ if(APPLE) RTUbsan_standalone RTSanitizerCommon RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTInterception LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET ubsan) @@ -88,6 +89,7 @@ if(APPLE) RTUbsan_standalone RTSanitizerCommonNoHooks RTSanitizerCommonLibcNoHooks + RTSanitizerCommonCoverage RTInterception LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET ubsan) @@ -154,6 +156,7 @@ else() SOURCES ubsan_init_standalone_preinit.cc OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTUbsan RTUbsan_standalone RTInterception @@ -173,6 +176,7 @@ else() ARCHS ${UBSAN_SUPPORTED_ARCH} OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc + RTSanitizerCommonCoverage RTUbsan RTUbsan_cxx RTUbsan_standalone |