summaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c69
1 files changed, 33 insertions, 36 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index dff7477f54e..b895f226ad0 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -535,20 +535,16 @@ proper position among the other output files. */
#define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}"
#ifndef LIBASAN_SPEC
-#ifdef STATIC_LIBASAN_LIBS
-#define ADD_STATIC_LIBASAN_LIBS \
- " %{static-libasan:" STATIC_LIBASAN_LIBS "}"
-#else
-#define ADD_STATIC_LIBASAN_LIBS
-#endif
+#define STATIC_LIBASAN_LIBS \
+ " %{static-libasan:%:include(libsanitizer.spec)%(link_libasan)}"
#ifdef LIBASAN_EARLY_SPEC
-#define LIBASAN_SPEC ADD_STATIC_LIBASAN_LIBS
+#define LIBASAN_SPEC STATIC_LIBASAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \
"} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \
- ADD_STATIC_LIBASAN_LIBS
+ STATIC_LIBASAN_LIBS
#else
-#define LIBASAN_SPEC "-lasan" ADD_STATIC_LIBASAN_LIBS
+#define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
#endif
#endif
@@ -557,20 +553,16 @@ proper position among the other output files. */
#endif
#ifndef LIBTSAN_SPEC
-#ifdef STATIC_LIBTSAN_LIBS
-#define ADD_STATIC_LIBTSAN_LIBS \
- " %{static-libtsan:" STATIC_LIBTSAN_LIBS "}"
-#else
-#define ADD_STATIC_LIBTSAN_LIBS
-#endif
+#define STATIC_LIBTSAN_LIBS \
+ " %{static-libtsan:%:include(libsanitizer.spec)%(link_libtsan)}"
#ifdef LIBTSAN_EARLY_SPEC
-#define LIBTSAN_SPEC ADD_STATIC_LIBTSAN_LIBS
+#define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \
"} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
- ADD_STATIC_LIBTSAN_LIBS
+ STATIC_LIBTSAN_LIBS
#else
-#define LIBTSAN_SPEC "-ltsan" ADD_STATIC_LIBTSAN_LIBS
+#define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
#endif
#endif
@@ -578,28 +570,30 @@ proper position among the other output files. */
#define LIBTSAN_EARLY_SPEC ""
#endif
-#ifndef LIBUBSAN_SPEC
-#ifdef STATIC_LIBUBSAN_LIBS
-#define ADD_STATIC_LIBUBSAN_LIBS \
- " %{static-libubsan:" STATIC_LIBUBSAN_LIBS "}"
+#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 \
+ "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
+ STATIC_LIBLSAN_LIBS "}"
#else
-#define ADD_STATIC_LIBUBSAN_LIBS
+#define LIBLSAN_SPEC "%{!shared:-llsan" STATIC_LIBLSAN_LIBS "}"
#endif
-#ifdef LIBUBSAN_EARLY_SPEC
-#define LIBUBSAN_SPEC ADD_STATIC_LIBUBSAN_LIBS
-#elif defined(HAVE_LD_STATIC_DYNAMIC)
+#endif
+
+#ifndef LIBUBSAN_SPEC
+#define STATIC_LIBUBSAN_LIBS \
+ " %{static-libubsan:%:include(libsanitizer.spec)%(link_libubsan)}"
+#ifdef HAVE_LD_STATIC_DYNAMIC
#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \
"} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
- ADD_STATIC_LIBUBSAN_LIBS
+ STATIC_LIBUBSAN_LIBS
#else
-#define LIBUBSAN_SPEC "-lubsan" ADD_STATIC_LIBUBSAN_LIBS
+#define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
#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 +717,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 +728,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 +8117,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;
}