summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/asan/CMakeLists.txt1
-rw-r--r--lib/msan/CMakeLists.txt1
-rw-r--r--lib/sanitizer_common/CMakeLists.txt11
-rw-r--r--lib/sanitizer_common/sanitizer_common.cc9
-rw-r--r--lib/sanitizer_common/sanitizer_common.h2
-rw-r--r--lib/sanitizer_common/sanitizer_common_libcdep.cc23
-rw-r--r--lib/sanitizer_common/tests/CMakeLists.txt6
-rw-r--r--lib/tsan/rtl/CMakeLists.txt1
8 files changed, 43 insertions, 11 deletions
diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt
index b70a29cfd..721f7b732 100644
--- a/lib/asan/CMakeLists.txt
+++ b/lib/asan/CMakeLists.txt
@@ -84,6 +84,7 @@ else()
SOURCES ${ASAN_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
CFLAGS ${ASAN_CFLAGS}
DEFS ${ASAN_COMMON_DEFINITIONS}
SYMS asan.syms)
diff --git a/lib/msan/CMakeLists.txt b/lib/msan/CMakeLists.txt
index 5eedbea74..7577948b9 100644
--- a/lib/msan/CMakeLists.txt
+++ b/lib/msan/CMakeLists.txt
@@ -24,6 +24,7 @@ if(CAN_TARGET_${arch})
SOURCES ${MSAN_RTL_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
CFLAGS ${MSAN_RTL_CFLAGS}
SYMS msan.syms)
list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch})
diff --git a/lib/sanitizer_common/CMakeLists.txt b/lib/sanitizer_common/CMakeLists.txt
index fb01dba1e..3d0654523 100644
--- a/lib/sanitizer_common/CMakeLists.txt
+++ b/lib/sanitizer_common/CMakeLists.txt
@@ -23,6 +23,10 @@ set(SANITIZER_SOURCES
sanitizer_win.cc
)
+set(SANITIZER_LIBCDEP_SOURCES
+ sanitizer_common_libcdep.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.
@@ -62,11 +66,12 @@ if(APPLE)
# Build universal binary on APPLE.
add_compiler_rt_osx_object_library(RTSanitizerCommon
ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH}
- SOURCES ${SANITIZER_SOURCES}
+ SOURCES ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES}
CFLAGS ${SANITIZER_CFLAGS})
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.osx)
elseif(ANDROID)
- add_library(RTSanitizerCommon.arm.android OBJECT ${SANITIZER_SOURCES})
+ add_library(RTSanitizerCommon.arm.android OBJECT
+ ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES})
set_target_compile_flags(RTSanitizerCommon.arm.android
${SANITIZER_CFLAGS})
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android)
@@ -75,6 +80,8 @@ else()
foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH})
add_compiler_rt_object_library(RTSanitizerCommon ${arch}
SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
+ add_compiler_rt_object_library(RTSanitizerCommonLibc ${arch}
+ SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
add_compiler_rt_static_runtime(clang_rt.san-${arch} ${arch}
SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${arch})
diff --git a/lib/sanitizer_common/sanitizer_common.cc b/lib/sanitizer_common/sanitizer_common.cc
index 12d5b6cf5..3684e847c 100644
--- a/lib/sanitizer_common/sanitizer_common.cc
+++ b/lib/sanitizer_common/sanitizer_common.cc
@@ -31,7 +31,7 @@ static bool log_to_file = false; // Set to true by __sanitizer_set_report_path
// By default, dump to stderr. If |log_to_file| is true and |report_fd_pid|
// isn't equal to the current PID, try to obtain file descriptor by opening
// file "report_path_prefix.<PID>".
-static fd_t report_fd = kStderrFd;
+fd_t report_fd = kStderrFd;
static char report_path_prefix[4096]; // Set via __sanitizer_set_report_path.
// PID of process that opened |report_fd|. If a fork() occurs, the PID of the
// child thread will be different from |report_fd_pid|.
@@ -64,7 +64,7 @@ void NORETURN CheckFailed(const char *file, int line, const char *cond,
Die();
}
-static void MaybeOpenReportFile() {
+void MaybeOpenReportFile() {
if (!log_to_file || (report_fd_pid == GetPid())) return;
InternalScopedBuffer<char> report_path_full(4096);
internal_snprintf(report_path_full.data(), report_path_full.size(),
@@ -84,11 +84,6 @@ static void MaybeOpenReportFile() {
report_fd_pid = GetPid();
}
-bool PrintsToTty() {
- MaybeOpenReportFile();
- return internal_isatty(report_fd);
-}
-
void RawWrite(const char *buffer) {
static const char *kRawWriteError = "RawWrite can't output requested buffer!";
uptr length = (uptr)internal_strlen(buffer);
diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h
index 252224f57..f0208f333 100644
--- a/lib/sanitizer_common/sanitizer_common.h
+++ b/lib/sanitizer_common/sanitizer_common.h
@@ -114,6 +114,8 @@ void Report(const char *format, ...);
void SetPrintfAndReportCallback(void (*callback)(const char *));
// Can be used to prevent mixing error reports from different sanitizers.
extern StaticSpinMutex CommonSanitizerReportMutex;
+void MaybeOpenReportFile();
+extern fd_t report_fd;
uptr OpenFile(const char *filename, bool write);
// Opens the file 'file_name" and reads up to 'max_len' bytes.
diff --git a/lib/sanitizer_common/sanitizer_common_libcdep.cc b/lib/sanitizer_common/sanitizer_common_libcdep.cc
new file mode 100644
index 000000000..36f6cf0bc
--- /dev/null
+++ b/lib/sanitizer_common/sanitizer_common_libcdep.cc
@@ -0,0 +1,23 @@
+//===-- sanitizer_common_libcdep.cc ---------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is shared between AddressSanitizer and ThreadSanitizer
+// run-time libraries.
+//===----------------------------------------------------------------------===//
+
+#include "sanitizer_common.h"
+
+namespace __sanitizer {
+
+bool PrintsToTty() {
+ MaybeOpenReportFile();
+ return internal_isatty(report_fd);
+}
+
+} // namespace __sanitizer
diff --git a/lib/sanitizer_common/tests/CMakeLists.txt b/lib/sanitizer_common/tests/CMakeLists.txt
index 97a5474c5..25e57507a 100644
--- a/lib/sanitizer_common/tests/CMakeLists.txt
+++ b/lib/sanitizer_common/tests/CMakeLists.txt
@@ -97,11 +97,13 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
else()
if(CAN_TARGET_x86_64)
add_sanitizer_common_lib("RTSanitizerCommon.test.x86_64"
- $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>)
+ $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.x86_64>)
endif()
if(CAN_TARGET_i386)
add_sanitizer_common_lib("RTSanitizerCommon.test.i386"
- $<TARGET_OBJECTS:RTSanitizerCommon.i386>)
+ $<TARGET_OBJECTS:RTSanitizerCommon.i386>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.i386>)
endif()
endif()
if(CAN_TARGET_x86_64)
diff --git a/lib/tsan/rtl/CMakeLists.txt b/lib/tsan/rtl/CMakeLists.txt
index 8d89e6e7b..f1a8ff4d6 100644
--- a/lib/tsan/rtl/CMakeLists.txt
+++ b/lib/tsan/rtl/CMakeLists.txt
@@ -43,6 +43,7 @@ if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE)
SOURCES ${TSAN_SOURCES} ${TSAN_ASM_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
CFLAGS ${TSAN_CFLAGS}
DEFS ${TSAN_COMMON_DEFINITIONS}
SYMS tsan.syms)