]> granicus.if.org Git - llvm/commitdiff
[AddressSanitizer] Put shadow at 0 for Fuchsia
authorPetr Hosek <phosek@chromium.org>
Mon, 27 Feb 2017 22:49:37 +0000 (22:49 +0000)
committerPetr Hosek <phosek@chromium.org>
Mon, 27 Feb 2017 22:49:37 +0000 (22:49 +0000)
The Fuchsia ASan runtime reserves the low part of the address space.

Patch by Roland McGrath

Differential Revision: https://reviews.llvm.org/D30426

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296405 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/AddressSanitizer.cpp

index 5b719a5bd1f2e37419f9e686179f3f17f37b977c..afcf86547c7818d2b4d5b7b34ad9f04d7d739b72 100644 (file)
@@ -394,6 +394,7 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
                   TargetTriple.getArch() == llvm::Triple::mips64el;
   bool IsAArch64 = TargetTriple.getArch() == llvm::Triple::aarch64;
   bool IsWindows = TargetTriple.isOSWindows();
+  bool IsFuchsia = TargetTriple.isOSFuchsia();
 
   ShadowMapping Mapping;
 
@@ -414,7 +415,11 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
     else
       Mapping.Offset = kDefaultShadowOffset32;
   } else {  // LongSize == 64
-    if (IsPPC64)
+    // Fuchsia is always PIE, which means that the beginning of the address
+    // space is always available.
+    if (IsFuchsia)
+      Mapping.Offset = 0;
+    else if (IsPPC64)
       Mapping.Offset = kPPC64_ShadowOffset64;
     else if (IsSystemZ)
       Mapping.Offset = kSystemZ_ShadowOffset64;