summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-05-24 22:22:20 +0000
committerDerek Bruening <bruening@google.com>2016-05-24 22:22:20 +0000
commit7004e06b806d5700285320c21f1e5483c84e6c5c (patch)
tree222c05f67f3bfc6e89c7b2b92c80d5c799badb1c
parent90a55651e6222d52da2ffbae87e3e25194a60afd (diff)
downloadbcm5719-llvm-7004e06b806d5700285320c21f1e5483c84e6c5c.tar.gz
bcm5719-llvm-7004e06b806d5700285320c21f1e5483c84e6c5c.zip
[esan] Add compilation unit init/exit routines.
Summary: Adds processCompilationUnitInit and processCompilationUnitExit for compilation unit init/exit. Adds a tool-specific argument passed to esan_init. Adds the dtor and esan_exit called from the dtor. A test will be added separately (adding it here results in failure until the corresponding compilation patch is in place). Reviewers: aizatsky Subscribers: kubabrecka, bruening, kcc, vitalybuka, eugenis, llvm-commits Differential Revision: http://reviews.llvm.org/D20486 llvm-svn: 270624
-rw-r--r--compiler-rt/lib/esan/esan.cpp10
-rw-r--r--compiler-rt/lib/esan/esan.h4
-rw-r--r--compiler-rt/lib/esan/esan.syms.extra1
-rw-r--r--compiler-rt/lib/esan/esan_interface.cpp8
-rw-r--r--compiler-rt/lib/esan/esan_interface_internal.h3
5 files changed, 24 insertions, 2 deletions
diff --git a/compiler-rt/lib/esan/esan.cpp b/compiler-rt/lib/esan/esan.cpp
index 1499895eb72..746575f669f 100644
--- a/compiler-rt/lib/esan/esan.cpp
+++ b/compiler-rt/lib/esan/esan.cpp
@@ -179,4 +179,14 @@ int finalizeLibrary() {
return 0;
}
+void processCompilationUnitInit(void *Ptr) {
+ VPrintf(2, "in esan::%s\n", __FUNCTION__);
+}
+
+// This is called when the containing module is unloaded.
+// For the main executable module, this is called after finalizeLibrary.
+void processCompilationUnitExit(void *Ptr) {
+ VPrintf(2, "in esan::%s\n", __FUNCTION__);
+}
+
} // namespace __esan
diff --git a/compiler-rt/lib/esan/esan.h b/compiler-rt/lib/esan/esan.h
index c231d3c21a9..2dc8d1991f7 100644
--- a/compiler-rt/lib/esan/esan.h
+++ b/compiler-rt/lib/esan/esan.h
@@ -37,6 +37,10 @@ extern ToolType WhichTool;
void initializeLibrary(ToolType Tool);
int finalizeLibrary();
+// Esan creates the variable per tool per compilation unit at compile time
+// and passes its pointer Ptr to the runtime library.
+void processCompilationUnitInit(void *Ptr);
+void processCompilationUnitExit(void *Ptr);
void processRangeAccess(uptr PC, uptr Addr, int Size, bool IsWrite);
void initializeInterceptors();
diff --git a/compiler-rt/lib/esan/esan.syms.extra b/compiler-rt/lib/esan/esan.syms.extra
index bef023d5f39..d6397d4c350 100644
--- a/compiler-rt/lib/esan/esan.syms.extra
+++ b/compiler-rt/lib/esan/esan.syms.extra
@@ -1,3 +1,4 @@
__esan_init
+__esan_exit
__esan_aligned*
__esan_unaligned*
diff --git a/compiler-rt/lib/esan/esan_interface.cpp b/compiler-rt/lib/esan/esan_interface.cpp
index f8a562e55d0..5b10f7f2e82 100644
--- a/compiler-rt/lib/esan/esan_interface.cpp
+++ b/compiler-rt/lib/esan/esan_interface.cpp
@@ -17,8 +17,14 @@
using namespace __esan; // NOLINT
-void __esan_init(ToolType Tool) {
+void __esan_init(ToolType Tool, void *Ptr) {
+ WhichTool = Tool;
initializeLibrary(Tool);
+ processCompilationUnitInit(Ptr);
+}
+
+void __esan_exit(void *Ptr) {
+ processCompilationUnitExit(Ptr);
}
void __esan_aligned_load1(void *Addr) {
diff --git a/compiler-rt/lib/esan/esan_interface_internal.h b/compiler-rt/lib/esan/esan_interface_internal.h
index a8b9e0887e6..577c7e3cf9e 100644
--- a/compiler-rt/lib/esan/esan_interface_internal.h
+++ b/compiler-rt/lib/esan/esan_interface_internal.h
@@ -32,7 +32,8 @@ typedef enum Type : u32 {
// This function should be called at the very beginning of the process,
// before any instrumented code is executed and before any call to malloc.
-SANITIZER_INTERFACE_ATTRIBUTE void __esan_init(ToolType Tool);
+SANITIZER_INTERFACE_ATTRIBUTE void __esan_init(ToolType Tool, void *Ptr);
+SANITIZER_INTERFACE_ATTRIBUTE void __esan_exit(void *Ptr);
// The instrumentation module will insert a call to one of these routines prior
// to each load and store instruction for which we do not have "fastpath"
OpenPOWER on IntegriCloud