[compiler-rt] r278793 - [MSAN][MIPS] Changed memory mapping to support pie executable.
Sagar Thakur via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 16 05:49:55 PDT 2016
Author: slthakur
Date: Tue Aug 16 07:49:54 2016
New Revision: 278793
URL: http://llvm.org/viewvc/llvm-project?rev=278793&view=rev
Log:
[MSAN][MIPS] Changed memory mapping to support pie executable.
Reviewed by eugenis
Differential: D22993
Modified:
compiler-rt/trunk/lib/msan/msan.h
compiler-rt/trunk/test/msan/mmap.cc
compiler-rt/trunk/test/msan/strlen_of_shadow.cc
Modified: compiler-rt/trunk/lib/msan/msan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.h?rev=278793&r1=278792&r2=278793&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.h (original)
+++ compiler-rt/trunk/lib/msan/msan.h Tue Aug 16 07:49:54 2016
@@ -42,15 +42,27 @@ struct MappingDesc {
#if SANITIZER_LINUX && defined(__mips64)
-// Everything is above 0x00e000000000.
+// MIPS64 maps:
+// - 0x0000000000-0x0200000000: Program own segments
+// - 0xa200000000-0xc000000000: PIE program segments
+// - 0xe200000000-0xffffffffff: libraries segments.
const MappingDesc kMemoryLayout[] = {
- {0x000000000000ULL, 0x00a000000000ULL, MappingDesc::INVALID, "invalid"},
- {0x00a000000000ULL, 0x00c000000000ULL, MappingDesc::SHADOW, "shadow"},
- {0x00c000000000ULL, 0x00e000000000ULL, MappingDesc::ORIGIN, "origin"},
- {0x00e000000000ULL, 0x010000000000ULL, MappingDesc::APP, "app"}};
+ {0x000000000000ULL, 0x000200000000ULL, MappingDesc::APP, "app-1"},
+ {0x000200000000ULL, 0x002200000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x002200000000ULL, 0x004000000000ULL, MappingDesc::SHADOW, "shadow-2"},
+ {0x004000000000ULL, 0x004200000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x004200000000ULL, 0x006000000000ULL, MappingDesc::ORIGIN, "origin-2"},
+ {0x006000000000ULL, 0x006200000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x006200000000ULL, 0x008000000000ULL, MappingDesc::SHADOW, "shadow-3"},
+ {0x008000000000ULL, 0x008200000000ULL, MappingDesc::SHADOW, "shadow-1"},
+ {0x008200000000ULL, 0x00a000000000ULL, MappingDesc::ORIGIN, "origin-3"},
+ {0x00a000000000ULL, 0x00a200000000ULL, MappingDesc::ORIGIN, "origin-1"},
+ {0x00a200000000ULL, 0x00c000000000ULL, MappingDesc::APP, "app-2"},
+ {0x00c000000000ULL, 0x00e200000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x00e200000000ULL, 0x00ffffffffffULL, MappingDesc::APP, "app-3"}};
-#define MEM_TO_SHADOW(mem) (((uptr)(mem)) & ~0x4000000000ULL)
-#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x002000000000)
+#define MEM_TO_SHADOW(mem) (((uptr)(mem)) ^ 0x8000000000ULL)
+#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x2000000000ULL)
#elif SANITIZER_LINUX && defined(__aarch64__)
Modified: compiler-rt/trunk/test/msan/mmap.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/mmap.cc?rev=278793&r1=278792&r2=278793&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/mmap.cc (original)
+++ compiler-rt/trunk/test/msan/mmap.cc Tue Aug 16 07:49:54 2016
@@ -19,7 +19,9 @@ bool AddrIsApp(void *p) {
(addr >= 0x510000000000ULL && addr < 0x600000000000ULL) ||
(addr >= 0x700000000000ULL && addr < 0x800000000000ULL);
#elif defined(__mips64)
- return addr >= 0x00e000000000ULL;
+ return (addr >= 0x0000000000ULL && addr <= 0x0200000000ULL) ||
+ (addr >= 0xa200000000ULL && addr <= 0xc000000000ULL) ||
+ addr >= 0xe200000000ULL;
#elif defined(__powerpc64__)
return addr < 0x000100000000ULL || addr >= 0x300000000000ULL;
#elif defined(__aarch64__)
Modified: compiler-rt/trunk/test/msan/strlen_of_shadow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/strlen_of_shadow.cc?rev=278793&r1=278792&r2=278793&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/strlen_of_shadow.cc (original)
+++ compiler-rt/trunk/test/msan/strlen_of_shadow.cc Tue Aug 16 07:49:54 2016
@@ -14,7 +14,7 @@ const char *mem_to_shadow(const char *p)
#if defined(__x86_64__)
return (char *)((uintptr_t)p ^ 0x500000000000ULL);
#elif defined (__mips64)
- return (char *)((uintptr_t)p & ~0x4000000000ULL);
+ return (char *)((uintptr_t)p ^ 0x8000000000ULL);
#elif defined(__powerpc64__)
#define LINEARIZE_MEM(mem) \
(((uintptr_t)(mem) & ~0x200000000000ULL) ^ 0x100000000000ULL)
More information about the llvm-commits
mailing list