From: Adhemerval Zanella Date: Wed, 16 Sep 2015 15:10:27 +0000 (+0000) Subject: [sanitizer] Add MSan support for AArch64 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5f57416779109b38f80797b7294c2549aa938ccb;p=oota-llvm.git [sanitizer] Add MSan support for AArch64 This patch adds support for msan on aarch64-linux for both 39 and 42-bit VMA. The support is enabled by defining the SANITIZER_AARCH64_VMA compiler flag to either 39 or 42 at build time for both clang/llvm and compiler-rt. The default VMA is 39 bits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247807 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp index be8e25505ca..3c0c768c23a 100644 --- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -120,6 +120,16 @@ using namespace llvm; #define DEBUG_TYPE "msan" +// VMA size definition for architecture that support multiple sizes. +// AArch64 has 3 VMA sizes: 39, 42 and 48. +#ifndef SANITIZER_AARCH64_VMA +# define SANITIZER_AARCH64_VMA 39 +#else +# if SANITIZER_AARCH64_VMA != 39 && SANITIZER_AARCH64_VMA != 42 +# error "invalid SANITIZER_AARCH64_VMA size" +# endif +#endif + static const unsigned kOriginSize = 4; static const unsigned kMinOriginAlignment = 4; static const unsigned kShadowTLSAlignment = 8; @@ -244,6 +254,21 @@ static const MemoryMapParams Linux_PowerPC64_MemoryMapParams = { 0x1C0000000000, // OriginBase }; +// aarch64 Linux +static const MemoryMapParams Linux_AArch64_MemoryMapParams = { +#if SANITIZER_AARCH64_VMA == 39 + 0x007C00000000, // AndMask + 0x000100000000, // XorMask + 0x004000000000, // ShadowBase + 0x004300000000, // OriginBase +#elif SANITIZER_AARCH64_VMA == 42 + 0x03E000000000, // AndMask + 0x001000000000, // XorMask + 0x010000000000, // ShadowBase + 0x012000000000, // OriginBase +#endif +}; + // i386 FreeBSD static const MemoryMapParams FreeBSD_I386_MemoryMapParams = { 0x000180000000, // AndMask @@ -275,6 +300,11 @@ static const PlatformMemoryMapParams Linux_PowerPC_MemoryMapParams = { &Linux_PowerPC64_MemoryMapParams, }; +static const PlatformMemoryMapParams Linux_ARM_MemoryMapParams = { + NULL, + &Linux_AArch64_MemoryMapParams, +}; + static const PlatformMemoryMapParams FreeBSD_X86_MemoryMapParams = { &FreeBSD_I386_MemoryMapParams, &FreeBSD_X86_64_MemoryMapParams, @@ -496,6 +526,10 @@ bool MemorySanitizer::doInitialization(Module &M) { case Triple::ppc64le: MapParams = Linux_PowerPC_MemoryMapParams.bits64; break; + case Triple::aarch64: + case Triple::aarch64_be: + MapParams = Linux_ARM_MemoryMapParams.bits64; + break; default: report_fatal_error("unsupported architecture"); }