Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -36,6 +36,10 @@ endif() endfunction() +if(COMPILER_RT_HAS_SANITIZER_COMMON) + add_subdirectory(sancov) +endif() + if(COMPILER_RT_BUILD_SANITIZERS) compiler_rt_build_runtime(interception) Index: lib/asan/CMakeLists.txt =================================================================== --- lib/asan/CMakeLists.txt +++ lib/asan/CMakeLists.txt @@ -118,6 +118,7 @@ RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTLSanCommon RTUbsan CFLAGS ${ASAN_DYNAMIC_CFLAGS} @@ -131,6 +132,7 @@ RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTLSanCommon RTUbsan) Index: lib/asan/tests/CMakeLists.txt =================================================================== --- lib/asan/tests/CMakeLists.txt +++ lib/asan/tests/CMakeLists.txt @@ -281,6 +281,7 @@ $ $ $ + $ $ $) else() @@ -290,6 +291,7 @@ $ $ $ + $ $ $ $) @@ -342,6 +344,7 @@ $ $ $ + $ $ $ ${COMPILER_RT_GTEST_SOURCE} Index: lib/cfi/CMakeLists.txt =================================================================== --- lib/cfi/CMakeLists.txt +++ lib/cfi/CMakeLists.txt @@ -20,6 +20,7 @@ OBJECT_LIBS RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc CFLAGS ${CFI_CFLAGS} PARENT_TARGET cfi) add_compiler_rt_runtime(clang_rt.cfi_diag @@ -29,6 +30,7 @@ OBJECT_LIBS RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTUbsan CFLAGS ${CFI_CFLAGS} ${CFI_DIAG_CFLAGS} PARENT_TARGET cfi) Index: lib/dfsan/CMakeLists.txt =================================================================== --- lib/dfsan/CMakeLists.txt +++ lib/dfsan/CMakeLists.txt @@ -23,6 +23,7 @@ $ $ $ + $ CFLAGS ${DFSAN_CFLAGS} PARENT_TARGET dfsan) add_sanitizer_rt_symbols(clang_rt.dfsan Index: lib/esan/CMakeLists.txt =================================================================== --- lib/esan/CMakeLists.txt +++ lib/esan/CMakeLists.txt @@ -26,6 +26,7 @@ $ $ $ + $ CFLAGS ${ESAN_RTL_CFLAGS}) add_sanitizer_rt_symbols(clang_rt.esan ARCHS ${arch} Index: lib/lsan/CMakeLists.txt =================================================================== --- lib/lsan/CMakeLists.txt +++ lib/lsan/CMakeLists.txt @@ -32,6 +32,7 @@ $ $ $ + $ $ CFLAGS ${LSAN_CFLAGS} PARENT_TARGET lsan) Index: lib/msan/CMakeLists.txt =================================================================== --- lib/msan/CMakeLists.txt +++ lib/msan/CMakeLists.txt @@ -35,6 +35,7 @@ $ $ $ + $ $ CFLAGS ${MSAN_RTL_CFLAGS} PARENT_TARGET msan) Index: lib/sancov/CMakeLists.txt =================================================================== --- /dev/null +++ lib/sancov/CMakeLists.txt @@ -0,0 +1,13 @@ +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(..) + Index: lib/sancov/sancov_flags.h =================================================================== --- lib/sancov/sancov_flags.h +++ 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 { Index: lib/sancov/sancov_flags.cc =================================================================== --- lib/sancov/sancov_flags.cc +++ 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. Index: lib/sancov/sanitizer_coverage_libcdep.cc =================================================================== --- lib/sancov/sanitizer_coverage_libcdep.cc +++ 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; Index: lib/sanitizer_common/CMakeLists.txt =================================================================== --- lib/sanitizer_common/CMakeLists.txt +++ lib/sanitizer_common/CMakeLists.txt @@ -52,9 +52,7 @@ 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 Index: lib/sanitizer_common/sancov_flags.inc =================================================================== --- /dev/null +++ lib/sanitizer_common/sancov_flags.inc @@ -1,21 +0,0 @@ -//===-- sancov_flags.inc ----------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Sanitizer Coverage runtime flags. -// -//===----------------------------------------------------------------------===// -#ifndef SANCOV_FLAG -#error "Defnine SANCOV_FLAG prior to including this file!" -#endif - -SANCOV_FLAG(bool, symbolize, true, - "If set, converage information will be symbolized by sancov tool " - "after dumping.") - -SANCOV_FLAG(bool, help, false, "Print flags help.") Index: lib/sanitizer_common/sanitizer_coverage_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_coverage_libcdep.cc +++ lib/sanitizer_common/sanitizer_coverage_libcdep.cc @@ -954,7 +954,9 @@ } 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, Index: lib/sanitizer_common/tests/CMakeLists.txt =================================================================== --- lib/sanitizer_common/tests/CMakeLists.txt +++ lib/sanitizer_common/tests/CMakeLists.txt @@ -200,7 +200,8 @@ 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 @@ 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 @@ ${SANITIZER_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE} $ - $) + $ + $) set_target_compile_flags(SanitizerTest ${SANITIZER_COMMON_CFLAGS} ${SANITIZER_TEST_CFLAGS_COMMON}) Index: lib/scudo/CMakeLists.txt =================================================================== --- lib/scudo/CMakeLists.txt +++ lib/scudo/CMakeLists.txt @@ -29,6 +29,7 @@ $ $ $ + $ CFLAGS ${SCUDO_CFLAGS} PARENT_TARGET scudo) endforeach() Index: lib/stats/CMakeLists.txt =================================================================== --- lib/stats/CMakeLists.txt +++ lib/stats/CMakeLists.txt @@ -22,6 +22,7 @@ SOURCES stats.cc OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc CFLAGS ${SANITIZER_COMMON_CFLAGS} LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET stats) Index: lib/tsan/CMakeLists.txt =================================================================== --- lib/tsan/CMakeLists.txt +++ lib/tsan/CMakeLists.txt @@ -119,6 +119,7 @@ OBJECT_LIBS RTInterception RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTUbsan CFLAGS ${TSAN_RTL_CFLAGS} LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} @@ -179,6 +180,7 @@ $ $ $ + $ $ CFLAGS ${TSAN_RTL_CFLAGS}) add_compiler_rt_runtime(clang_rt.tsan_cxx Index: lib/tsan/dd/CMakeLists.txt =================================================================== --- lib/tsan/dd/CMakeLists.txt +++ lib/tsan/dd/CMakeLists.txt @@ -26,6 +26,7 @@ $ $ $ + $ CFLAGS ${DD_CFLAGS} PARENT_TARGET dd) @@ -40,6 +41,7 @@ $ $ $ + $ LINK_LIBS ${DD_LINKLIBS} PARENT_TARGET dd) endif() Index: lib/tsan/tests/CMakeLists.txt =================================================================== --- lib/tsan/tests/CMakeLists.txt +++ lib/tsan/tests/CMakeLists.txt @@ -69,6 +69,7 @@ $ $ $ + $ $) set(TSAN_TEST_RUNTIME RTTsanTest.${testname}.${arch}) add_library(${TSAN_TEST_RUNTIME} STATIC ${TSAN_TEST_RUNTIME_OBJECTS}) Index: lib/ubsan/CMakeLists.txt =================================================================== --- lib/ubsan/CMakeLists.txt +++ lib/ubsan/CMakeLists.txt @@ -67,6 +67,7 @@ RTUbsan_standalone RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET ubsan) endif() @@ -102,6 +103,7 @@ ARCHS ${UBSAN_SUPPORTED_ARCH} OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc + RTSancovLibc RTUbsan RTUbsan_standalone CFLAGS ${UBSAN_CFLAGS} Index: lib/xray/CMakeLists.txt =================================================================== --- lib/xray/CMakeLists.txt +++ lib/xray/CMakeLists.txt @@ -51,7 +51,8 @@ set(XRAY_COMMON_RUNTIME_OBJECT_LIBS RTSanitizerCommon - RTSanitizerCommonLibc) + RTSanitizerCommonLibc + RTSancovLibc) foreach(arch ${XRAY_SUPPORTED_ARCH}) if(CAN_TARGET_${arch})