From 875572f358e30b05bd4834e57c99420887cd3392 Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Thu, 12 Jan 2017 01:19:34 +0000 Subject: [PATCH] [sancov] moving sancov rt to sancov/ directory Subscribers: kubabrecka, mgorny Differential Revision: https://reviews.llvm.org/D28541 llvm-svn: 291734 --- compiler-rt/lib/CMakeLists.txt | 4 ++++ compiler-rt/lib/asan/CMakeLists.txt | 2 ++ compiler-rt/lib/asan/tests/CMakeLists.txt | 3 +++ compiler-rt/lib/cfi/CMakeLists.txt | 2 ++ compiler-rt/lib/dfsan/CMakeLists.txt | 1 + compiler-rt/lib/esan/CMakeLists.txt | 1 + compiler-rt/lib/lsan/CMakeLists.txt | 1 + compiler-rt/lib/msan/CMakeLists.txt | 1 + compiler-rt/lib/sancov/CMakeLists.txt | 16 ++++++++++++++++ .../{sanitizer_common => sancov}/sancov_flags.cc | 4 ++-- .../{sanitizer_common => sancov}/sancov_flags.h | 4 ++-- .../sancov_flags.inc | 0 .../sanitizer_coverage_libcdep.cc} | 8 ++++---- compiler-rt/lib/sanitizer_common/CMakeLists.txt | 2 -- .../sanitizer_coverage_libcdep.cc | 2 ++ .../lib/sanitizer_common/tests/CMakeLists.txt | 9 ++++++--- compiler-rt/lib/scudo/CMakeLists.txt | 1 + compiler-rt/lib/stats/CMakeLists.txt | 1 + compiler-rt/lib/tsan/CMakeLists.txt | 2 ++ compiler-rt/lib/tsan/dd/CMakeLists.txt | 2 ++ compiler-rt/lib/tsan/tests/CMakeLists.txt | 1 + compiler-rt/lib/ubsan/CMakeLists.txt | 2 ++ compiler-rt/lib/xray/CMakeLists.txt | 3 ++- 23 files changed, 58 insertions(+), 14 deletions(-) create mode 100644 compiler-rt/lib/sancov/CMakeLists.txt rename compiler-rt/lib/{sanitizer_common => sancov}/sancov_flags.cc (94%) rename compiler-rt/lib/{sanitizer_common => sancov}/sancov_flags.h (90%) rename compiler-rt/lib/{sanitizer_common => sancov}/sancov_flags.inc (100%) rename compiler-rt/lib/{sanitizer_common/sanitizer_coverage_libcdep_new.cc => sancov/sanitizer_coverage_libcdep.cc} (96%) diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt index 4ab1e933af3a..461579068a10 100644 --- a/compiler-rt/lib/CMakeLists.txt +++ b/compiler-rt/lib/CMakeLists.txt @@ -36,6 +36,10 @@ function(compiler_rt_build_sanitizer sanitizer) endif() endfunction() +if(COMPILER_RT_HAS_SANITIZER_COMMON) + add_subdirectory(sancov) +endif() + if(COMPILER_RT_BUILD_SANITIZERS) compiler_rt_build_runtime(interception) diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt index 5ac5708a63d7..e265343ca62e 100644 --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -118,6 +118,7 @@ if(APPLE) RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTLSanCommon RTUbsan CFLAGS ${ASAN_DYNAMIC_CFLAGS} @@ -131,6 +132,7 @@ else() RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTLSanCommon RTUbsan) diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt index 8089d51efe68..0d53e0fee076 100644 --- a/compiler-rt/lib/asan/tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/tests/CMakeLists.txt @@ -281,6 +281,7 @@ macro(add_asan_tests_for_arch_and_kind arch kind) $ $ $ + $ $ $) else() @@ -290,6 +291,7 @@ macro(add_asan_tests_for_arch_and_kind arch kind) $ $ $ + $ $ $ $) @@ -342,6 +344,7 @@ if(ANDROID) $ $ $ + $ $ $ ${COMPILER_RT_GTEST_SOURCE} diff --git a/compiler-rt/lib/cfi/CMakeLists.txt b/compiler-rt/lib/cfi/CMakeLists.txt index 206400201466..cf0fb3e82694 100644 --- a/compiler-rt/lib/cfi/CMakeLists.txt +++ b/compiler-rt/lib/cfi/CMakeLists.txt @@ -20,6 +20,7 @@ foreach(arch ${CFI_SUPPORTED_ARCH}) OBJECT_LIBS RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc CFLAGS ${CFI_CFLAGS} PARENT_TARGET cfi) add_compiler_rt_runtime(clang_rt.cfi_diag @@ -29,6 +30,7 @@ foreach(arch ${CFI_SUPPORTED_ARCH}) OBJECT_LIBS RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTUbsan CFLAGS ${CFI_CFLAGS} ${CFI_DIAG_CFLAGS} PARENT_TARGET cfi) diff --git a/compiler-rt/lib/dfsan/CMakeLists.txt b/compiler-rt/lib/dfsan/CMakeLists.txt index 2c486bff821b..cf843410e42b 100644 --- a/compiler-rt/lib/dfsan/CMakeLists.txt +++ b/compiler-rt/lib/dfsan/CMakeLists.txt @@ -23,6 +23,7 @@ foreach(arch ${DFSAN_SUPPORTED_ARCH}) $ $ $ + $ CFLAGS ${DFSAN_CFLAGS} PARENT_TARGET dfsan) add_sanitizer_rt_symbols(clang_rt.dfsan diff --git a/compiler-rt/lib/esan/CMakeLists.txt b/compiler-rt/lib/esan/CMakeLists.txt index 2012ab642bf1..635f697dec6c 100644 --- a/compiler-rt/lib/esan/CMakeLists.txt +++ b/compiler-rt/lib/esan/CMakeLists.txt @@ -26,6 +26,7 @@ foreach (arch ${ESAN_SUPPORTED_ARCH}) $ $ $ + $ CFLAGS ${ESAN_RTL_CFLAGS}) add_sanitizer_rt_symbols(clang_rt.esan ARCHS ${arch} diff --git a/compiler-rt/lib/lsan/CMakeLists.txt b/compiler-rt/lib/lsan/CMakeLists.txt index b782f2421dc2..eb21003180bd 100644 --- a/compiler-rt/lib/lsan/CMakeLists.txt +++ b/compiler-rt/lib/lsan/CMakeLists.txt @@ -32,6 +32,7 @@ if(COMPILER_RT_HAS_LSAN) $ $ $ + $ $ CFLAGS ${LSAN_CFLAGS} PARENT_TARGET lsan) diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt index 598ae54588c1..d9492760d514 100644 --- a/compiler-rt/lib/msan/CMakeLists.txt +++ b/compiler-rt/lib/msan/CMakeLists.txt @@ -35,6 +35,7 @@ foreach(arch ${MSAN_SUPPORTED_ARCH}) $ $ $ + $ $ CFLAGS ${MSAN_RTL_CFLAGS} PARENT_TARGET msan) diff --git a/compiler-rt/lib/sancov/CMakeLists.txt b/compiler-rt/lib/sancov/CMakeLists.txt new file mode 100644 index 000000000000..6ad03508b87a --- /dev/null +++ b/compiler-rt/lib/sancov/CMakeLists.txt @@ -0,0 +1,16 @@ +set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS}) +append_rtti_flag(OFF SANITIZER_CFLAGS) + +set(SANCOV_LIBCDEP_SOURCES + sancov_flags.cc + sanitizer_coverage_libcdep.cc) + +add_compiler_rt_object_libraries(RTSancovLibc + ${OS_OPTION} + ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} + SOURCES ${SANCOV_LIBCDEP_SOURCES} + CFLAGS ${SANITIZER_CFLAGS} + DEFS ${SANITIZER_COMMON_DEFINITIONS}) + +include_directories(..) + diff --git a/compiler-rt/lib/sanitizer_common/sancov_flags.cc b/compiler-rt/lib/sancov/sancov_flags.cc similarity index 94% rename from compiler-rt/lib/sanitizer_common/sancov_flags.cc rename to compiler-rt/lib/sancov/sancov_flags.cc index 08fd2a4366a8..14473a3816cb 100644 --- a/compiler-rt/lib/sanitizer_common/sancov_flags.cc +++ b/compiler-rt/lib/sancov/sancov_flags.cc @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "sancov_flags.h" -#include "sanitizer_flag_parser.h" -#include "sanitizer_platform.h" +#include "sanitizer_common/sanitizer_flag_parser.h" +#include "sanitizer_common/sanitizer_platform.h" #if !SANITIZER_LINUX // other platforms do not have weak symbols out of the box. diff --git a/compiler-rt/lib/sanitizer_common/sancov_flags.h b/compiler-rt/lib/sancov/sancov_flags.h similarity index 90% rename from compiler-rt/lib/sanitizer_common/sancov_flags.h rename to compiler-rt/lib/sancov/sancov_flags.h index 5fbd7ad06a95..3fe17dbf29e7 100644 --- a/compiler-rt/lib/sanitizer_common/sancov_flags.h +++ b/compiler-rt/lib/sancov/sancov_flags.h @@ -13,8 +13,8 @@ #ifndef SANCOV_FLAGS_H #define SANCOV_FLAGS_H -#include "sanitizer_flag_parser.h" -#include "sanitizer_internal_defs.h" +#include "sanitizer_common/sanitizer_flag_parser.h" +#include "sanitizer_common/sanitizer_internal_defs.h" namespace __sancov { diff --git a/compiler-rt/lib/sanitizer_common/sancov_flags.inc b/compiler-rt/lib/sancov/sancov_flags.inc similarity index 100% rename from compiler-rt/lib/sanitizer_common/sancov_flags.inc rename to compiler-rt/lib/sancov/sancov_flags.inc diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc b/compiler-rt/lib/sancov/sanitizer_coverage_libcdep.cc similarity index 96% rename from compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc rename to compiler-rt/lib/sancov/sanitizer_coverage_libcdep.cc index df6d10f81762..92026bae057a 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc +++ b/compiler-rt/lib/sancov/sanitizer_coverage_libcdep.cc @@ -9,10 +9,10 @@ // Sanitizer Coverage Controller for Trace PC Guard. #include "sancov_flags.h" -#include "sanitizer_allocator_internal.h" -#include "sanitizer_atomic.h" -#include "sanitizer_common.h" -#include "sanitizer_symbolizer.h" +#include "sanitizer_common/sanitizer_allocator_internal.h" +#include "sanitizer_common/sanitizer_atomic.h" +#include "sanitizer_common/sanitizer_common.h" +#include "sanitizer_common/sanitizer_symbolizer.h" using namespace __sanitizer; diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt index c70b8be6d8e2..007d93cc1687 100644 --- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt @@ -52,9 +52,7 @@ set(SANITIZER_NOLIBC_SOURCES set(SANITIZER_LIBCDEP_SOURCES sanitizer_common_libcdep.cc - sancov_flags.cc sanitizer_coverage_libcdep.cc - sanitizer_coverage_libcdep_new.cc sanitizer_coverage_mapping_libcdep.cc sanitizer_linux_libcdep.cc sanitizer_posix_libcdep.cc diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc index ebdee33d7d5b..5945ebbe90b2 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc @@ -954,7 +954,9 @@ SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_init() { } SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump() { coverage_data.DumpAll(); +#if SANITIZER_LINUX __sanitizer_dump_trace_pc_guard_coverage(); +#endif } SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_module_init(s32 *guards, uptr npcs, u8 *counters, diff --git a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt index 20698b9a8a96..f03b5a15c5a3 100644 --- a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt @@ -200,7 +200,8 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID) if(APPLE) add_sanitizer_common_lib("RTSanitizerCommon.test.osx" $ - $) + $ + $) else() if(CAN_TARGET_x86_64) add_sanitizer_common_lib("RTSanitizerCommon.test.nolibc.x86_64" @@ -210,7 +211,8 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID) foreach(arch ${SANITIZER_UNITTEST_SUPPORTED_ARCH}) add_sanitizer_common_lib("RTSanitizerCommon.test.${arch}" $ - $) + $ + $) endforeach() endif() foreach(arch ${SANITIZER_UNITTEST_SUPPORTED_ARCH}) @@ -224,7 +226,8 @@ if(ANDROID) ${SANITIZER_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE} $ - $) + $ + $) set_target_compile_flags(SanitizerTest ${SANITIZER_COMMON_CFLAGS} ${SANITIZER_TEST_CFLAGS_COMMON}) diff --git a/compiler-rt/lib/scudo/CMakeLists.txt b/compiler-rt/lib/scudo/CMakeLists.txt index 4f1acec78c8f..7a386811a462 100644 --- a/compiler-rt/lib/scudo/CMakeLists.txt +++ b/compiler-rt/lib/scudo/CMakeLists.txt @@ -29,6 +29,7 @@ if(COMPILER_RT_HAS_SCUDO) $ $ $ + $ CFLAGS ${SCUDO_CFLAGS} PARENT_TARGET scudo) endforeach() diff --git a/compiler-rt/lib/stats/CMakeLists.txt b/compiler-rt/lib/stats/CMakeLists.txt index 2b3d6474bb76..27f5fa0f15c6 100644 --- a/compiler-rt/lib/stats/CMakeLists.txt +++ b/compiler-rt/lib/stats/CMakeLists.txt @@ -22,6 +22,7 @@ add_compiler_rt_runtime(clang_rt.stats SOURCES stats.cc OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc CFLAGS ${SANITIZER_COMMON_CFLAGS} LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET stats) diff --git a/compiler-rt/lib/tsan/CMakeLists.txt b/compiler-rt/lib/tsan/CMakeLists.txt index d5195459656c..c0bb480833bb 100644 --- a/compiler-rt/lib/tsan/CMakeLists.txt +++ b/compiler-rt/lib/tsan/CMakeLists.txt @@ -119,6 +119,7 @@ if(APPLE) OBJECT_LIBS RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTUbsan CFLAGS ${TSAN_RTL_CFLAGS} LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} @@ -179,6 +180,7 @@ else() $ $ $ + $ $ CFLAGS ${TSAN_RTL_CFLAGS}) add_compiler_rt_runtime(clang_rt.tsan_cxx diff --git a/compiler-rt/lib/tsan/dd/CMakeLists.txt b/compiler-rt/lib/tsan/dd/CMakeLists.txt index bcff35f20b36..be862d51c0a1 100644 --- a/compiler-rt/lib/tsan/dd/CMakeLists.txt +++ b/compiler-rt/lib/tsan/dd/CMakeLists.txt @@ -26,6 +26,7 @@ if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE AND NOT ANDROID) $ $ $ + $ CFLAGS ${DD_CFLAGS} PARENT_TARGET dd) @@ -40,6 +41,7 @@ if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE AND NOT ANDROID) $ $ $ + $ LINK_LIBS ${DD_LINKLIBS} PARENT_TARGET dd) endif() diff --git a/compiler-rt/lib/tsan/tests/CMakeLists.txt b/compiler-rt/lib/tsan/tests/CMakeLists.txt index 87e14174ad1f..d972f54de531 100644 --- a/compiler-rt/lib/tsan/tests/CMakeLists.txt +++ b/compiler-rt/lib/tsan/tests/CMakeLists.txt @@ -69,6 +69,7 @@ macro(add_tsan_unittest testname) $ $ $ + $ $) set(TSAN_TEST_RUNTIME RTTsanTest.${testname}.${arch}) 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 9bb36edc72cf..e3ad52eb9105 100644 --- a/compiler-rt/lib/ubsan/CMakeLists.txt +++ b/compiler-rt/lib/ubsan/CMakeLists.txt @@ -67,6 +67,7 @@ if(APPLE) RTUbsan_standalone RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET ubsan) endif() @@ -102,6 +103,7 @@ else() ARCHS ${UBSAN_SUPPORTED_ARCH} OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTUbsan RTUbsan_standalone CFLAGS ${UBSAN_CFLAGS} diff --git a/compiler-rt/lib/xray/CMakeLists.txt b/compiler-rt/lib/xray/CMakeLists.txt index 9c7cf6ce361c..fc1e0909f3ed 100644 --- a/compiler-rt/lib/xray/CMakeLists.txt +++ b/compiler-rt/lib/xray/CMakeLists.txt @@ -51,7 +51,8 @@ add_compiler_rt_component(xray-fdr) set(XRAY_COMMON_RUNTIME_OBJECT_LIBS RTSanitizerCommon - RTSanitizerCommonLibc) + RTSanitizerCommonLibc + RTSancovLibc) foreach(arch ${XRAY_SUPPORTED_ARCH}) if(CAN_TARGET_${arch})