[PATCH] D15625: Add iOS/watchOS/tvOS support for ASan (llvm part)

Anna Zaks via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 12:42:38 PST 2015


zaks.anna created this revision.
zaks.anna added reviewers: llvm-commits, kcc.

Set the shadow region on iOS/watchOS/tvOS.

This change along with the corresponding changes in clang and compiler-rt completes ASan support for iOS/watchOS/tvOS.

http://reviews.llvm.org/D15625

Files:
  lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -67,6 +67,9 @@
 static const uint64_t kDefaultShadowOffset32 = 1ULL << 29;
 static const uint64_t kIOSShadowOffset32 = 1ULL << 30;
 static const uint64_t kDefaultShadowOffset64 = 1ULL << 44;
+static const uint64_t kIOSShadowOffset64 = 0x120200000;
+static const uint64_t kIOSSimShadowOffset32 = 1ULL << 30;
+static const uint64_t kIOSSimShadowOffset64 = kDefaultShadowOffset64;
 static const uint64_t kSmallX86_64ShadowOffset = 0x7FFF8000;  // < 2G.
 static const uint64_t kLinuxKasan_ShadowOffset64 = 0xdffffc0000000000;
 static const uint64_t kPPC64_ShadowOffset64 = 1ULL << 41;
@@ -334,11 +337,12 @@
 static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
                                       bool IsKasan) {
   bool IsAndroid = TargetTriple.isAndroid();
-  bool IsIOS = TargetTriple.isiOS();
+  bool IsIOS = TargetTriple.isiOS() || TargetTriple.isWatchOS();
   bool IsFreeBSD = TargetTriple.isOSFreeBSD();
   bool IsLinux = TargetTriple.isOSLinux();
   bool IsPPC64 = TargetTriple.getArch() == llvm::Triple::ppc64 ||
                  TargetTriple.getArch() == llvm::Triple::ppc64le;
+  bool IsX86 = TargetTriple.getArch() == llvm::Triple::x86;
   bool IsX86_64 = TargetTriple.getArch() == llvm::Triple::x86_64;
   bool IsMIPS32 = TargetTriple.getArch() == llvm::Triple::mips ||
                   TargetTriple.getArch() == llvm::Triple::mipsel;
@@ -358,6 +362,8 @@
       Mapping.Offset = kMIPS32_ShadowOffset32;
     else if (IsFreeBSD)
       Mapping.Offset = kFreeBSD_ShadowOffset32;
+    else if (IsIOS && IsX86)
+      Mapping.Offset = kIOSSimShadowOffset32;
     else if (IsIOS)
       Mapping.Offset = kIOSShadowOffset32;
     else if (IsWindows)
@@ -376,6 +382,10 @@
         Mapping.Offset = kSmallX86_64ShadowOffset;
     } else if (IsMIPS64)
       Mapping.Offset = kMIPS64_ShadowOffset64;
+    else if (IsIOS && IsX86_64)
+      Mapping.Offset = kIOSSimShadowOffset64;
+    else if (IsIOS)
+      Mapping.Offset = kIOSShadowOffset64;
     else if (IsAArch64)
       Mapping.Offset = kAArch64_ShadowOffset64;
     else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15625.43172.patch
Type: text/x-patch
Size: 2298 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151217/66914f10/attachment.bin>


More information about the llvm-commits mailing list