[PATCH] D23634: [asan] Initialize __asan_set_shadow_* callbacks

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 16:31:10 PDT 2016


vitalybuka created this revision.
vitalybuka added reviewers: kcc, eugenis.
vitalybuka added a subscriber: llvm-commits.

Callbacks are not being used yet.

PR27453

https://reviews.llvm.org/D23634

Files:
  lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -54,6 +54,7 @@
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 #include "llvm/Transforms/Utils/PromoteMemToReg.h"
 #include <algorithm>
+#include <cstdlib>
 #include <string>
 #include <system_error>
 
@@ -111,6 +112,12 @@
 static const char *const kAsanGenPrefix = "__asan_gen_";
 static const char *const kODRGenPrefix = "__odr_asan_gen_";
 static const char *const kSanCovGenPrefix = "__sancov_gen_";
+static const char *const kAsanSetShadow00Func = "__asan_set_shadow_00";
+static const char *const kAsanSetShadowf1Func = "__asan_set_shadow_f1";
+static const char *const kAsanSetShadowf2Func = "__asan_set_shadow_f2";
+static const char *const kAsanSetShadowf3Func = "__asan_set_shadow_f3";
+static const char *const kAsanSetShadowf5Func = "__asan_set_shadow_f5";
+static const char *const kAsanSetShadowf8Func = "__asan_set_shadow_f8";
 static const char *const kAsanPoisonStackMemoryName =
     "__asan_poison_stack_memory";
 static const char *const kAsanUnpoisonStackMemoryName =
@@ -612,6 +619,7 @@
 
   Function *AsanStackMallocFunc[kMaxAsanStackMallocSizeClass + 1],
       *AsanStackFreeFunc[kMaxAsanStackMallocSizeClass + 1];
+  Function *AsanSetShadowFunc[1 << sizeof(uint8_t)] = {};
   Function *AsanPoisonStackMemoryFunc, *AsanUnpoisonStackMemoryFunc;
   Function *AsanAllocaPoisonFunc, *AsanAllocasUnpoisonFunc;
 
@@ -1919,6 +1927,15 @@
                               IntptrTy, IntptrTy, nullptr));
   }
 
+  for (const char *Name :
+       {kAsanSetShadow00Func, kAsanSetShadowf1Func, kAsanSetShadowf2Func,
+        kAsanSetShadowf3Func, kAsanSetShadowf5Func, kAsanSetShadowf8Func}) {
+    char *End = 0;
+    AsanSetShadowFunc[std::strtoul(Name + strlen(Name) - 2, &End, 16)] =
+        checkSanitizerInterfaceFunction(M.getOrInsertFunction(
+            Name, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
+  }
+
   AsanAllocaPoisonFunc = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
       kAsanAllocaPoison, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
   AsanAllocasUnpoisonFunc =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23634.68450.patch
Type: text/x-patch
Size: 2263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160817/f22758f4/attachment.bin>


More information about the llvm-commits mailing list