forked from OSchip/llvm-project
parent
787c0e42e0
commit
ffbc4ec790
|
@ -25,7 +25,6 @@ foreach(arch ${DFSAN_SUPPORTED_ARCH})
|
|||
add_compiler_rt_runtime(clang_rt.dfsan-libc-${arch} ${arch} STATIC
|
||||
SOURCES ${DFSAN_RTL_SOURCES}
|
||||
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
|
||||
$<TARGET_OBJECTS:RTSanitizerCommonNoLibc.${arch}>
|
||||
CFLAGS ${DFSAN_NOLIBC_CFLAGS})
|
||||
add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} dfsan.syms.extra)
|
||||
add_dependencies(dfsan
|
||||
|
|
|
@ -22,7 +22,6 @@ else()
|
|||
SOURCES ${SAFESTACK_SOURCES}
|
||||
$<TARGET_OBJECTS:RTInterception.${arch}>
|
||||
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
|
||||
$<TARGET_OBJECTS:RTSanitizerCommonNoLibc.${arch}>
|
||||
CFLAGS ${SAFESTACK_CFLAGS})
|
||||
add_dependencies(safestack clang_rt.safestack-${arch})
|
||||
endforeach()
|
||||
|
|
|
@ -33,12 +33,6 @@ set(SANITIZER_SOURCES
|
|||
sanitizer_thread_registry.cc
|
||||
sanitizer_win.cc)
|
||||
|
||||
# Libc functions stubs. These sources should be linked instead of
|
||||
# SANITIZER_LIBCDEP_SOURCES when sanitizer_common library must not depend on
|
||||
# libc.
|
||||
set(SANITIZER_NOLIBC_SOURCES
|
||||
sanitizer_common_nolibc.cc)
|
||||
|
||||
set(SANITIZER_LIBCDEP_SOURCES
|
||||
sanitizer_common_libcdep.cc
|
||||
sanitizer_coverage_libcdep.cc
|
||||
|
@ -151,10 +145,6 @@ else()
|
|||
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
||||
SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS}
|
||||
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
||||
add_compiler_rt_object_libraries(RTSanitizerCommonNoLibc
|
||||
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
||||
SOURCES ${SANITIZER_NOLIBC_SOURCES} CFLAGS ${SANITIZER_CFLAGS}
|
||||
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
||||
add_compiler_rt_object_libraries(RTSanitizerCommonLibc
|
||||
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
||||
SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS}
|
||||
|
|
|
@ -628,20 +628,15 @@ enum AndroidApiLevel {
|
|||
ANDROID_POST_LOLLIPOP = 23
|
||||
};
|
||||
|
||||
#if SANITIZER_POSIX
|
||||
#if SANITIZER_ANDROID
|
||||
// Initialize Android logging. Any writes before this are silently lost.
|
||||
void AndroidLogInit();
|
||||
void WriteToSyslog(const char *buffer);
|
||||
#else
|
||||
INLINE void AndroidLogInit() {}
|
||||
INLINE void WriteToSyslog(const char *buffer) {}
|
||||
#endif
|
||||
|
||||
#if SANITIZER_ANDROID
|
||||
void AndroidLogWrite(const char *buffer);
|
||||
void GetExtraActivationFlags(char *buf, uptr size);
|
||||
void SanitizerInitializeUnwinder();
|
||||
AndroidApiLevel AndroidGetApiLevel();
|
||||
#else
|
||||
INLINE void AndroidLogInit() {}
|
||||
INLINE void AndroidLogWrite(const char *buffer_unused) {}
|
||||
INLINE void GetExtraActivationFlags(char *buf, uptr size) { *buf = '\0'; }
|
||||
INLINE void SanitizerInitializeUnwinder() {}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
//===-- sanitizer_common_nolibc.cc ----------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains stubs for libc function to facilitate optional use of
|
||||
// libc in no-libcdep sources.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "sanitizer_platform.h"
|
||||
#include "sanitizer_common.h"
|
||||
|
||||
namespace __sanitizer {
|
||||
|
||||
void WriteToSyslog(const char *buffer) {}
|
||||
|
||||
}
|
|
@ -54,10 +54,6 @@ COMMON_FLAG(
|
|||
bool, log_exe_name, false,
|
||||
"Mention name of executable when reporting error and "
|
||||
"append executable name to logs (as in \"log_path.exe_name.pid\").")
|
||||
COMMON_FLAG(
|
||||
bool, log_to_syslog, SANITIZER_ANDROID,
|
||||
"Write all sanitizer output to syslog in addition to other means of "
|
||||
"logging.")
|
||||
COMMON_FLAG(
|
||||
int, verbosity, 0,
|
||||
"Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).")
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "sanitizer_platform.h"
|
||||
#if SANITIZER_FREEBSD || SANITIZER_LINUX
|
||||
|
||||
#include "sanitizer_allocator_internal.h"
|
||||
#include "sanitizer_common.h"
|
||||
#include "sanitizer_flags.h"
|
||||
#include "sanitizer_internal_defs.h"
|
||||
|
@ -74,6 +75,7 @@ extern char **environ; // provided by crt1
|
|||
#endif
|
||||
|
||||
#if SANITIZER_ANDROID
|
||||
#include <android/log.h>
|
||||
#include <sys/system_properties.h>
|
||||
#endif
|
||||
|
||||
|
@ -918,6 +920,33 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
|
|||
#endif // defined(__x86_64__) && SANITIZER_LINUX
|
||||
|
||||
#if SANITIZER_ANDROID
|
||||
static atomic_uint8_t android_log_initialized;
|
||||
|
||||
void AndroidLogInit() {
|
||||
atomic_store(&android_log_initialized, 1, memory_order_release);
|
||||
}
|
||||
// This thing is not, strictly speaking, async signal safe, but it does not seem
|
||||
// to cause any issues. Alternative is writing to log devices directly, but
|
||||
// their location and message format might change in the future, so we'd really
|
||||
// like to avoid that.
|
||||
void AndroidLogWrite(const char *buffer) {
|
||||
if (!atomic_load(&android_log_initialized, memory_order_acquire))
|
||||
return;
|
||||
|
||||
char *copy = internal_strdup(buffer);
|
||||
char *p = copy;
|
||||
char *q;
|
||||
// __android_log_write has an implicit message length limit.
|
||||
// Print one line at a time.
|
||||
do {
|
||||
q = internal_strchr(p, '\n');
|
||||
if (q) *q = '\0';
|
||||
__android_log_write(ANDROID_LOG_INFO, NULL, p);
|
||||
if (q) p = q + 1;
|
||||
} while (q);
|
||||
InternalFree(copy);
|
||||
}
|
||||
|
||||
void GetExtraActivationFlags(char *buf, uptr size) {
|
||||
CHECK(size > PROP_VALUE_MAX);
|
||||
__system_property_get("asan.options", buf);
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "sanitizer_platform.h"
|
||||
|
||||
#if SANITIZER_POSIX
|
||||
#include "sanitizer_allocator_internal.h"
|
||||
#include "sanitizer_common.h"
|
||||
#include "sanitizer_flags.h"
|
||||
#include "sanitizer_platform_limits_posix.h"
|
||||
|
@ -31,17 +30,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if SANITIZER_ANDROID && __ANDROID_API__ < 21
|
||||
#include <android/log.h>
|
||||
#else
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
#if SANITIZER_FREEBSD
|
||||
// The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
|
||||
// that, it was never implemented. So just define it to zero.
|
||||
|
@ -282,49 +275,6 @@ void *MmapNoAccess(uptr fixed_addr, uptr size, const char *name) {
|
|||
0);
|
||||
}
|
||||
|
||||
// 64-bit Android targets don't provide the deprecated __android_log_write.
|
||||
// Starting with the L release, syslog() works and is preferable to
|
||||
// __android_log_write.
|
||||
#if SANITIZER_ANDROID && __ANDROID_API__ < 21
|
||||
static atomic_uint8_t android_log_initialized;
|
||||
|
||||
void AndroidLogInit() {
|
||||
atomic_store(&android_log_initialized, 1, memory_order_release);
|
||||
}
|
||||
|
||||
static bool IsSyslogAvailable() {
|
||||
return atomic_load(&android_log_initialized, memory_order_acquire);
|
||||
}
|
||||
|
||||
static void WriteOneLineToSyslog(const char *s) {
|
||||
__android_log_write(ANDROID_LOG_INFO, NULL, s);
|
||||
}
|
||||
#else
|
||||
void AndroidLogInit() {}
|
||||
|
||||
static bool IsSyslogAvailable() { return true; }
|
||||
|
||||
static void WriteOneLineToSyslog(const char *s) { syslog(LOG_INFO, "%s", s); }
|
||||
#endif
|
||||
|
||||
void WriteToSyslog(const char *buffer) {
|
||||
if (!IsSyslogAvailable())
|
||||
return;
|
||||
char *copy = internal_strdup(buffer);
|
||||
char *p = copy;
|
||||
char *q;
|
||||
// syslog, at least on Android, has an implicit message length limit.
|
||||
// Print one line at a time.
|
||||
do {
|
||||
q = internal_strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
WriteOneLineToSyslog(p);
|
||||
if (q)
|
||||
p = q + 1;
|
||||
} while (q);
|
||||
InternalFree(copy);
|
||||
}
|
||||
} // namespace __sanitizer
|
||||
|
||||
#endif // SANITIZER_POSIX
|
||||
|
|
|
@ -279,8 +279,7 @@ static void SharedPrintfCode(bool append_pid, const char *format,
|
|||
# undef CHECK_NEEDED_LENGTH
|
||||
}
|
||||
RawWrite(buffer);
|
||||
if (common_flags()->log_to_syslog)
|
||||
WriteToSyslog(buffer);
|
||||
AndroidLogWrite(buffer);
|
||||
CallPrintfAndReportCallback(buffer);
|
||||
// If we had mapped any memory, clean up.
|
||||
if (buffer != local_buffer)
|
||||
|
|
|
@ -172,8 +172,7 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID)
|
|||
else()
|
||||
if(CAN_TARGET_x86_64)
|
||||
add_sanitizer_common_lib("RTSanitizerCommon.test.nolibc.x86_64"
|
||||
$<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
|
||||
$<TARGET_OBJECTS:RTSanitizerCommonNoLibc.x86_64>)
|
||||
$<TARGET_OBJECTS:RTSanitizerCommon.x86_64>)
|
||||
endif()
|
||||
foreach(arch ${SANITIZER_UNITTEST_SUPPORTED_ARCH})
|
||||
add_sanitizer_common_lib("RTSanitizerCommon.test.${arch}"
|
||||
|
|
Loading…
Reference in New Issue