Build and install .syms files alongside sanitizer runtimes. These are used to

specify which symbols are exported to DSOs when the sanitizer is statically
linked into a binary.

llvm-svn: 177784
This commit is contained in:
Richard Smith 2013-03-23 00:31:07 +00:00
parent f3e624ca73
commit c91e327cba
9 changed files with 24 additions and 7 deletions

View File

@ -36,10 +36,11 @@ endmacro()
# add_compiler_rt_static_runtime(<name> <arch>
# SOURCES <source files>
# CFLAGS <compile flags>
# DEFS <compile definitions>)
# DEFS <compile definitions>
# SYMS <symbols file>)
macro(add_compiler_rt_static_runtime name arch)
if(CAN_TARGET_${arch})
parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN})
parse_arguments(LIB "SOURCES;CFLAGS;DEFS;SYMS" "" ${ARGN})
add_library(${name} STATIC ${LIB_SOURCES})
# Setup compile flags and definitions.
set_target_compile_flags(${name}
@ -52,6 +53,13 @@ macro(add_compiler_rt_static_runtime name arch)
# Add installation command.
install(TARGETS ${name}
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
# Generate the .syms file if possible.
if(LIB_SYMS)
get_target_property(libfile ${name} LOCATION)
configure_file(${LIB_SYMS} ${libfile}.syms)
install(FILES ${libfile}.syms
DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
endif(LIB_SYMS)
else()
message(FATAL_ERROR "Archtecture ${arch} can't be targeted")
endif()

View File

@ -86,7 +86,8 @@ else()
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
CFLAGS ${ASAN_CFLAGS}
DEFS ${ASAN_COMMON_DEFINITIONS})
DEFS ${ASAN_COMMON_DEFINITIONS}
SYMS asan.syms)
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-${arch})
endforeach()
endif()

View File

@ -0,0 +1 @@
{ __asan_*; };

View File

@ -24,7 +24,8 @@ if(CAN_TARGET_${arch})
SOURCES ${MSAN_RTL_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
CFLAGS ${MSAN_RTL_CFLAGS})
CFLAGS ${MSAN_RTL_CFLAGS}
SYMS msan.syms)
list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch})
endif()

View File

@ -0,0 +1 @@
{ __msan_*; };

View File

@ -44,6 +44,7 @@ if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE)
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
CFLAGS ${TSAN_CFLAGS}
DEFS ${TSAN_COMMON_DEFINITIONS})
DEFS ${TSAN_COMMON_DEFINITIONS}
SYMS tsan.syms)
list(APPEND TSAN_RUNTIME_LIBRARIES clang_rt.tsan-${arch})
endif()

View File

@ -0,0 +1 @@
{ __tsan_*; };

View File

@ -34,11 +34,13 @@ else()
# Main UBSan runtime.
add_compiler_rt_static_runtime(clang_rt.ubsan-${arch} ${arch}
SOURCES ${UBSAN_SOURCES}
CFLAGS ${UBSAN_CFLAGS})
CFLAGS ${UBSAN_CFLAGS}
SYMS ubsan.syms)
# C++-specific parts of UBSan runtime. Requires a C++ ABI library.
add_compiler_rt_static_runtime(clang_rt.ubsan_cxx-${arch} ${arch}
SOURCES ${UBSAN_CXX_SOURCES}
CFLAGS ${UBSAN_CFLAGS})
CFLAGS ${UBSAN_CFLAGS}
SYMS ubsan.syms)
list(APPEND UBSAN_RUNTIME_LIBRARIES
clang_rt.san-${arch}
clang_rt.ubsan-${arch}

View File

@ -0,0 +1 @@
{ __ubsan_*; };