diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2012-05-23 15:21:50 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2012-05-23 15:21:50 +0000 |
commit | c99f70044d64482adbc1053f04b32bdbf0d4c057 (patch) | |
tree | bfcf7cb7c7259b01206de476f5e2f26d8d8bb14a /lib/asan | |
parent | f1ee2cd5e4c7a46e1188315daa2c79181f852bec (diff) | |
download | compiler-rt-c99f70044d64482adbc1053f04b32bdbf0d4c057.tar.gz |
Move AsanShadowRangeIsAvailable() from mac to posix.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157326 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan')
-rw-r--r-- | lib/asan/asan_linux.cc | 9 | ||||
-rw-r--r-- | lib/asan/asan_mac.cc | 27 | ||||
-rw-r--r-- | lib/asan/asan_posix.cc | 26 |
3 files changed, 30 insertions, 32 deletions
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc index 1e5ceae4e..26c67e917 100644 --- a/lib/asan/asan_linux.cc +++ b/lib/asan/asan_linux.cc @@ -46,11 +46,6 @@ void *AsanDoesNotSupportStaticLinkage() { return &_DYNAMIC; // defined in link.h } -bool AsanShadowRangeIsAvailable() { - // FIXME: shall we need anything here on Linux? - return true; -} - void GetPcSpBp(void *context, uintptr_t *pc, uintptr_t *sp, uintptr_t *bp) { #ifdef ANDROID *pc = *sp = *bp = 0; @@ -191,6 +186,10 @@ bool AsanProcMaps::Next(uintptr_t *start, uintptr_t *end, char flags[10]; int major, minor; uintptr_t inode; + uintptr_t dummy; + if (!start) start = &dummy; + if (!end) end = &dummy; + if (!offset) offset = &dummy; char *next_line = (char*)internal_memchr(current_, '\n', last - current_); if (next_line == NULL) next_line = last; diff --git a/lib/asan/asan_mac.cc b/lib/asan/asan_mac.cc index b68b0ed71..df039c55c 100644 --- a/lib/asan/asan_mac.cc +++ b/lib/asan/asan_mac.cc @@ -93,33 +93,6 @@ void *AsanDoesNotSupportStaticLinkage() { return NULL; } -static inline bool IntervalsAreSeparate(uintptr_t start1, uintptr_t end1, - uintptr_t start2, uintptr_t end2) { - CHECK(start1 <= end1); - CHECK(start2 <= end2); - return (end1 < start2) || (end2 < start1); -} - -// FIXME: this is thread-unsafe, but should not cause problems most of the time. -// When the shadow is mapped only a single thread usually exists (plus maybe -// several worker threads on Mac, which aren't expected to map big chunks of -// memory). -bool AsanShadowRangeIsAvailable() { - AsanProcMaps procmaps; - uintptr_t start, end; - bool available = true; - while (procmaps.Next(&start, &end, - /*offset*/NULL, /*filename*/NULL, /*filename_size*/0)) { - if (!IntervalsAreSeparate(start, end, - kLowShadowBeg - kMmapGranularity, - kHighShadowEnd)) { - available = false; - break; - } - } - return available; -} - bool AsanInterceptsSignal(int signum) { return (signum == SIGSEGV || signum == SIGBUS) && FLAG_handle_segv; } diff --git a/lib/asan/asan_posix.cc b/lib/asan/asan_posix.cc index cd198bc61..912bb7e7c 100644 --- a/lib/asan/asan_posix.cc +++ b/lib/asan/asan_posix.cc @@ -15,6 +15,7 @@ #include "asan_internal.h" #include "asan_interceptors.h" +#include "asan_mapping.h" #include "asan_procmaps.h" #include "asan_stack.h" #include "asan_thread_registry.h" @@ -38,6 +39,31 @@ static const size_t kAltStackSize = SIGSTKSZ * 4; // SIGSTKSZ is not enough. namespace __asan { +static inline bool IntervalsAreSeparate(uintptr_t start1, uintptr_t end1, + uintptr_t start2, uintptr_t end2) { + CHECK(start1 <= end1); + CHECK(start2 <= end2); + return (end1 < start2) || (end2 < start1); +} + +// FIXME: this is thread-unsafe, but should not cause problems most of the time. +// When the shadow is mapped only a single thread usually exists (plus maybe +// several worker threads on Mac, which aren't expected to map big chunks of +// memory). +bool AsanShadowRangeIsAvailable() { + AsanProcMaps procmaps; + uintptr_t start, end; + uintptr_t shadow_start = kLowShadowBeg; + if (kLowShadowBeg > 0) shadow_start -= kMmapGranularity; + uintptr_t shadow_end = kHighShadowEnd; + while (procmaps.Next(&start, &end, + /*offset*/NULL, /*filename*/NULL, /*filename_size*/0)) { + if (!IntervalsAreSeparate(start, end, shadow_start, shadow_end)) + return false; + } + return true; +} + static void MaybeInstallSigaction(int signum, void (*handler)(int, siginfo_t *, void *)) { if (!AsanInterceptsSignal(signum)) |