From 9065ada9b5fa30d47ec723fbfbbeaad1082035cb Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Fri, 22 Nov 2013 22:13:08 +0100
Subject: [PATCH] re PR sanitizer/59061 (Port leaksanitizer)

	PR sanitizer/59061
	* common.opt (static-liblsan): Add.
	* config/gnu-user.h (STATIC_LIBLSAN_LIBS, STATIC_LIBUBSAN_LIBS):
	Define.
	* flag-types.h (enum sanitize_code): Add SANITIZE_LEAK.  Renumber
	SANITIZE_SHIFT, SANITIZE_DIVIDE, SANITIZE_UNREACHABLE, SANITIZE_VLA,
	SANITIZE_RETURN.
	* opts.c (common_handle_option): Handle -fsanitize=leak.
	* gcc.c (ADD_STATIC_LIBLSAN_LIBS, LIBLSAN_SPEC): Define.
	(LIBUBSAN_SPEC): Don't test LIBUBSAN_EARLY_SPEC.
	(LIBUBSAN_EARLY_SPEC): Remove.
	(SANITIZER_EARLY_SPEC): Don't do anything for libubsan.
	(SANITIZER_SPEC): Add -fsanitize=leak handling.
	(sanitize_spec_function): Handle %sanitize(leak).
	* doc/invoke.texi (-static-liblsan, -fsanitize=leak): Document.

	* c-c++-common/asan/no-redundant-instrumentation-7.c: Fix
	cleanup-tree-dump directive.

	* configure.tgt: Set LSAN_SUPPORTED=yes for x86_64-linux.
	* configure.ac (LSAN_SUPPORTED): New AM_CONDITIONAL.
	* configure: Regenerated.
	* lsan/Makefile.am (toolexeclib_LTLIBRARIES, lsan_files,
	liblsan_la_SOURCES, liblsan_la_LIBADD, liblsan_la_LDFLAGS): Add.
	* lsan/Makefile.in: Regenerated.

From-SVN: r205290
---
 gcc/ChangeLog                                 |  18 +++
 gcc/common.opt                                |   3 +
 gcc/config/gnu-user.h                         |   8 ++
 gcc/doc/invoke.texi                           |  18 ++-
 gcc/flag-types.h                              |  14 +-
 gcc/gcc.c                                     |  35 +++--
 gcc/opts.c                                    |   1 +
 gcc/testsuite/ChangeLog                       |   5 +
 .../asan/no-redundant-instrumentation-7.c     |   2 +-
 libsanitizer/ChangeLog                        |  10 ++
 libsanitizer/configure                        |  19 ++-
 libsanitizer/configure.ac                     |   2 +
 libsanitizer/configure.tgt                    |   1 +
 libsanitizer/lsan/Makefile.am                 |  14 ++
 libsanitizer/lsan/Makefile.in                 | 122 +++++++++++++++---
 15 files changed, 234 insertions(+), 38 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0757d157cc89..f298c0bef5e0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2013-11-22  Jakub Jelinek  <jakub@redhat.com>
+
+	PR sanitizer/59061
+	* common.opt (static-liblsan): Add.
+	* config/gnu-user.h (STATIC_LIBLSAN_LIBS, STATIC_LIBUBSAN_LIBS):
+	Define.
+	* flag-types.h (enum sanitize_code): Add SANITIZE_LEAK.  Renumber
+	SANITIZE_SHIFT, SANITIZE_DIVIDE, SANITIZE_UNREACHABLE, SANITIZE_VLA,
+	SANITIZE_RETURN.
+	* opts.c (common_handle_option): Handle -fsanitize=leak.
+	* gcc.c (ADD_STATIC_LIBLSAN_LIBS, LIBLSAN_SPEC): Define.
+	(LIBUBSAN_SPEC): Don't test LIBUBSAN_EARLY_SPEC.
+	(LIBUBSAN_EARLY_SPEC): Remove.
+	(SANITIZER_EARLY_SPEC): Don't do anything for libubsan.
+	(SANITIZER_SPEC): Add -fsanitize=leak handling.
+	(sanitize_spec_function): Handle %sanitize(leak).
+	* doc/invoke.texi (-static-liblsan, -fsanitize=leak): Document.
+
 2013-11-22  Aldy Hernandez  <aldyh@redhat.com>
 	    Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/common.opt b/gcc/common.opt
