diff options
author | Marcos Pividori <mpividori@google.com> | 2017-02-02 23:01:28 +0000 |
---|---|---|
committer | Marcos Pividori <mpividori@google.com> | 2017-02-02 23:01:28 +0000 |
commit | 060fe63bb45fb6007571e840e8c4b2f25f75c09e (patch) | |
tree | 848db2bbd8e4b41fb586e7c9d378483e90a0fd89 /lib/ubsan/CMakeLists.txt | |
parent | b27ebe955b66ec464fd2c7c03ea2788bec5c0433 (diff) | |
download | compiler-rt-060fe63bb45fb6007571e840e8c4b2f25f75c09e.tar.gz |
[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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293951 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ubsan/CMakeLists.txt')
-rw-r--r-- | lib/ubsan/CMakeLists.txt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/ubsan/CMakeLists.txt b/lib/ubsan/CMakeLists.txt index 9bb36edc7..6a2544632 100644 --- a/lib/ubsan/CMakeLists.txt +++ b/lib/ubsan/CMakeLists.txt @@ -90,6 +90,15 @@ else() ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH} SOURCES ${UBSAN_CXX_SOURCES} CFLAGS ${UBSAN_CXXFLAGS}) + if (WIN32) + add_compiler_rt_object_libraries(UbsanDllThunk + ${SANITIZER_COMMON_SUPPORTED_OS} + ARCHS ${UBSAN_SUPPORTED_ARCH} + SOURCES ubsan_win_dll_thunk.cc + CFLAGS ${UBSAN_CFLAGS} -DSANITIZER_DLL_THUNK + DEFS ${UBSAN_COMMON_DEFINITIONS}) + endif() + if(COMPILER_RT_HAS_UBSAN) # Initializer of standalone UBSan runtime. add_compiler_rt_object_libraries(RTUbsan_standalone |