[compiler-rt] r182376 - [lsan] LSan in LD_PRELOAD library form.

Sergey Matveev earthdok at google.com
Tue May 21 05:49:33 PDT 2013


Author: smatveev
Date: Tue May 21 07:49:33 2013
New Revision: 182376

URL: http://llvm.org/viewvc/llvm-project?rev=182376&view=rev
Log:
[lsan] LSan in LD_PRELOAD library form.

Added:
    compiler-rt/trunk/lib/lsan/tests/lsan_testlib.cc

Added: compiler-rt/trunk/lib/lsan/tests/lsan_testlib.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/tests/lsan_testlib.cc?rev=182376&view=auto
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/lsan_testlib.cc (added)
+++ compiler-rt/trunk/lib/lsan/tests/lsan_testlib.cc Tue May 21 07:49:33 2013
@@ -0,0 +1,31 @@
+//===-- lsan_testlib.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.
+// Standalone LSan tool as a shared library, to be used with LD_PRELOAD.
+//
+//===----------------------------------------------------------------------===//
+/* Usage:
+clang++ ../sanitizer_common/sanitizer_*.cc ../interception/interception_*.cc \
+ lsan*.cc tests/lsan_testlib.cc -I. -I.. -g -ldl -lpthread -fPIC -shared -O2 \
+ -o lsan.so
+LD_PRELOAD=./lsan.so /your/app
+*/
+#include "lsan_common.h"
+#include "lsan.h"
+
+__attribute__((constructor))
+void constructor() {
+  __lsan::Init();
+}
+
+__attribute__((destructor))
+void destructor() {
+  __lsan::DoLeakCheck();
+}





More information about the llvm-commits mailing list