index 2216d6e0392e..a7af6369103c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2654,6 +2654,9 @@ Driver
 static-libtsan
 Driver
 
+static-liblsan
+Driver
+
 static-libubsan
 Driver
 
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 6f6915842b9e..157e147b188d 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -134,3 +134,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 /* Additional libraries needed by -static-libtsan.  */
 #undef STATIC_LIBTSAN_LIBS
 #define STATIC_LIBTSAN_LIBS "-ldl -lpthread"
+
+/* Additional libraries needed by -static-liblsan.  */
+#undef STATIC_LIBLSAN_LIBS
+#define STATIC_LIBLSAN_LIBS "-ldl -lpthread"
+
+/* Additional libraries needed by -static-libubsan.  */
+#undef STATIC_LIBUBSAN_LIBS
+#define STATIC_LIBUBSAN_LIBS "-ldl -lpthread"
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 7048b0bc16b2..0708836443aa 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -455,7 +455,7 @@ Objective-C and Objective-C++ Dialects}.
 @gccoptlist{@var{object-file-name}  -l@var{library} @gol
 -nostartfiles  -nodefaultlibs  -nostdlib -pie -rdynamic @gol
 -s  -static -static-libgcc -static-libstdc++ @gol
--static-libasan -static-libtsan -static-libubsan @gol
+-static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
 -shared -shared-libgcc  -symbolic @gol
 -T @var{script}  -Wl,@var{option}  -Xlinker @var{option} @gol
 -u @var{symbol}}
