summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/CMakeLists.txt
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2017-12-22 18:04:20 +0000
committerAlex Shlyapnikov <alekseys@google.com>2017-12-22 18:04:20 +0000
commit654de9cb6f8f66a9e5a0d110c54e89121b562934 (patch)
tree11210ed64dfedca5e892991ae51ab461bf438c10 /lib/sanitizer_common/CMakeLists.txt
parent4a21f6f81e93ebc443e5f63f6e70528b65e1b3b1 (diff)
[Sanitizers, CMake] Basic sanitizer Solaris support (PR 33274)
Summary: This patch, on top of https://reviews.llvm.org/D40898, contains the build system changes necessary to enable the Solaris/x86 sanitizer port. The only issue of note is the libclang_rt.sancov_{begin, end} libraries: clang relies on the linker automatically defining __start_SECNAME and __stop_SECNAME labels for sections whose names are valid C identifiers. This is a GNU ld extension not present in the ELF gABI, also implemented by gold and lld, but not by Solaris ld. To work around this, I automatically link the sancov_{begin,end} libraries into every executable for now. There seems to be now way to build individual startup objects like crtbegin.o/crtend.o, so I've followed the lead of libclang_rt.asan-preinit which also contains just a single object. Reviewers: kcc, alekseyshl Reviewed By: alekseyshl Subscribers: srhines, kubamracek, mgorny, fedor.sergeev, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40899 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/CMakeLists.txt')
-rw-r--r--lib/sanitizer_common/CMakeLists.txt38
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/sanitizer_common/CMakeLists.txt b/lib/sanitizer_common/CMakeLists.txt
index 60caa5c4f..e0226ae49 100644
--- a/lib/sanitizer_common/CMakeLists.txt
+++ b/lib/sanitizer_common/CMakeLists.txt
@@ -20,12 +20,15 @@ set(SANITIZER_SOURCES_NOTERMINATION
sanitizer_platform_limits_linux.cc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_posix.cc
+ sanitizer_platform_limits_solaris.cc
sanitizer_posix.cc
sanitizer_printf.cc
sanitizer_procmaps_common.cc
sanitizer_procmaps_freebsd.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
@@ -40,7 +43,7 @@ set(SANITIZER_SOURCES_NOTERMINATION
sanitizer_thread_registry.cc
sanitizer_win.cc)
-if(UNIX AND NOT APPLE)
+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
@@ -122,6 +125,7 @@ set(SANITIZER_HEADERS
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
@@ -216,6 +220,38 @@ add_compiler_rt_object_libraries(RTSanitizerCommonLibcNoHooks
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)
add_compiler_rt_object_libraries(SanitizerCommonWeakInterception
${SANITIZER_COMMON_SUPPORTED_OS}