Index: lib/sanitizer_common/CMakeLists.txt =================================================================== --- lib/sanitizer_common/CMakeLists.txt +++ lib/sanitizer_common/CMakeLists.txt @@ -77,6 +77,27 @@ sanitizer_symbolizer_posix_libcdep.cc sanitizer_unwind_linux_libcdep.cc) +set(SANITIZER_SCUDO_SOURCES + sanitizer_allocator.cc + sanitizer_allocator_checks.cc + sanitizer_common.cc + sanitizer_common_libcdep.cc + sanitizer_errno.cc + sanitizer_file.cc + sanitizer_flags.cc + sanitizer_flag_parser.cc + sanitizer_fuchsia.cc + sanitizer_libc.cc + sanitizer_linux.cc + sanitizer_linux_libcdep.cc + sanitizer_platform_limits_linux.cc + sanitizer_platform_limits_posix.cc + sanitizer_posix.cc + sanitizer_posix_libcdep.cc + sanitizer_printf.cc + sanitizer_procmaps_common.cc + sanitizer_procmaps_linux.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 +229,12 @@ SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS} DEFS ${SANITIZER_COMMON_DEFINITIONS}) +add_compiler_rt_object_libraries(RTSanitizerCommonScudo + ${OS_OPTION} + ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} + SOURCES ${SANITIZER_SCUDO_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") Index: lib/scudo/CMakeLists.txt =================================================================== --- lib/scudo/CMakeLists.txt +++ lib/scudo/CMakeLists.txt @@ -18,6 +18,7 @@ scudo_crc32.cpp scudo_flags.cpp scudo_malloc.cpp + scudo_override.cpp scudo_termination.cpp scudo_tsd_exclusive.cpp scudo_tsd_shared.cpp @@ -38,8 +39,7 @@ endif() if(COMPILER_RT_HAS_SCUDO) - set(SCUDO_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY} - ${SANITIZER_COMMON_LINK_LIBS}) + set(SCUDO_DYNAMIC_LIBS ${SANITIZER_COMMON_LINK_LIBS}) append_list_if(COMPILER_RT_HAS_LIBDL dl SCUDO_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBRT rt SCUDO_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread SCUDO_DYNAMIC_LIBS) @@ -75,6 +75,17 @@ RTUbsan_cxx CFLAGS ${SCUDO_CFLAGS} LINK_FLAGS ${SCUDO_DYNAMIC_LINK_FLAGS} + LINK_LIBS ${SCUDO_DYNAMIC_LIBS} ${SANITIZER_CXX_ABI_LIBRARY} + PARENT_TARGET scudo) + + add_compiler_rt_runtime(clang_rt.scudo_minimal + SHARED + ARCHS ${SCUDO_SUPPORTED_ARCH} + SOURCES ${SCUDO_SOURCES} ${SCUDO_CXX_SOURCES} + OBJECT_LIBS RTSanitizerCommonScudo + RTInterception + CFLAGS ${SCUDO_CFLAGS} + LINK_FLAGS ${SCUDO_DYNAMIC_LINK_FLAGS} LINK_LIBS ${SCUDO_DYNAMIC_LIBS} PARENT_TARGET scudo) endif() Index: lib/scudo/scudo_override.cpp =================================================================== --- /dev/null +++ lib/scudo/scudo_override.cpp @@ -0,0 +1,26 @@ +//===-- scudo_override.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// Strong definitions for some sanitizer_common weak interface functions that +/// Scudo doesn't need and that end up pulling a whole lot of dependencies in. +/// +//===----------------------------------------------------------------------===// + +#include "sanitizer_common/sanitizer_internal_defs.h" + +extern "C" { +typedef struct { + int coverage_sandboxed; + __sanitizer::sptr coverage_fd; + unsigned int coverage_max_block_size; +} __sanitizer_sandbox_arguments; + +SANITIZER_INTERFACE_ATTRIBUTE +void __sanitizer_sandbox_on_notify(__sanitizer_sandbox_arguments *args) {} +}