summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2015-12-27 23:47:38 +0100
committerMichał Górny <mgorny@gentoo.org>2015-12-27 23:51:59 +0100
commit4ea0768355d83631d0baf5c7de9b712ea2ebe12a (patch)
tree15fa6bc310c84f248d57d749f59db7c1442f2bbd /sys-devel/llvm/files/llvm-3.7-msan-fix.patch
parentdev-util/plan9port: add prefix support, bug #567260 (diff)
downloadgentoo-4ea0768355d83631d0baf5c7de9b712ea2ebe12a.tar.gz
gentoo-4ea0768355d83631d0baf5c7de9b712ea2ebe12a.tar.bz2
gentoo-4ea0768355d83631d0baf5c7de9b712ea2ebe12a.zip
sys-devel/llvm: Backport msan fix for 4.1+ kernels, bug #569894
Diffstat (limited to 'sys-devel/llvm/files/llvm-3.7-msan-fix.patch')
-rw-r--r--sys-devel/llvm/files/llvm-3.7-msan-fix.patch79
1 files changed, 79 insertions, 0 deletions
diff --git a/sys-devel/llvm/files/llvm-3.7-msan-fix.patch b/sys-devel/llvm/files/llvm-3.7-msan-fix.patch
new file mode 100644
index 00000000000..e44baa8a516
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.7-msan-fix.patch
@@ -0,0 +1,79 @@
+From 8b0f2fff6e080c053e4fd94d44a694768b8c156e Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Wed, 5 Aug 2015 05:35:26 -0700
+Subject: [PATCH 78/84] Apply split-layout-llvm.patch
+
+https://llvm.org/bugs/show_bug.cgi?id=24155
+---
+ lib/Transforms/Instrumentation/MemorySanitizer.cpp | 31 ++++++++++++++++------
+ 1 file changed, 23 insertions(+), 8 deletions(-)
+
+diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+index 286a563..2ab8bfc 100644
+--- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp
++++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+@@ -194,6 +194,12 @@ static cl::opt<bool> ClCheckConstantShadow("msan-check-constant-shadow",
+ static const char *const kMsanModuleCtorName = "msan.module_ctor";
+ static const char *const kMsanInitName = "__msan_init";
+
++static cl::opt<bool> ClSplitLayout(
++ "msan-split-layout", cl::desc(
++ "use experimental memory layout compatible with "
++ "non-pie and non-aslr execution"),
++ cl::Hidden, cl::init(true));
++
+ namespace {
+
+ // Memory map parameters used in application-to-shadow address calculation.
+@@ -228,6 +234,13 @@ static const MemoryMapParams Linux_X86_64_MemoryMapParams = {
+ 0x200000000000, // OriginBase
+ };
+
++static const MemoryMapParams Linux_X86_64_Split_MemoryMapParams = {
++ 0, // AndMask (not used)
++ 0x500000000000, // XorMask
++ 0, // ShadowBase (not used)
++ 0x100000000000, // OriginBase
++};
++
+ // mips64 Linux
+ static const MemoryMapParams Linux_MIPS64_MemoryMapParams = {
+ 0x004000000000, // AndMask
+@@ -483,7 +496,8 @@ bool MemorySanitizer::doInitialization(Module &M) {
+ case Triple::Linux:
+ switch (TargetTriple.getArch()) {
+ case Triple::x86_64:
+- MapParams = Linux_X86_MemoryMapParams.bits64;
++ MapParams = ClSplitLayout ? &Linux_X86_64_Split_MemoryMapParams
++ : Linux_X86_MemoryMapParams.bits64;
+ break;
+ case Triple::x86:
+ MapParams = Linux_X86_MemoryMapParams.bits32;
+@@ -893,16 +907,17 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
+ ///
+ /// Offset = (Addr & ~AndMask) ^ XorMask
+ Value *getShadowPtrOffset(Value *Addr, IRBuilder<> &IRB) {
++ Value *OffsetLong = IRB.CreatePointerCast(Addr, MS.IntptrTy);
++
+ uint64_t AndMask = MS.MapParams->AndMask;
+- assert(AndMask != 0 && "AndMask shall be specified");
+- Value *OffsetLong =
+- IRB.CreateAnd(IRB.CreatePointerCast(Addr, MS.IntptrTy),
+- ConstantInt::get(MS.IntptrTy, ~AndMask));
++ if (AndMask)
++ OffsetLong =
++ IRB.CreateAnd(OffsetLong, ConstantInt::get(MS.IntptrTy, ~AndMask));
+
+ uint64_t XorMask = MS.MapParams->XorMask;
+- if (XorMask != 0)
+- OffsetLong = IRB.CreateXor(OffsetLong,
+- ConstantInt::get(MS.IntptrTy, XorMask));
++ if (XorMask)
++ OffsetLong =
++ IRB.CreateXor(OffsetLong, ConstantInt::get(MS.IntptrTy, XorMask));
+ return OffsetLong;
+ }
+
+--
+2.6.4
+