[llvm] r247807 - [sanitizer] Add MSan support for AArch64
Adhemerval Zanella via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 08:10:27 PDT 2015
Author: azanella
Date: Wed Sep 16 10:10:27 2015
New Revision: 247807
URL: http://llvm.org/viewvc/llvm-project?rev=247807&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=247807&r1=247806&r2=247807&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Wed Sep 16 10:10:27 2015
@@ -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_Power
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 Lin
&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(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");
}
More information about the llvm-commits
mailing list