@@ -5269,6 +5269,13 @@ Memory access instructions will be instrumented to detect
 data race bugs.
 See @uref{http://code.google.com/p/data-race-test/wiki/ThreadSanitizer} for more details.
 
+@item -fsanitize=leak
+Enable LeakSanitizer, a memory leak detector.
+This option only matters for linking of executables and if neither
+@option{-fsanitize=address} nor @option{-fsanitize=thread} is used.  In that
+case it will link the executable against a library that overrides @code{malloc}
+and other allocator functions.
+
 @item -fsanitize=undefined
 Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
 Various computations will be instrumented to detect undefined behavior
@@ -10227,6 +10234,15 @@ option is not used, then this links against the shared version of
 driver to link @file{libtsan} statically, without necessarily linking
 other libraries statically.
 
+@item -static-liblsan
+When the @option{-fsanitize=leak} option is used to link a program,
+the GCC driver automatically links against @option{liblsan}.  If
+@file{liblsan} is available as a shared library, and the @option{-static}
+option is not used, then this links against the shared version of
+@file{liblsan}.  The @option{-static-liblsan} option directs the GCC
+driver to link @file{liblsan} statically, without necessarily linking
+other libraries statically.
+
 @item -static-libubsan
 When the @option{-fsanitize=undefined} option is used to link a program,
 the GCC driver automatically links against @option{libubsan}.  If
diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index 1d85a9aa4e85..5ba909766fe6 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -206,13 +206,15 @@ enum sanitize_code {
   SANITIZE_ADDRESS = 1 << 0,
   /* ThreadSanitizer.  */
   SANITIZE_THREAD = 1 << 1,
+  /* LeakSanitizer.  */
+  SANITIZE_LEAK = 1 << 2,
   /* UndefinedBehaviorSanitizer.  */
-  SANITIZE_SHIFT = 1 << 2,
-  SANITIZE_DIVIDE = 1 << 3,
-  SANITIZE_UNREACHABLE = 1 << 4,
-  SANITIZE_VLA = 1 << 5,
-  SANITIZE_NULL = 1 << 6,
-  SANITIZE_RETURN = 1 << 7,
+  SANITIZE_SHIFT = 1 << 3,
+  SANITIZE_DIVIDE = 1 << 4,
+  SANITIZE_UNREACHABLE = 1 << 5,
+  SANITIZE_VLA = 1 << 6,
+  SANITIZE_NULL = 1 << 7,
+  SANITIZE_RETURN = 1 << 8,
   SANITIZE_UNDEFINED = SANITIZE_SHIFT | SANITIZE_DIVIDE | SANITIZE_UNREACHABLE
 		       | SANITIZE_VLA | SANITIZE_NULL | SANITIZE_RETURN
 };
diff --git a/gcc/gcc.c b/gcc/gcc.c
index dff7477f54e1..4edf6771c4f9 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -578,6 +578,22 @@ proper position among the other output files.  */
 #define LIBTSAN_EARLY_SPEC ""
 #endif
 
+#ifndef LIBLSAN_SPEC
+#ifdef STATIC_LIBLSAN_LIBS
+#define ADD_STATIC_LIBLSAN_LIBS \
+  " %{static-liblsan:" STATIC_LIBLSAN_LIBS "}"
+#else
+#define ADD_STATIC_LIBLSAN_LIBS
+#endif
+#ifdef HAVE_LD_STATIC_DYNAMIC
+#define LIBLSAN_SPEC "%{!shared:%{static-liblsan:" LD_STATIC_OPTION \
+		     "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
+		     ADD_STATIC_LIBLSAN_LIBS "}"
+#else
+#define LIBLSAN_SPEC "%{!shared:-llsan" ADD_STATIC_LIBLSAN_LIBS "}"
+#endif
+#endif
+
 #ifndef LIBUBSAN_SPEC
 #ifdef STATIC_LIBUBSAN_LIBS
 #define ADD_STATIC_LIBUBSAN_LIBS \
@@ -585,9 +601,7 @@ proper position among the other output files.  */
 #else
 #define ADD_STATIC_LIBUBSAN_LIBS
 #endif
-#ifdef LIBUBSAN_EARLY_SPEC
-#define LIBUBSAN_SPEC ADD_STATIC_LIBUBSAN_LIBS
-#elif defined(HAVE_LD_STATIC_DYNAMIC)
+#ifdef HAVE_LD_STATIC_DYNAMIC
 #define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \
 		     "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
 		     ADD_STATIC_LIBUBSAN_LIBS
@@ -596,10 +610,6 @@ proper position among the other output files.  */
 #endif
 #endif
 
-#ifndef LIBUBSAN_EARLY_SPEC
-#define LIBUBSAN_EARLY_SPEC ""
-#endif
-
 /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is
    included.  */
 #ifndef LIBGCC_SPEC
@@ -723,8 +733,7 @@ proper position among the other output files.  */
 #ifndef SANITIZER_EARLY_SPEC
 #define SANITIZER_EARLY_SPEC "\
 %{!nostdlib:%{!nodefaultlibs:%{%:sanitize(address):" LIBASAN_EARLY_SPEC "} \
-    %{%:sanitize(thread):" LIBTSAN_EARLY_SPEC "} \
-    %{%:sanitize(undefined):" LIBUBSAN_EARLY_SPEC "}}}"
+    %{%:sanitize(thread):" LIBTSAN_EARLY_SPEC "}}}"
 #endif
 
 /* Linker command line options for -fsanitize= late on the command line.  */
@@ -735,7 +744,8 @@ proper position among the other output files.  */
     %{%:sanitize(thread):%e-fsanitize=address is incompatible with -fsanitize=thread}}\
     %{%:sanitize(thread):" LIBTSAN_SPEC "\
     %{!pie:%{!shared:%e-fsanitize=thread linking must be done with -pie or -shared}}}\
