diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-22 21:13:08 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-22 21:13:08 +0000 |
commit | f8ff4a27f642c5518c34015952e644dd294d2ff8 (patch) | |
tree | 1e351f73c04f7b8ee40bc54557ac53f5b8b0aa2a /gcc/gcc.c | |
parent | 7c9e96640d9cc6306cc48c538a63199a41f7f06c (diff) | |
download | gcc-f8ff4a27f642c5518c34015952e644dd294d2ff8.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205290 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c index dff7477f54e..4edf6771c4f 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; } |