llvm-project/compiler-rt/lib/sanitizer_common/CMakeLists.txt

321 lines
11 KiB
CMake
Raw Normal View History

# Build system for the common Sanitizer runtime support library components.
# These components are shared between AddressSanitizer and ThreadSanitizer.
set(SANITIZER_SOURCES_NOTERMINATION
sanitizer_allocator.cc
sanitizer_common.cc
sanitizer_deadlock_detector1.cc
sanitizer_deadlock_detector2.cc
sanitizer_errno.cc
sanitizer_file.cc
sanitizer_flags.cc
sanitizer_flag_parser.cc
sanitizer_fuchsia.cc
sanitizer_libc.cc
sanitizer_libignore.cc
sanitizer_linux.cc
sanitizer_linux_s390.cc
sanitizer_mac.cc
sanitizer_openbsd.cc
sanitizer_persistent_allocator.cc
sanitizer_platform_limits_linux.cc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_openbsd.cc
sanitizer_platform_limits_posix.cc
sanitizer_platform_limits_solaris.cc
sanitizer_posix.cc
sanitizer_printf.cc
sanitizer_procmaps_common.cc
sanitizer_procmaps_bsd.cc
sanitizer_procmaps_linux.cc
sanitizer_procmaps_mac.cc
sanitizer_procmaps_solaris.cc
sanitizer_solaris.cc
sanitizer_stackdepot.cc
sanitizer_stacktrace.cc
sanitizer_stacktrace_printer.cc
sanitizer_stoptheworld_mac.cc
sanitizer_suppressions.cc
sanitizer_symbolizer.cc
sanitizer_symbolizer_fuchsia.cc
sanitizer_symbolizer_libbacktrace.cc
sanitizer_symbolizer_mac.cc
sanitizer_symbolizer_win.cc
sanitizer_tls_get_addr.cc
sanitizer_thread_registry.cc
sanitizer_win.cc)
if(UNIX AND NOT APPLE AND NOT OS_NAME MATCHES "SunOS")
list(APPEND SANITIZER_SOURCES_NOTERMINATION
sanitizer_linux_x86_64.S)
list(APPEND SANITIZER_SOURCES_NOTERMINATION
sanitizer_linux_mips64.S)
endif()
set(SANITIZER_SOURCES
${SANITIZER_SOURCES_NOTERMINATION} sanitizer_termination.cc)
# Libc functions stubs. These sources should be linked instead of
# SANITIZER_LIBCDEP_SOURCES when sanitizer_common library must not depend on
# libc.
set(SANITIZER_NOLIBC_SOURCES
sanitizer_common_nolibc.cc)
set(SANITIZER_LIBCDEP_SOURCES
sanitizer_common_libcdep.cc
sanitizer_allocator_checks.cc
sanitizer_linux_libcdep.cc
sanitizer_mac_libcdep.cc
sanitizer_posix_libcdep.cc
sanitizer_stacktrace_libcdep.cc
sanitizer_stoptheworld_linux_libcdep.cc
sanitizer_symbolizer_libcdep.cc
sanitizer_symbolizer_posix_libcdep.cc
sanitizer_unwind_linux_libcdep.cc
sanitizer_unwind_win.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.
set(SANITIZER_HEADERS
sanitizer_addrhashmap.h
sanitizer_allocator.h
sanitizer_allocator_bytemap.h
sanitizer_allocator_combined.h
sanitizer_allocator_interface.h
sanitizer_allocator_internal.h
sanitizer_allocator_local_cache.h
sanitizer_allocator_primary32.h
sanitizer_allocator_primary64.h
sanitizer_allocator_secondary.h
sanitizer_allocator_size_class_map.h
sanitizer_allocator_stats.h
sanitizer_atomic.h
sanitizer_atomic_clang.h
sanitizer_atomic_msvc.h
sanitizer_bitvector.h
sanitizer_bvgraph.h
sanitizer_common.h
sanitizer_common_interceptors.inc
sanitizer_common_interceptors_ioctl.inc
sanitizer_common_interceptors_format.inc
sanitizer_common_syscalls.inc
sanitizer_deadlock_detector.h
sanitizer_deadlock_detector_interface.h
sanitizer_errno.h
sanitizer_errno_codes.h
sanitizer_file.h
sanitizer_flag_parser.h
sanitizer_flags.h
sanitizer_flags.inc
sanitizer_fuchsia.h
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_interface_internal.h
sanitizer_internal_defs.h
sanitizer_lfstack.h
sanitizer_libc.h
sanitizer_libignore.h
sanitizer_linux.h
sanitizer_list.h
sanitizer_mac.h
sanitizer_mutex.h
sanitizer_persistent_allocator.h
sanitizer_placement_new.h
sanitizer_platform.h
sanitizer_platform_interceptors.h
sanitizer_platform_limits_netbsd.h
sanitizer_platform_limits_posix.h
sanitizer_platform_limits_solaris.h
sanitizer_posix.h
sanitizer_procmaps.h
sanitizer_quarantine.h
sanitizer_report_decorator.h
sanitizer_stackdepot.h
sanitizer_stackdepotbase.h
sanitizer_stacktrace.h
sanitizer_stacktrace_printer.h
sanitizer_stoptheworld.h
sanitizer_suppressions.h
sanitizer_symbolizer.h
sanitizer_symbolizer_internal.h
sanitizer_symbolizer_libbacktrace.h
sanitizer_symbolizer_mac.h
sanitizer_syscall_generic.inc
sanitizer_syscall_linux_x86_64.inc
sanitizer_syscall_linux_aarch64.inc
sanitizer_syscalls_netbsd.inc
sanitizer_thread_registry.h
sanitizer_vector.h
sanitizer_win.h)
[sanitizer] Split dll_thunks into different sanitizers. When the sanitizer is implemented as a static library and is included in the main executable, we need an auxiliary static library dll_thunk that will be linked to the dlls that have instrumentation, so they can refer to the runtime in the main executable. Basically, it uses interception to get a pointer the function in the main executable and override its function with that pointer. Before this diff, all of the implementation for dll_thunks was included in asan. In this diff I split it into different sanitizers, so we can use other sanitizers regardless of whether we include asan or not. All the sanitizers include a file sanitizer_win_dll_thunk.cc that register functions to be intercepted in the binary section: DLLTH When the dll including dll_thunk is initialized, it will execute __dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc, which will consider all the CB registered in the section DLLTH. So, all the functions registered will be intercepted, and redirected to the implementation in the main executable. All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan, ubsan and sanitizer coverage in the address sanitizer library. Differential Revision: https://reviews.llvm.org/D29154 llvm-svn: 293951
2017-02-03 07:01:28 +08:00
include_directories(..)
set(SANITIZER_COMMON_DEFINITIONS)
include(CheckIncludeFile)
append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
append_rtti_flag(OFF SANITIZER_CFLAGS)
append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570
SANITIZER_CFLAGS)
append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
SANITIZER_CFLAGS)
if (LLVM_ENABLE_PEDANTIC AND UNIX AND NOT APPLE)
# With -pedantic, our .S files raise warnings about empty macro arguments
# from __USER_LABEL_PREFIX__ being an empty arg to GLUE(). Unfortunately,
# there is no simple way to test for an empty define, nor to disable just
# that warning or to disable -pedantic. There is also no simple way to
# remove -pedantic from just this file (we'd have to remove from
# CMAKE_C*_FLAGS and re-add as a source property to all the non-.S files).
set_source_files_properties(sanitizer_linux_x86_64.S
PROPERTIES COMPILE_FLAGS "-w")
set_source_files_properties(sanitizer_linux_mips64.S
PROPERTIES COMPILE_FLAGS "-w")
endif ()
if(APPLE)
set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS})
endif()
add_compiler_rt_object_libraries(RTSanitizerCommon
${OS_OPTION}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES ${SANITIZER_SOURCES}
CFLAGS ${SANITIZER_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_object_libraries(RTSanitizerCommonNoTermination
${OS_OPTION}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES ${SANITIZER_SOURCES_NOTERMINATION}
CFLAGS ${SANITIZER_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_object_libraries(RTSanitizerCommonNoLibc
${OS_OPTION}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES ${SANITIZER_NOLIBC_SOURCES}
CFLAGS ${SANITIZER_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_object_libraries(RTSanitizerCommonLibc
${OS_OPTION}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
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")
add_compiler_rt_object_libraries(RTSanitizerCommonNoHooks
${OS_OPTION}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES ${SANITIZER_SOURCES}
CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_object_libraries(RTSanitizerCommonLibcNoHooks
${OS_OPTION}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES ${SANITIZER_LIBCDEP_SOURCES}
CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
if(OS_NAME MATCHES "SunOS")
# Solaris ld doesn't support the non-standard GNU ld extension of adding
# __start_SECNAME and __stop_SECNAME labels to sections whose names are
# valid C identifiers. Instead we add our own definitions for the
# __sancov_guards section.
add_compiler_rt_object_libraries(SancovBegin
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sancov_begin.S
CFLAGS ${SANITIZER_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_runtime(clang_rt.sancov_begin
STATIC
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
OBJECT_LIBS SancovBegin
CFLAGS ${SANITIZER_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_object_libraries(SancovEnd
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sancov_end.S
CFLAGS ${SANITIZER_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_runtime(clang_rt.sancov_end
STATIC
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
OBJECT_LIBS SancovEnd
CFLAGS ${SANITIZER_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
endif()
if(WIN32)
[sanitizer] Use interception to access to strong definitions in the executable. In Windows, when sanitizers are implemented as a shared library (DLL), users can redefine and export a new definition for weak functions, in the main executable, for example: extern "C" __declspec(dllexport) void __sanitizer_cov_trace_pc_guard(u32* guard) { // Different implementation provided by the client. } However, other dlls, will continue using the default implementation imported from the sanitizer dll. This is different in linux, where all the shared libraries will consider the strong definition. With the implementation in this diff, when the dll is initialized, it will check if the main executable exports the definition for some weak function (for example __sanitizer_cov_trace_pc_guard). If it finds that function, then it will override the function in the dll with that pointer. So, all the dlls with instrumentation that import __sanitizer_cov_trace_pc_guard__dll() from asan dll, will be using the function provided by the main executable. In other words, when the main executable exports a strong definition for a weak function, we ensure all the dlls use that implementation instead of the default weak implementation. The behavior is similar to linux. Now, every user that want to override a weak function, only has to define and export it. The same for Linux and Windows, and it will work fine. So, there is no difference on the user's side. All the sanitizers will include a file sanitizer_win_weak_interception.cc that register sanitizer's weak functions to be intercepted in the binary section WEAK When the sanitizer dll is initialized, it will execute weak_intercept_init() which will consider all the CB registered in the section WEAK. So, for all the weak functions registered, we will check if a strong definition is provided in the main executable. All the files sanitizer_win_weak_interception.cc are independent, so we do not need to include a specific list of sanitizers. Now, we include [asan|ubsan|sanitizer_coverage]_win_weak_interception.cc and sanitizer_win_weak_interception.cc in asan dll, so when it is initialized, it will consider all the weak functions from asan, ubsan and sanitizer coverage. After this diff, sanitizer coverage is fixed for MD on Windows. In particular libFuzzer can provide custom implementation for all sanitizer coverage's weak functions, and they will be considered by asan dll. Differential Revision: https://reviews.llvm.org/D29168 llvm-svn: 293958
2017-02-03 07:02:11 +08:00
add_compiler_rt_object_libraries(SanitizerCommonWeakInterception
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sanitizer_win_weak_interception.cc
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DYNAMIC
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_object_libraries(SancovWeakInterception
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sanitizer_coverage_win_weak_interception.cc
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DYNAMIC
DEFS ${SANITIZER_COMMON_DEFINITIONS})
[sanitizer] Split dll_thunks into different sanitizers. When the sanitizer is implemented as a static library and is included in the main executable, we need an auxiliary static library dll_thunk that will be linked to the dlls that have instrumentation, so they can refer to the runtime in the main executable. Basically, it uses interception to get a pointer the function in the main executable and override its function with that pointer. Before this diff, all of the implementation for dll_thunks was included in asan. In this diff I split it into different sanitizers, so we can use other sanitizers regardless of whether we include asan or not. All the sanitizers include a file sanitizer_win_dll_thunk.cc that register functions to be intercepted in the binary section: DLLTH When the dll including dll_thunk is initialized, it will execute __dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc, which will consider all the CB registered in the section DLLTH. So, all the functions registered will be intercepted, and redirected to the implementation in the main executable. All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan, ubsan and sanitizer coverage in the address sanitizer library. Differential Revision: https://reviews.llvm.org/D29154 llvm-svn: 293951
2017-02-03 07:01:28 +08:00
add_compiler_rt_object_libraries(SanitizerCommonDllThunk
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sanitizer_win_dll_thunk.cc
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_object_libraries(SancovDllThunk
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sanitizer_coverage_win_dll_thunk.cc
sanitizer_coverage_win_sections.cc
[sanitizer] Split dll_thunks into different sanitizers. When the sanitizer is implemented as a static library and is included in the main executable, we need an auxiliary static library dll_thunk that will be linked to the dlls that have instrumentation, so they can refer to the runtime in the main executable. Basically, it uses interception to get a pointer the function in the main executable and override its function with that pointer. Before this diff, all of the implementation for dll_thunks was included in asan. In this diff I split it into different sanitizers, so we can use other sanitizers regardless of whether we include asan or not. All the sanitizers include a file sanitizer_win_dll_thunk.cc that register functions to be intercepted in the binary section: DLLTH When the dll including dll_thunk is initialized, it will execute __dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc, which will consider all the CB registered in the section DLLTH. So, all the functions registered will be intercepted, and redirected to the implementation in the main executable. All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan, ubsan and sanitizer coverage in the address sanitizer library. Differential Revision: https://reviews.llvm.org/D29154 llvm-svn: 293951
2017-02-03 07:01:28 +08:00
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
DEFS ${SANITIZER_COMMON_DEFINITIONS})
[sanitizer] Add dynamic_runtime_thunk for different sanitizers. In Windows, when the sanitizer is implemented as a shared library (DLL), we need an auxiliary static library dynamic_runtime_thunk that will be linked to the main executable and dlls. In the sanitizer DLL, we are exposing weak functions with WIN_WEAK_EXPORT_DEF(), which exports the default implementation with __dll suffix. For example: for sanitizer coverage, the default implementation of __sanitizer_cov_trace_cmp is exported as: __sanitizer_cov_trace_cmp__dll. In the dynamic_runtime_thunk static library, we include weak aliases to the imported implementation from the dll, using the macro WIN_WEAK_IMPORT_DEF(). By default, all users's programs that include calls to weak functions like __sanitizer_cov_trace_cmp, will be redirected to the implementation in the dll, when linking to dynamic_runtime_thunk. After this diff, we are able to compile code with sanitizer coverage instrumentation on Windows. When the instrumented object files are linked with clang-rt_asan_dynamic_runtime_thunk-arch.lib all the weak symbols will be resolved to the implementation imported from asan dll. All the files sanitizer_dynamic_runtime_thunk.cc are independent, so we do not need to include a specific list of sanitizers. Now, we compile: [asan|ubsan|sanitizer_coverage]_win_dynamic_runtime_thunk.cc and sanitizer_win_dynamic_runtime_thunk.cc to generate asan_dynamic_runtime_thunk.lib, because we include asan, ubsan and sanitizer coverage in the address sanitizer library. Differential Revision: https://reviews.llvm.org/D29158 llvm-svn: 293953
2017-02-03 07:01:41 +08:00
set(DYNAMIC_RUNTIME_THUNK_CFLAGS "-DSANITIZER_DYNAMIC_RUNTIME_THUNK")
if(MSVC)
list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-Zl")
elseif(CMAKE_C_COMPILER_ID MATCHES Clang)
list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-nodefaultlibs")
endif()
add_compiler_rt_object_libraries(SanitizerCommonDynamicRuntimeThunk
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sanitizer_win_dynamic_runtime_thunk.cc
CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
add_compiler_rt_object_libraries(SancovDynamicRuntimeThunk
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sanitizer_coverage_win_dynamic_runtime_thunk.cc
sanitizer_coverage_win_sections.cc
[sanitizer] Add dynamic_runtime_thunk for different sanitizers. In Windows, when the sanitizer is implemented as a shared library (DLL), we need an auxiliary static library dynamic_runtime_thunk that will be linked to the main executable and dlls. In the sanitizer DLL, we are exposing weak functions with WIN_WEAK_EXPORT_DEF(), which exports the default implementation with __dll suffix. For example: for sanitizer coverage, the default implementation of __sanitizer_cov_trace_cmp is exported as: __sanitizer_cov_trace_cmp__dll. In the dynamic_runtime_thunk static library, we include weak aliases to the imported implementation from the dll, using the macro WIN_WEAK_IMPORT_DEF(). By default, all users's programs that include calls to weak functions like __sanitizer_cov_trace_cmp, will be redirected to the implementation in the dll, when linking to dynamic_runtime_thunk. After this diff, we are able to compile code with sanitizer coverage instrumentation on Windows. When the instrumented object files are linked with clang-rt_asan_dynamic_runtime_thunk-arch.lib all the weak symbols will be resolved to the implementation imported from asan dll. All the files sanitizer_dynamic_runtime_thunk.cc are independent, so we do not need to include a specific list of sanitizers. Now, we compile: [asan|ubsan|sanitizer_coverage]_win_dynamic_runtime_thunk.cc and sanitizer_win_dynamic_runtime_thunk.cc to generate asan_dynamic_runtime_thunk.lib, because we include asan, ubsan and sanitizer coverage in the address sanitizer library. Differential Revision: https://reviews.llvm.org/D29158 llvm-svn: 293953
2017-02-03 07:01:41 +08:00
CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
[sanitizer] Split dll_thunks into different sanitizers. When the sanitizer is implemented as a static library and is included in the main executable, we need an auxiliary static library dll_thunk that will be linked to the dlls that have instrumentation, so they can refer to the runtime in the main executable. Basically, it uses interception to get a pointer the function in the main executable and override its function with that pointer. Before this diff, all of the implementation for dll_thunks was included in asan. In this diff I split it into different sanitizers, so we can use other sanitizers regardless of whether we include asan or not. All the sanitizers include a file sanitizer_win_dll_thunk.cc that register functions to be intercepted in the binary section: DLLTH When the dll including dll_thunk is initialized, it will execute __dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc, which will consider all the CB registered in the section DLLTH. So, all the functions registered will be intercepted, and redirected to the implementation in the main executable. All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan, ubsan and sanitizer coverage in the address sanitizer library. Differential Revision: https://reviews.llvm.org/D29154 llvm-svn: 293951
2017-02-03 07:01:28 +08:00
endif()
# Unit tests for common sanitizer runtime.
if(COMPILER_RT_INCLUDE_TESTS)
add_subdirectory(tests)
endif()