summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-06-03 19:40:37 +0000
committerDerek Bruening <bruening@google.com>2016-06-03 19:40:37 +0000
commit4252a16c35cae62204ce074ae4302cb45db1169e (patch)
tree8c973742ad1f8a8819dd68c6b718ac0f6897c863 /llvm/lib/Transforms
parent328e899301ed187ed7490e7443c897049b0e4200 (diff)
downloadbcm5719-llvm-4252a16c35cae62204ce074ae4302cb45db1169e.tar.gz
bcm5719-llvm-4252a16c35cae62204ce074ae4302cb45db1169e.zip
[esan] Specify which tool via a global variable
Summary: Adds a global variable to specify the tool, to support handling early interceptors that invoke instrumented code and require shadow memory to be initialized prior to __esan_init() being invoked. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits Differential Revision: http://reviews.llvm.org/D20973 llvm-svn: 271715
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
index d29d400e72e..da3e0ca9efd 100644
--- a/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
@@ -72,6 +72,10 @@ static const char *const EsanModuleDtorName = "esan.module_dtor";
static const char *const EsanInitName = "__esan_init";
static const char *const EsanExitName = "__esan_exit";
+// We need to specify the tool to the runtime earlier than
+// the ctor is called in some cases, so we set a global variable.
+static const char *const EsanWhichToolName = "__esan_which_tool";
+
// We must keep these Shadow* constants consistent with the esan runtime.
// FIXME: Try to place these shadow constants, the names of the __esan_*
// interface functions, and the ToolType enum into a header shared between
@@ -430,6 +434,8 @@ bool EfficiencySanitizer::initOnModule(Module &M) {
// Create the variable passed to EsanInit and EsanExit.
Constant *ToolInfoArg = createEsanInitToolInfoArg(M);
// Constructor
+ // We specify the tool type both in the EsanWhichToolName global
+ // and as an arg to the init routine as a sanity check.
std::tie(EsanCtorFunction, std::ignore) = createSanitizerCtorAndInitFunctions(
M, EsanModuleCtorName, EsanInitName, /*InitArgTypes=*/{OrdTy, Int8PtrTy},
/*InitArgs=*/{
@@ -438,6 +444,13 @@ bool EfficiencySanitizer::initOnModule(Module &M) {
appendToGlobalCtors(M, EsanCtorFunction, EsanCtorAndDtorPriority);
createDestructor(M, ToolInfoArg);
+
+ new GlobalVariable(M, OrdTy, true,
+ GlobalValue::WeakAnyLinkage,
+ ConstantInt::get(OrdTy,
+ static_cast<int>(Options.ToolType)),
+ EsanWhichToolName);
+
return true;
}
OpenPOWER on IntegriCloud