summaryrefslogtreecommitdiffstats
path: root/contrib/compiler-rt/lib/lsan/lsan_preinit.cc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/compiler-rt/lib/lsan/lsan_preinit.cc')
-rw-r--r--contrib/compiler-rt/lib/lsan/lsan_preinit.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/contrib/compiler-rt/lib/lsan/lsan_preinit.cc b/contrib/compiler-rt/lib/lsan/lsan_preinit.cc
new file mode 100644
index 0000000..5a190959
--- /dev/null
+++ b/contrib/compiler-rt/lib/lsan/lsan_preinit.cc
@@ -0,0 +1,22 @@
+//===-- lsan_preinit.cc ---------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of LeakSanitizer.
+//
+// Call __lsan_init at the very early stage of process startup.
+//===----------------------------------------------------------------------===//
+
+#include "lsan.h"
+
+#if SANITIZER_CAN_USE_PREINIT_ARRAY
+ // We force __lsan_init to be called before anyone else by placing it into
+ // .preinit_array section.
+ __attribute__((section(".preinit_array"), used))
+ void (*__local_lsan_preinit)(void) = __lsan_init;
+#endif
OpenPOWER on IntegriCloud