From: Bill Seurer Date: Thu, 7 Dec 2017 22:53:33 +0000 (+0000) Subject: [PowerPC][asan] Update asan to handle changed memory layouts in newer kernels X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f299aeb363d95582a03ad196f9fc011c57b5515;p=llvm [PowerPC][asan] Update asan to handle changed memory layouts in newer kernels In more recent Linux kernels with 47 bit VMAs the layout of virtual memory for powerpc64 changed causing the address sanitizer to not work properly. This patch adds support for 47 bit VMA kernels for powerpc64 and fixes up test cases. https://reviews.llvm.org/D40907 There is an associated patch for compiler-rt. Tested on several 4.x and 3.x kernel releases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320109 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index c707dfc0b50..dc17aa6cbd5 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -100,7 +100,7 @@ static const uint64_t kIOSSimShadowOffset64 = kDefaultShadowOffset64; static const uint64_t kSmallX86_64ShadowOffsetBase = 0x7FFFFFFF; // < 2G. static const uint64_t kSmallX86_64ShadowOffsetAlignMask = ~0xFFFULL; static const uint64_t kLinuxKasan_ShadowOffset64 = 0xdffffc0000000000; -static const uint64_t kPPC64_ShadowOffset64 = 1ULL << 41; +static const uint64_t kPPC64_ShadowOffset64 = 1ULL << 44; static const uint64_t kSystemZ_ShadowOffset64 = 1ULL << 52; static const uint64_t kMIPS32_ShadowOffset32 = 0x0aaa0000; static const uint64_t kMIPS64_ShadowOffset64 = 1ULL << 37; diff --git a/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll b/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll index 569a67d6d35..3bdf2639ca1 100644 --- a/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll +++ b/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll @@ -20,7 +20,7 @@ entry: %z = alloca [40 x i8], align 1 %zz = getelementptr inbounds [40 x i8], [40 x i8]* %z, i64 0, i64 0 - ; CHECK: [[SHADOW_BASE:%[0-9]+]] = add i64 %{{[0-9]+}}, 2199023255552 + ; CHECK: [[SHADOW_BASE:%[0-9]+]] = add i64 %{{[0-9]+}}, 17592186044416 ; F1F1F1F1 ; ENTRY-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 0