[PATCH] [Compiler-rt][Sanitizer][MSan][i386] Adding support for i386

Mohit Bhakkad mohit.bhakkad at imgtec.com
Thu Feb 19 04:28:38 PST 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6433

Files:
  cmake/config-ix.cmake
  lib/msan/msan.h
  lib/msan/msan_allocator.cc
  lib/msan/msan_linux.cc
  lib/sanitizer_common/sanitizer_platform_interceptors.h

Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -204,7 +204,7 @@
 # by other sanitizers (even if they build into dummy object files).
 filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH
   ${SANITIZER_COMMON_SUPPORTED_ARCH})
-filter_available_targets(MSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
+filter_available_targets(MSAN_SUPPORTED_ARCH i386 x86_64 mips64 mips64el)
 filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 i686 arm mips mips64
   mipsel mips64el aarch64 powerpc64 powerpc64le)
 filter_available_targets(TSAN_SUPPORTED_ARCH x86_64)
Index: lib/msan/msan.h
===================================================================
--- lib/msan/msan.h
+++ lib/msan/msan.h
@@ -47,6 +47,17 @@
 #define MEM_TO_SHADOW(mem) (((uptr)(mem)) & ~0x4000000000ULL)
 #define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x002000000000)
 
+#elif SANITIZER_LINUX && SANITIZER_WORDSIZE == 32
+
+const MappingDesc kMemoryLayout[] = {
+    {0x00000000UL, 0x40000000UL, MappingDesc::INVALID, "invalid"},
+    {0x40000000UL, 0x80000000UL, MappingDesc::SHADOW, "shadow"},
+    {0x80000000UL, 0xc0000000UL, MappingDesc::ORIGIN, "origin"},
+    {0xc0000000UL, 0xffffffffUL, MappingDesc::APP, "app"}};
+
+#define MEM_TO_SHADOW(mem) (((uptr)(mem)) & ~0x80000000UL)
+#define SHADOW_TO_ORIGIN(mem) (((uptr)(mem)) + 0x40000000UL)
+
 #elif SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 64
 
 // Low memory: main binary, MAP_32BIT mappings and modules
Index: lib/msan/msan_allocator.cc
===================================================================
--- lib/msan/msan_allocator.cc
+++ lib/msan/msan_allocator.cc
@@ -39,7 +39,16 @@
   }
 };
 
-#if defined(__mips64)
+#if defined (__i386__)
+  static const uptr kMaxAllowedMallocSize = 3UL << 30;
+  static const uptr kRegionSizeLog = 20;
+  static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
+  typedef FlatByteMap<kNumRegions> ByteMap;
+  typedef CompactSizeClassMap SizeClassMap;
+  typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE, sizeof(Metadata),
+                               SizeClassMap, kRegionSizeLog, ByteMap,
+                               MsanMapUnmapCallback> PrimaryAllocator;
+#elif defined(__mips64)
   static const uptr kMaxAllowedMallocSize = 2UL << 30;
   static const uptr kRegionSizeLog = 20;
   static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
Index: lib/msan/msan_linux.cc
===================================================================
--- lib/msan/msan_linux.cc
+++ lib/msan/msan_linux.cc
@@ -73,7 +73,9 @@
     CHECK_LT(start, end);
     CHECK_EQ(prev_end, start);
     CHECK(addr_is_type(start, type));
+#if !defined(__i386__)
     CHECK(addr_is_type((start + end) / 2, type));
+#endif
     CHECK(addr_is_type(end - 1, type));
     if (type == MappingDesc::APP) {
       uptr addr = start;
Index: lib/sanitizer_common/sanitizer_platform_interceptors.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -175,7 +175,8 @@
   SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
 #define SANITIZER_INTERCEPT_ETHER_R SI_FREEBSD || SI_LINUX_NOT_ANDROID
 #define SANITIZER_INTERCEPT_SHMCTL \
-  ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && SANITIZER_WORDSIZE == 64)
+  ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \
+   (SANITIZER_WORDSIZE == 64 || defined(__i386__)))
 #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_NOT_WINDOWS
 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSCHED \

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6433.20277.patch
Type: text/x-patch
Size: 3705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150219/5b8858cc/attachment.bin>


More information about the llvm-commits mailing list