summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-devel/llvm/files/compiler-rt-3.7-msan-fix.patch')
-rw-r--r--sys-devel/llvm/files/compiler-rt-3.7-msan-fix.patch86
1 files changed, 86 insertions, 0 deletions
diff --git a/sys-devel/llvm/files/compiler-rt-3.7-msan-fix.patch b/sys-devel/llvm/files/compiler-rt-3.7-msan-fix.patch
new file mode 100644
index 00000000000..3854a18497b
--- /dev/null
+++ b/sys-devel/llvm/files/compiler-rt-3.7-msan-fix.patch
@@ -0,0 +1,86 @@
+From 5dad120f9c9bc74c73edadb0467d8df81ae46066 Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Wed, 5 Aug 2015 05:34:27 -0700
+Subject: [PATCH 08/13] Apply split-layout-compiler-rt.patch
+
+https://llvm.org/bugs/show_bug.cgi?id=24155
+---
+ lib/msan/msan.h | 30 ++++++++++++++++++++----------
+ lib/msan/msan_allocator.cc | 12 +++++++++++-
+ 2 files changed, 31 insertions(+), 11 deletions(-)
+
+diff --git a/lib/msan/msan.h b/lib/msan/msan.h
+index cd8bc19..6251b38 100644
+--- a/lib/msan/msan.h
++++ b/lib/msan/msan.h
+@@ -94,17 +94,27 @@ const MappingDesc kMemoryLayout[] = {
+
+ #elif SANITIZER_LINUX && SANITIZER_WORDSIZE == 64
+
+-// Requries PIE binary and ASLR enabled.
+-// Main thread stack and DSOs at 0x7f0000000000 (sometimes 0x7e0000000000).
+-// Heap at 0x600000000000.
++// All of the following configurations are supported.
++// ASLR disabled: main executable and DSOs at 0x555550000000
++// PIE and ASLR: main executable and DSOs at 0x7f0000000000
++// non-PIE: main executable below 0x100000000, DSOs at 0x7f0000000000
++// Heap at 0x700000000000.
+ const MappingDesc kMemoryLayout[] = {
+- {0x000000000000ULL, 0x200000000000ULL, MappingDesc::INVALID, "invalid"},
+- {0x200000000000ULL, 0x400000000000ULL, MappingDesc::SHADOW, "shadow"},
+- {0x400000000000ULL, 0x600000000000ULL, MappingDesc::ORIGIN, "origin"},
+- {0x600000000000ULL, 0x800000000000ULL, MappingDesc::APP, "app"}};
+-
+-#define MEM_TO_SHADOW(mem) (((uptr)(mem)) & ~0x400000000000ULL)
+-#define SHADOW_TO_ORIGIN(mem) (((uptr)(mem)) + 0x200000000000ULL)
++ {0x000000000000ULL, 0x050000000000ULL, MappingDesc::APP, "app-1"},
++ {0x050000000000ULL, 0x100000000000ULL, MappingDesc::SHADOW, "shadow-2"},
++ {0x100000000000ULL, 0x150000000000ULL, MappingDesc::INVALID, "invalid"},
++ {0x150000000000ULL, 0x200000000000ULL, MappingDesc::ORIGIN, "origin-2"},
++ {0x200000000000ULL, 0x300000000000ULL, MappingDesc::SHADOW, "shadow-3"},
++ {0x300000000000ULL, 0x400000000000ULL, MappingDesc::ORIGIN, "origin-3"},
++ {0x400000000000ULL, 0x500000000000ULL, MappingDesc::INVALID, "invalid"},
++ {0x500000000000ULL, 0x550000000000ULL, MappingDesc::SHADOW, "shadow-1"},
++ {0x550000000000ULL, 0x600000000000ULL, MappingDesc::APP, "app-2"},
++ {0x600000000000ULL, 0x650000000000ULL, MappingDesc::ORIGIN, "origin-1"},
++ {0x650000000000ULL, 0x700000000000ULL, MappingDesc::INVALID, "invalid"},
++ {0x700000000000ULL, 0x800000000000ULL, MappingDesc::APP, "app-3"}};
++
++#define MEM_TO_SHADOW(mem) (((uptr)(mem)) ^ 0x500000000000ULL)
++#define SHADOW_TO_ORIGIN(mem) (((uptr)(mem)) + 0x100000000000ULL)
+
+ #else
+ #error "Unsupported platform"
+diff --git a/lib/msan/msan_allocator.cc b/lib/msan/msan_allocator.cc
+index 6df3566..e588bf8 100644
+--- a/lib/msan/msan_allocator.cc
++++ b/lib/msan/msan_allocator.cc
+@@ -49,7 +49,8 @@ struct MsanMapUnmapCallback {
+ typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE, sizeof(Metadata),
+ SizeClassMap, kRegionSizeLog, ByteMap,
+ MsanMapUnmapCallback> PrimaryAllocator;
+-#elif defined(__x86_64__)
++
++#elif SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 64
+ static const uptr kAllocatorSpace = 0x600000000000ULL;
+ static const uptr kAllocatorSize = 0x80000000000; // 8T.
+ static const uptr kMetadataSize = sizeof(Metadata);
+@@ -67,6 +68,15 @@ struct MsanMapUnmapCallback {
+ typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, kMetadataSize,
+ DefaultSizeClassMap,
+ MsanMapUnmapCallback> PrimaryAllocator;
++#elif SANITIZER_LINUX && SANITIZER_WORDSIZE == 64
++ static const uptr kAllocatorSpace = 0x700000000000ULL;
++ static const uptr kAllocatorSize = 0x80000000000; // 8T.
++ static const uptr kMetadataSize = sizeof(Metadata);
++ static const uptr kMaxAllowedMallocSize = 8UL << 30;
++
++ typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, kMetadataSize,
++ DefaultSizeClassMap,
++ MsanMapUnmapCallback> PrimaryAllocator;
+ #endif
+ typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
+ typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator;
+--
+2.6.4
+