gnu-user.h (LIBLSAN_EARLY_SPEC): Define.
authorJakub Jelinek <jakub@redhat.com>
Mon, 1 Sep 2014 08:26:51 +0000 (10:26 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 1 Sep 2014 08:26:51 +0000 (10:26 +0200)
* config/gnu-user.h (LIBLSAN_EARLY_SPEC): Define.
* gcc.c (LIBLSAN_SPEC, LIBLSAN_EARLY_SPEC): Follow LIBTSAN*_SPEC.
(SANITIZER_EARLY_SPEC): Include LIBLSAN_EARLY_SPEC for -fsanitize=leak.

From-SVN: r214778

gcc/ChangeLog
gcc/config/gnu-user.h
gcc/gcc.c

index ad06e2d..8aa71ef 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-01  Jakub Jelinek  <jakub@redhat.com>
+
+       * config/gnu-user.h (LIBLSAN_EARLY_SPEC): Define.
+       * gcc.c (LIBLSAN_SPEC, LIBLSAN_EARLY_SPEC): Follow LIBTSAN*_SPEC.
+       (SANITIZER_EARLY_SPEC): Include LIBLSAN_EARLY_SPEC for -fsanitize=leak.
+
 2014-09-01  Yury Gribov  <y.gribov@samsung.com>
 
        PR sanitizer/61897
index a1955a7..9b46621 100644 (file)
@@ -114,7 +114,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 /* Link -lasan early on the command line.  For -static-libasan, don't link
    it for -shared link, the executable should be compiled with -static-libasan
    in that case, and for executable link link with --{,no-}whole-archive around
-   it to force everything into the executable.  And similarly for -ltsan.  */
+   it to force everything into the executable.  And similarly for -ltsan
+   and -llsan.  */
 #if defined(HAVE_LD_STATIC_DYNAMIC)
 #undef LIBASAN_EARLY_SPEC
 #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
@@ -125,4 +126,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define LIBTSAN_EARLY_SPEC "%{static-libtsan:%{!shared:" \
   LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
   LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
+#undef LIBLSAN_EARLY_SPEC
+#define LIBLSAN_EARLY_SPEC "%{static-liblsan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
 #endif
index 44d0416..c550d9d 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -576,15 +576,21 @@ proper position among the other output files.  */
 #ifndef LIBLSAN_SPEC
 #define STATIC_LIBLSAN_LIBS \
   " %{static-liblsan:%:include(libsanitizer.spec)%(link_liblsan)}"
-#ifdef HAVE_LD_STATIC_DYNAMIC
-#define LIBLSAN_SPEC "%{!shared:%{static-liblsan:" LD_STATIC_OPTION \
+#ifdef LIBLSAN_EARLY_SPEC
+#define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
+#elif defined(HAVE_LD_STATIC_DYNAMIC)
+#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \
                     "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
-                    STATIC_LIBLSAN_LIBS "}"
+                    STATIC_LIBLSAN_LIBS
 #else
-#define LIBLSAN_SPEC "%{!shared:-llsan" STATIC_LIBLSAN_LIBS "}"
+#define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
 #endif
 #endif
 
+#ifndef LIBLSAN_EARLY_SPEC
+#define LIBLSAN_EARLY_SPEC ""
+#endif
+
 #ifndef LIBUBSAN_SPEC
 #define STATIC_LIBUBSAN_LIBS \
   " %{static-libubsan:%:include(libsanitizer.spec)%(link_libubsan)}"
@@ -772,7 +778,8 @@ 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(thread):" LIBTSAN_EARLY_SPEC "} \
+    %{%:sanitize(leak):" LIBLSAN_EARLY_SPEC "}}}"
 #endif
 
 /* Linker command line options for -fsanitize= late on the command line.  */