[llvm-commits] [compiler-rt] r157326 - in /compiler-rt/trunk/lib/asan: asan_linux.cc asan_mac.cc asan_posix.cc

Evgeniy Stepanov eugeni.stepanov at gmail.com
Wed May 23 08:21:50 PDT 2012


Author: eugenis
Date: Wed May 23 10:21:50 2012
New Revision: 157326

URL: http://llvm.org/viewvc/llvm-project?rev=157326&view=rev
Log:
Move AsanShadowRangeIsAvailable() from mac to posix.

Modified:
    compiler-rt/trunk/lib/asan/asan_linux.cc
    compiler-rt/trunk/lib/asan/asan_mac.cc
    compiler-rt/trunk/lib/asan/asan_posix.cc

Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=157326&r1=157325&r2=157326&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_linux.cc Wed May 23 10:21:50 2012
@@ -46,11 +46,6 @@
   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 @@
   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;

Modified: compiler-rt/trunk/lib/asan/asan_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=157326&r1=157325&r2=157326&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Wed May 23 10:21:50 2012
@@ -93,33 +93,6 @@
   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;
 }

Modified: compiler-rt/trunk/lib/asan/asan_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=157326&r1=157325&r2=157326&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Wed May 23 10:21:50 2012
@@ -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 @@
 
 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))





More information about the llvm-commits mailing list