[llvm-commits] [compiler-rt] r148303 - /compiler-rt/trunk/lib/asan/asan_mac.cc

Alexander Potapenko glider at google.com
Tue Jan 17 01:38:54 PST 2012


Author: glider
Date: Tue Jan 17 03:38:54 2012
New Revision: 148303

URL: http://llvm.org/viewvc/llvm-project?rev=148303&view=rev
Log:
Define the bounds of the branch allocator memory space for 32-bit apps.

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

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=148303&r1=148302&r2=148303&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Tue Jan 17 03:38:54 2012
@@ -178,21 +178,30 @@
 // islands.
 // TODO(glider): instead of mapping a fixed range we must find a range of
 // unmapped pages in vmmap and take them.
+// These constants were chosen empirically and may not work if the shadow
+// memory layout changes. Unfortunately they do necessarily depend on
+// kHighMemBeg or kHighMemEnd.
+#if __WORDSIZE == 32
+#define kIslandEnd (0xffdf0000 - kPageSize)
+#define kIslandBeg (kIslandEnd - 256 * kPageSize)
+#else
 #define kIslandEnd (0x7fffffdf0000 - kPageSize)
 #define kIslandBeg (kIslandEnd - 256 * kPageSize)
+#endif
 
 extern "C"
 mach_error_t __asan_allocate_island(void **ptr,
                                     size_t unused_size,
                                     void *unused_hint) {
   if (!island_allocator_pos) {
-    if ((void*)-1 == asan_mmap((void*)kIslandBeg, kIslandEnd - kIslandBeg,
-                               PROT_READ | PROT_WRITE | PROT_EXEC,
-                               MAP_PRIVATE | MAP_ANON | MAP_FIXED,
-                               -1, 0)) {
+    island_allocator_pos =
+        asan_mmap((void*)kIslandBeg, kIslandEnd - kIslandBeg,
+                  PROT_READ | PROT_WRITE | PROT_EXEC,
+                  MAP_PRIVATE | MAP_ANON | MAP_FIXED,
+                 -1, 0);
+    if (island_allocator_pos != (void*)kIslandBeg) {
       return KERN_NO_SPACE;
     }
-    island_allocator_pos = (void*)kIslandBeg;
   };
   *ptr = island_allocator_pos;
   island_allocator_pos = (char*)island_allocator_pos + kPageSize;





More information about the llvm-commits mailing list