-    %{%:sanitize(undefined):" LIBUBSAN_SPEC "}}}"
+    %{%:sanitize(undefined):" LIBUBSAN_SPEC "}\
+    %{%:sanitize(leak):" LIBLSAN_SPEC "}}}"
 #endif
 
 /*  This is the spec to use, once the code for creating the vtable
@@ -8123,7 +8133,10 @@ sanitize_spec_function (int argc, const char **argv)
     return (flag_sanitize & SANITIZE_THREAD) ? "" : NULL;
   if (strcmp (argv[0], "undefined") == 0)
     return (flag_sanitize & SANITIZE_UNDEFINED) ? "" : NULL;
-
+  if (strcmp (argv[0], "leak") == 0)
+    return ((flag_sanitize
+	     & (SANITIZE_ADDRESS | SANITIZE_LEAK | SANITIZE_THREAD))
+	    == SANITIZE_LEAK) ? "" : NULL;
   return NULL;
 }
 
diff --git a/gcc/opts.c b/gcc/opts.c
index 21ca9dcdf7ae..0c1f57e1b3c3 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1450,6 +1450,7 @@ common_handle_option (struct gcc_options *opts,
 	    {
 	      { "address", SANITIZE_ADDRESS, sizeof "address" - 1 },
 	      { "thread", SANITIZE_THREAD, sizeof "thread" - 1 },
+	      { "leak", SANITIZE_LEAK, sizeof "leak" - 1 },
 	      { "shift", SANITIZE_SHIFT, sizeof "shift" - 1 },
 	      { "integer-divide-by-zero", SANITIZE_DIVIDE,
 		sizeof "integer-divide-by-zero" - 1 },
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9a66cbfd0b1c..12d2c907b051 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-22  Jakub Jelinek  <jakub@redhat.com>
+
+	* c-c++-common/asan/no-redundant-instrumentation-7.c: Fix
+	cleanup-tree-dump directive.
+
 2013-11-22  Jan Hubicka  <jh@suse.cz>
 
 	* gcc.dg/20081223-1.c: Add -ffat-lto-objects.
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c
index 075e9cfb8682..bf40a0376792 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c
@@ -20,4 +20,4 @@ foo  (int *a, char *b, char *c)
 
 /* { dg-final { scan-tree-dump-times "__builtin___asan_report_load" 6 "asan0" } } */
 /* { dg-final { scan-tree-dump-not "__builtin___asan_report_store" "asan0" } } */
-/* { dg-final { cleanup-tree-dump "asan" } } */
+/* { dg-final { cleanup-tree-dump "asan0" } } */
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 000ca18c8f43..fd9b55d516f2 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,13 @@
+2013-11-22  Jakub Jelinek  <jakub@redhat.com>
+
+	PR sanitizer/59061
+	* configure.tgt: Set LSAN_SUPPORTED=yes for x86_64-linux.
+	* configure.ac (LSAN_SUPPORTED): New AM_CONDITIONAL.
+	* configure: Regenerated.
+	* lsan/Makefile.am (toolexeclib_LTLIBRARIES, lsan_files,
+	liblsan_la_SOURCES, liblsan_la_LIBADD, liblsan_la_LDFLAGS): Add.
+	* lsan/Makefile.in: Regenerated.
+
 2013-11-22  Mike Stump  <mikestump@comcast.net>
 
 	* sanitizer_common/sanitizer_linux.cc (__sanitizer): Grab one
diff --git a/libsanitizer/configure b/libsanitizer/configure
index 5e425d1d9e3b..22f7fee91560 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -606,6 +606,8 @@ LTLIBOBJS
 LIBOBJS
 USING_MAC_INTERPOSE_FALSE
 USING_MAC_INTERPOSE_TRUE
+LSAN_SUPPORTED_FALSE
+LSAN_SUPPORTED_TRUE
 TSAN_SUPPORTED_FALSE
 TSAN_SUPPORTED_TRUE
 enable_static
@@ -11117,7 +11119,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11120 "configure"
+#line 11122 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11223,7 +11225,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11226 "configure"
+#line 11228 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14523,6 +14525,7 @@ fi
 
 # Get target configury.
 unset TSAN_SUPPORTED
+unset LSAN_SUPPORTED
 . ${srcdir}/configure.tgt
  if test "x$TSAN_SUPPORTED" = "xyes"; then
   TSAN_SUPPORTED_TRUE=
@@ -14532,6 +14535,14 @@ else
   TSAN_SUPPORTED_FALSE=
 fi
 
+ if test "x$LSAN_SUPPORTED" = "xyes"; then
+  LSAN_SUPPORTED_TRUE=
+  LSAN_SUPPORTED_FALSE='#'
+else
+  LSAN_SUPPORTED_TRUE='#'
+  LSAN_SUPPORTED_FALSE=
+fi
+
 
 case "$host" in
   *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;;
@@ -14722,6 +14733,10 @@ if test -z "${TSAN_SUPPORTED_TRUE}" && test -z "${TSAN_SUPPORTED_FALSE}"; then
   as_fn_error "conditional \"TSAN_SUPPORTED\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${LSAN_SUPPORTED_TRUE}" && test -z "${LSAN_SUPPORTED_FALSE}"; then
