forked from OSchip/llvm-project
[sanitizer] Move ASan platform macros to sanitizer_common and rename them appropriately.
llvm-svn: 177397
This commit is contained in:
parent
45d2f96582
commit
d3b56605f1
|
@ -21,39 +21,8 @@
|
|||
#include "sanitizer_common/sanitizer_stacktrace.h"
|
||||
#include "sanitizer_common/sanitizer_libc.h"
|
||||
|
||||
#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32)
|
||||
# error "This operating system is not supported by AddressSanitizer"
|
||||
#endif
|
||||
|
||||
#define ASAN_DEFAULT_FAILURE_EXITCODE 1
|
||||
|
||||
#if defined(__linux__)
|
||||
# define ASAN_LINUX 1
|
||||
#else
|
||||
# define ASAN_LINUX 0
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
# define ASAN_MAC 1
|
||||
#else
|
||||
# define ASAN_MAC 0
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define ASAN_WINDOWS 1
|
||||
#else
|
||||
# define ASAN_WINDOWS 0
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__) || defined(ANDROID)
|
||||
# define ASAN_ANDROID 1
|
||||
#else
|
||||
# define ASAN_ANDROID 0
|
||||
#endif
|
||||
|
||||
|
||||
#define ASAN_POSIX (ASAN_LINUX || ASAN_MAC)
|
||||
|
||||
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
|
||||
# error "The AddressSanitizer run-time should not be"
|
||||
" instrumented by AddressSanitizer"
|
||||
|
@ -63,7 +32,7 @@
|
|||
|
||||
// If set, asan will install its own SEGV signal handler.
|
||||
#ifndef ASAN_NEEDS_SEGV
|
||||
# if ASAN_ANDROID == 1
|
||||
# if SANITIZER_ANDROID == 1
|
||||
# define ASAN_NEEDS_SEGV 0
|
||||
# else
|
||||
# define ASAN_NEEDS_SEGV 1
|
||||
|
@ -92,7 +61,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef ASAN_USE_PREINIT_ARRAY
|
||||
# define ASAN_USE_PREINIT_ARRAY (ASAN_LINUX && !ASAN_ANDROID)
|
||||
# define ASAN_USE_PREINIT_ARRAY (SANITIZER_LINUX && !SANITIZER_ANDROID)
|
||||
#endif
|
||||
|
||||
// All internal functions in asan reside inside the __asan namespace
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <unistd.h>
|
||||
#include <unwind.h>
|
||||
|
||||
#if !ASAN_ANDROID
|
||||
#if !SANITIZER_ANDROID
|
||||
// FIXME: where to get ucontext on Android?
|
||||
#include <sys/ucontext.h>
|
||||
#endif
|
||||
|
@ -50,7 +50,7 @@ void *AsanDoesNotSupportStaticLinkage() {
|
|||
}
|
||||
|
||||
void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
|
||||
#if ASAN_ANDROID
|
||||
#if SANITIZER_ANDROID
|
||||
*pc = *sp = *bp = 0;
|
||||
#elif defined(__arm__)
|
||||
ucontext_t *ucontext = (ucontext_t*)context;
|
||||
|
@ -119,7 +119,7 @@ void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, bool fast) {
|
|||
}
|
||||
}
|
||||
|
||||
#if !ASAN_ANDROID
|
||||
#if !SANITIZER_ANDROID
|
||||
void ReadContextStack(void *context, uptr *stack, uptr *ssize) {
|
||||
ucontext_t *ucp = (ucontext_t*)context;
|
||||
*stack = (uptr)ucp->uc_stack.ss_sp;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
//
|
||||
// Mac-specific ASan definitions.
|
||||
//===----------------------------------------------------------------------===//
|
||||
#ifndef ASAN_MAC_H
|
||||
#define ASAN_MAC_H
|
||||
#ifndef SANITIZER_MAC_H
|
||||
#define SANITIZER_MAC_H
|
||||
|
||||
// CF_RC_BITS, the layout of CFRuntimeBase and __CFStrIsConstant are internal
|
||||
// and subject to change in further CoreFoundation versions. Apple does not
|
||||
|
@ -54,4 +54,4 @@ void MaybeReplaceCFAllocator();
|
|||
|
||||
} // namespace __asan
|
||||
|
||||
#endif // ASAN_MAC_H
|
||||
#endif // SANITIZER_MAC_H
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "asan_stack.h"
|
||||
#include "asan_thread_registry.h"
|
||||
|
||||
#if ASAN_ANDROID
|
||||
#if SANITIZER_ANDROID
|
||||
DECLARE_REAL_AND_INTERCEPTOR(void*, malloc, uptr size)
|
||||
DECLARE_REAL_AND_INTERCEPTOR(void, free, void *ptr)
|
||||
DECLARE_REAL_AND_INTERCEPTOR(void*, calloc, uptr nmemb, uptr size)
|
||||
|
|
|
@ -56,7 +56,7 @@ extern SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_mapping_offset;
|
|||
# define SHADOW_SCALE (__asan_mapping_scale)
|
||||
# define SHADOW_OFFSET (__asan_mapping_offset)
|
||||
#else
|
||||
# if ASAN_ANDROID
|
||||
# if SANITIZER_ANDROID
|
||||
# define SHADOW_SCALE (3)
|
||||
# define SHADOW_OFFSET (0)
|
||||
# else
|
||||
|
@ -67,7 +67,7 @@ extern SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_mapping_offset;
|
|||
# if defined(__powerpc64__)
|
||||
# define SHADOW_OFFSET (1ULL << 41)
|
||||
# else
|
||||
# if ASAN_MAC
|
||||
# if SANITIZER_MAC
|
||||
# define SHADOW_OFFSET (1ULL << 44)
|
||||
# else
|
||||
# define SHADOW_OFFSET 0x7fff8000ULL
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace __asan; // NOLINT
|
|||
|
||||
// On Android new() goes through malloc interceptors.
|
||||
// See also https://code.google.com/p/address-sanitizer/issues/detail?id=131.
|
||||
#if !ASAN_ANDROID
|
||||
#if !SANITIZER_ANDROID
|
||||
|
||||
// Fake std::nothrow_t to avoid including <new>.
|
||||
namespace std {
|
||||
|
|
|
@ -169,7 +169,7 @@ void InitializeFlags(Flags *f, const char *env) {
|
|||
f->poison_heap = true;
|
||||
// Turn off alloc/dealloc mismatch checker on Mac for now.
|
||||
// TODO(glider): Fix known issues and enable this back.
|
||||
f->alloc_dealloc_mismatch = (ASAN_MAC == 0);;
|
||||
f->alloc_dealloc_mismatch = (SANITIZER_MAC == 0);;
|
||||
f->use_stack_depot = true; // Only affects allocator2.
|
||||
f->strict_memcmp = true;
|
||||
|
||||
|
@ -462,7 +462,7 @@ void __asan_init() {
|
|||
bool full_shadow_is_available =
|
||||
MemoryRangeIsAvailable(shadow_start, shadow_end);
|
||||
|
||||
#if ASAN_LINUX && defined(__x86_64__) && !ASAN_FIXED_MAPPING
|
||||
#if SANITIZER_LINUX && defined(__x86_64__) && !ASAN_FIXED_MAPPING
|
||||
if (!full_shadow_is_available) {
|
||||
kMidMemBeg = kLowMemEnd < 0x3000000000ULL ? 0x3000000000ULL : 0;
|
||||
kMidMemEnd = kLowMemEnd < 0x3000000000ULL ? 0x4fffffffffULL : 0;
|
||||
|
|
|
@ -70,7 +70,7 @@ AsanThread *AsanThreadRegistry::GetMain() {
|
|||
AsanThread *AsanThreadRegistry::GetCurrent() {
|
||||
AsanThreadSummary *summary = (AsanThreadSummary *)AsanTSDGet();
|
||||
if (!summary) {
|
||||
#if ASAN_ANDROID
|
||||
#if SANITIZER_ANDROID
|
||||
// On Android, libc constructor is called _after_ asan_init, and cleans up
|
||||
// TSD. Try to figure out if this is still the main thread by the stack
|
||||
// address. We are not entirely sure that we have correct main thread
|
||||
|
|
|
@ -13,6 +13,37 @@
|
|||
#ifndef SANITIZER_DEFS_H
|
||||
#define SANITIZER_DEFS_H
|
||||
|
||||
#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32)
|
||||
# error "This operating system is not supported"
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
# define SANITIZER_LINUX 1
|
||||
#else
|
||||
# define SANITIZER_LINUX 0
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
# define SANITIZER_MAC 1
|
||||
#else
|
||||
# define SANITIZER_MAC 0
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define SANITIZER_WINDOWS 1
|
||||
#else
|
||||
# define SANITIZER_WINDOWS 0
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__) || defined(ANDROID)
|
||||
# define SANITIZER_ANDROID 1
|
||||
#else
|
||||
# define SANITIZER_ANDROID 0
|
||||
#endif
|
||||
|
||||
#define SANITIZER_POSIX (SANITIZER_LINUX || SANITIZER_MAC)
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
// FIXME find out what we need on Windows. __declspec(dllexport) ?
|
||||
# define SANITIZER_INTERFACE_ATTRIBUTE
|
||||
|
|
Loading…
Reference in New Issue