2012-04-05 06:12:04 +08:00
|
|
|
# Build for the AddressSanitizer runtime support library.
|
|
|
|
|
2012-06-20 18:18:43 +08:00
|
|
|
set(ASAN_SOURCES
|
2012-12-10 21:52:55 +08:00
|
|
|
asan_allocator2.cc
|
2012-12-10 22:19:15 +08:00
|
|
|
asan_fake_stack.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
asan_globals.cc
|
|
|
|
asan_interceptors.cc
|
|
|
|
asan_linux.cc
|
|
|
|
asan_mac.cc
|
|
|
|
asan_malloc_linux.cc
|
|
|
|
asan_malloc_mac.cc
|
|
|
|
asan_malloc_win.cc
|
|
|
|
asan_new_delete.cc
|
|
|
|
asan_poisoning.cc
|
|
|
|
asan_posix.cc
|
2013-02-22 15:51:26 +08:00
|
|
|
asan_preinit.cc
|
2012-08-09 16:15:46 +08:00
|
|
|
asan_report.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
asan_rtl.cc
|
|
|
|
asan_stack.cc
|
|
|
|
asan_stats.cc
|
|
|
|
asan_thread.cc
|
2013-06-23 00:33:52 +08:00
|
|
|
asan_win.cc)
|
2012-04-05 06:12:04 +08:00
|
|
|
|
2012-08-17 17:00:08 +08:00
|
|
|
set(ASAN_DYLIB_SOURCES
|
2013-06-23 00:33:52 +08:00
|
|
|
${ASAN_SOURCES})
|
2012-08-17 17:00:08 +08:00
|
|
|
|
2012-06-25 20:57:43 +08:00
|
|
|
include_directories(..)
|
|
|
|
|
2013-03-13 17:18:30 +08:00
|
|
|
set(ASAN_CFLAGS
|
|
|
|
${SANITIZER_COMMON_CFLAGS}
|
|
|
|
-fno-rtti)
|
2012-09-05 17:00:03 +08:00
|
|
|
|
2013-01-21 16:24:19 +08:00
|
|
|
set(ASAN_COMMON_DEFINITIONS
|
2013-01-22 15:21:24 +08:00
|
|
|
ASAN_HAS_EXCEPTIONS=1)
|
2013-01-21 16:24:19 +08:00
|
|
|
|
2012-09-11 19:55:45 +08:00
|
|
|
if(ANDROID)
|
2013-01-21 16:24:19 +08:00
|
|
|
list(APPEND ASAN_COMMON_DEFINITIONS
|
2013-01-22 15:21:24 +08:00
|
|
|
ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
|
2012-09-11 19:55:45 +08:00
|
|
|
ASAN_NEEDS_SEGV=0
|
2013-01-21 16:24:19 +08:00
|
|
|
ASAN_LOW_MEMORY=1)
|
2012-09-11 19:55:45 +08:00
|
|
|
else()
|
2013-01-21 16:24:19 +08:00
|
|
|
list(APPEND ASAN_COMMON_DEFINITIONS
|
2013-01-22 15:21:24 +08:00
|
|
|
ASAN_FLEXIBLE_MAPPING_AND_OFFSET=1
|
2013-01-21 16:24:19 +08:00
|
|
|
ASAN_NEEDS_SEGV=1)
|
2012-09-11 19:55:45 +08:00
|
|
|
endif()
|
2012-08-17 17:00:08 +08:00
|
|
|
|
2013-01-19 00:51:07 +08:00
|
|
|
# Architectures supported by ASan.
|
|
|
|
filter_available_targets(ASAN_SUPPORTED_ARCH
|
2013-06-07 17:44:43 +08:00
|
|
|
x86_64 i386 powerpc64)
|
2013-01-19 00:51:07 +08:00
|
|
|
|
2012-08-10 22:45:52 +08:00
|
|
|
set(ASAN_RUNTIME_LIBRARIES)
|
|
|
|
if(APPLE)
|
|
|
|
# Build universal binary on APPLE.
|
2013-01-22 17:14:54 +08:00
|
|
|
add_compiler_rt_osx_dynamic_runtime(clang_rt.asan_osx_dynamic
|
|
|
|
ARCH ${ASAN_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${ASAN_DYLIB_SOURCES}
|
|
|
|
$<TARGET_OBJECTS:RTInterception.osx>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommon.osx>
|
2013-06-23 00:33:52 +08:00
|
|
|
$<TARGET_OBJECTS:RTLSanCommon.osx>
|
2013-01-22 17:14:54 +08:00
|
|
|
CFLAGS ${ASAN_CFLAGS}
|
2013-02-05 23:57:12 +08:00
|
|
|
DEFS ${ASAN_COMMON_DEFINITIONS}
|
2013-01-22 17:14:54 +08:00
|
|
|
# Dynamic lookup is needed because shadow scale and offset are
|
|
|
|
# provided by the instrumented modules.
|
|
|
|
LINKFLAGS "-framework Foundation"
|
|
|
|
"-undefined dynamic_lookup")
|
|
|
|
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan_osx_dynamic)
|
2012-09-11 19:55:45 +08:00
|
|
|
elseif(ANDROID)
|
|
|
|
add_library(clang_rt.asan-arm-android SHARED
|
|
|
|
${ASAN_SOURCES}
|
|
|
|
$<TARGET_OBJECTS:RTInterception.arm.android>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommon.arm.android>
|
|
|
|
)
|
|
|
|
set_target_compile_flags(clang_rt.asan-arm-android
|
2013-01-21 16:12:20 +08:00
|
|
|
${ASAN_CFLAGS})
|
|
|
|
set_property(TARGET clang_rt.asan-arm-android APPEND PROPERTY
|
|
|
|
COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS})
|
2012-09-11 19:55:45 +08:00
|
|
|
target_link_libraries(clang_rt.asan-arm-android dl)
|
|
|
|
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-arm-android)
|
2012-08-10 22:45:52 +08:00
|
|
|
else()
|
|
|
|
# Otherwise, build separate libraries for each target.
|
2013-01-19 00:51:07 +08:00
|
|
|
foreach(arch ${ASAN_SUPPORTED_ARCH})
|
2013-01-21 16:12:20 +08:00
|
|
|
add_compiler_rt_static_runtime(clang_rt.asan-${arch} ${arch}
|
|
|
|
SOURCES ${ASAN_SOURCES}
|
|
|
|
$<TARGET_OBJECTS:RTInterception.${arch}>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
|
2013-05-18 00:17:19 +08:00
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
|
2013-05-22 21:20:37 +08:00
|
|
|
$<TARGET_OBJECTS:RTLSanCommon.${arch}>
|
2013-01-21 16:12:20 +08:00
|
|
|
CFLAGS ${ASAN_CFLAGS}
|
2013-03-23 08:31:07 +08:00
|
|
|
DEFS ${ASAN_COMMON_DEFINITIONS}
|
|
|
|
SYMS asan.syms)
|
2013-01-19 00:51:07 +08:00
|
|
|
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-${arch})
|
|
|
|
endforeach()
|
2012-04-05 06:12:04 +08:00
|
|
|
endif()
|
2012-06-25 20:57:43 +08:00
|
|
|
|
2013-05-21 21:48:27 +08:00
|
|
|
add_compiler_rt_resource_file(asan_blacklist asan_blacklist.txt)
|
|
|
|
|
2012-06-25 20:57:43 +08:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
2012-07-31 23:43:11 +08:00
|
|
|
|
|
|
|
add_subdirectory(lit_tests)
|