+  as_fn_error "conditional \"LSAN_SUPPORTED\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${USING_MAC_INTERPOSE_TRUE}" && test -z "${USING_MAC_INTERPOSE_FALSE}"; then
   as_fn_error "conditional \"USING_MAC_INTERPOSE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
index 0b2d8132fb65..f769fdb030c1 100644
--- a/libsanitizer/configure.ac
+++ b/libsanitizer/configure.ac
@@ -78,8 +78,10 @@ fi
 
 # Get target configury.
 unset TSAN_SUPPORTED
+unset LSAN_SUPPORTED
 . ${srcdir}/configure.tgt
 AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"])
+AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"])
 
 case "$host" in
   *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;;
diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt
index bdfc22e3718f..b17ed73258d6 100644
--- a/libsanitizer/configure.tgt
+++ b/libsanitizer/configure.tgt
@@ -23,6 +23,7 @@ case "${target}" in
   x86_64-*-linux* | i?86-*-linux*)
 	if test x$ac_cv_sizeof_void_p = x8; then
 		TSAN_SUPPORTED=yes
+		LSAN_SUPPORTED=yes
 	fi
 	;;
   powerpc*-*-linux*)
diff --git a/libsanitizer/lsan/Makefile.am b/libsanitizer/lsan/Makefile.am
index 3d500f3240c1..a312c1c262e0 100644
--- a/libsanitizer/lsan/Makefile.am
+++ b/libsanitizer/lsan/Makefile.am
@@ -9,13 +9,27 @@ AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
 ACLOCAL_AMFLAGS = -I m4
 
 noinst_LTLIBRARIES = libsanitizer_lsan.la
+if LSAN_SUPPORTED
+toolexeclib_LTLIBRARIES = liblsan.la
+endif
 
 sanitizer_lsan_files = \
 	lsan_common.cc \
 	lsan_common_linux.cc
 
+lsan_files = \
+	$(sanitizer_lsan_files) \
+	lsan.cc \
+	lsan_allocator.cc \
+	lsan_interceptors.cc \
+	lsan_thread.cc
+
 libsanitizer_lsan_la_SOURCES = $(sanitizer_lsan_files)
 
+liblsan_la_SOURCES = $(lsan_files)
+liblsan_la_LIBADD = $(top_builddir)/sanitizer_common/libsanitizer_common.la $(top_builddir)/interception/libinterception.la $(LIBSTDCXX_RAW_CXX_LDFLAGS)
+liblsan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` -lpthread -ldl
+
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
 # values defined in terms of make variables, as is the case for CC and
 # friends when we are called from the top level Makefile.
diff --git a/libsanitizer/lsan/Makefile.in b/libsanitizer/lsan/Makefile.in
index c5c07e71eb77..f0946618eb2c 100644
--- a/libsanitizer/lsan/Makefile.in
+++ b/libsanitizer/lsan/Makefile.in
@@ -53,9 +53,44 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
-LTLIBRARIES = $(noinst_LTLIBRARIES)
-libsanitizer_lsan_la_LIBADD =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
+LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+liblsan_la_DEPENDENCIES =  \
+	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
+	$(top_builddir)/interception/libinterception.la \
+	$(am__DEPENDENCIES_1)
 am__objects_1 = lsan_common.lo lsan_common_linux.lo
+am__objects_2 = $(am__objects_1) lsan.lo lsan_allocator.lo \
+	lsan_interceptors.lo lsan_thread.lo
+am_liblsan_la_OBJECTS = $(am__objects_2)
+liblsan_la_OBJECTS = $(am_liblsan_la_OBJECTS)
+liblsan_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(liblsan_la_LDFLAGS) $(LDFLAGS) -o $@
+@LSAN_SUPPORTED_TRUE@am_liblsan_la_rpath = -rpath $(toolexeclibdir)
+libsanitizer_lsan_la_LIBADD =
 am_libsanitizer_lsan_la_OBJECTS = $(am__objects_1)
 libsanitizer_lsan_la_OBJECTS = $(am_libsanitizer_lsan_la_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
@@ -71,7 +106,7 @@ CXXLD = $(CXX)
 CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(libsanitizer_lsan_la_SOURCES)
+SOURCES = $(liblsan_la_SOURCES) $(libsanitizer_lsan_la_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 ACLOCAL = @ACLOCAL@
@@ -215,11 +250,22 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \
 	-Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
 ACLOCAL_AMFLAGS = -I m4
 noinst_LTLIBRARIES = libsanitizer_lsan.la
+@LSAN_SUPPORTED_TRUE@toolexeclib_LTLIBRARIES = liblsan.la
 sanitizer_lsan_files = \
 	lsan_common.cc \
 	lsan_common_linux.cc
 
+lsan_files = \
+	$(sanitizer_lsan_files) \
+	lsan.cc \
+	lsan_allocator.cc \
+	lsan_interceptors.cc \
+	lsan_thread.cc
+
 libsanitizer_lsan_la_SOURCES = $(sanitizer_lsan_files)
+liblsan_la_SOURCES = $(lsan_files)
+liblsan_la_LIBADD = $(top_builddir)/sanitizer_common/libsanitizer_common.la $(top_builddir)/interception/libinterception.la $(LIBSTDCXX_RAW_CXX_LDFLAGS)
+liblsan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` -lpthread -ldl
 
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
 # values defined in terms of make variables, as is the case for CC and
@@ -303,6 +349,39 @@ clean-noinstLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
+install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(toolexeclibdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)"
+	@list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(toolexeclibdir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(toolexeclibdir)"; \
+	}
+
+uninstall-toolexeclibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(toolexeclibdir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(toolexeclibdir)/$$f"; \
+	done
+
+clean-toolexeclibLTLIBRARIES:
+	-test -z "$(toolexeclib_LTLIBRARIES)" || rm -f $(toolexeclib_LTLIBRARIES)
+	@list='$(toolexeclib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+liblsan.la: $(liblsan_la_OBJECTS) $(liblsan_la_DEPENDENCIES) 
+	$(liblsan_la_LINK) $(am_liblsan_la_rpath) $(liblsan_la_OBJECTS) $(liblsan_la_LIBADD) $(LIBS)
 libsanitizer_lsan.la: $(libsanitizer_lsan_la_OBJECTS) $(libsanitizer_lsan_la_DEPENDENCIES) 
 	$(CXXLINK)  $(libsanitizer_lsan_la_OBJECTS) $(libsanitizer_lsan_la_LIBADD) $(LIBS)
 
@@ -312,8 +391,12 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsan.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsan_allocator.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsan_common.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsan_common_linux.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsan_interceptors.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsan_thread.Plo@am__quote@
 
 .cc.o:
 @am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -397,6 +480,9 @@ check-am: all-am
 check: check-am
 all-am: Makefile $(LTLIBRARIES)
 installdirs:
+	for dir in "$(DESTDIR)$(toolexeclibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
 install: install-am
 install-exec: install-exec-am
 install-data: install-data-am
@@ -425,7 +511,7 @@ maintainer-clean-generic:
 clean: clean-am
 
 clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
-	mostlyclean-am
+	clean-toolexeclibLTLIBRARIES mostlyclean-am
 
 distclean: distclean-am
 	-rm -rf ./$(DEPDIR)
@@ -451,7 +537,7 @@ install-dvi: install-dvi-am
 
 install-dvi-am:
 
-install-exec-am:
+install-exec-am: install-toolexeclibLTLIBRARIES
 
 install-html: install-html-am
 
@@ -491,22 +577,24 @@ ps: ps-am
 
 ps-am:
 
-uninstall-am:
+uninstall-am: uninstall-toolexeclibLTLIBRARIES
 
 .MAKE: install-am install-strip
 
 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
-	distclean-compile distclean-generic distclean-libtool \
-	distclean-tags dvi dvi-am html html-am info info-am install \
-	install-am install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am
+	clean-libtool clean-noinstLTLIBRARIES \
+	clean-toolexeclibLTLIBRARIES ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags dvi dvi-am \
+	html html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip \
+	install-toolexeclibLTLIBRARIES installcheck installcheck-am \
+	installdirs maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am uninstall-toolexeclibLTLIBRARIES
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
-- 
GitLab