summaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-02-05 15:55:31 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-02-05 15:55:31 +0000
commit5f13745b95aba2dda2a010c9f706577d10b23dca (patch)
tree100757cceba7527450ccfa949a2cd497d340f97a /gcc/gcc.c
parent2a11135011595efc4d9a72efcc9e92eeef21a3cd (diff)
downloadgcc-5f13745b95aba2dda2a010c9f706577d10b23dca.tar.gz
PR sanitizer/55374
* config/gnu-user.h (LIBTSAN_EARLY_SPEC): Define. (STATIC_LIBTSAN_LIBS): Likewise. * gcc.c (ADD_STATIC_LIBTSAN_LIBS, LIBTSAN_EARLY_SPEC): Define. (LIBTSAN_SPEC): Add ADD_STATIC_LIBTSAN_LIBS, if LIBTSAN_EARLY_SPEC is defined, don't add anything else beyond that. (SANITIZER_EARLY_SPEC, SANITIZER_SPEC): Define. (LINK_COMMAND_SPEC): Use them. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195761 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 29735be1b9b..5022789609c 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -564,12 +564,25 @@ proper position among the other output files. */
#endif
#ifndef LIBTSAN_SPEC
-#ifdef HAVE_LD_STATIC_DYNAMIC
+#ifdef STATIC_LIBTSAN_LIBS
+#define ADD_STATIC_LIBTSAN_LIBS \
+ " %{static-libtsan:" STATIC_LIBTSAN_LIBS "}"
+#else
+#define ADD_STATIC_LIBTSAN_LIBS
+#endif
+#ifdef LIBTSAN_EARLY_SPEC
+#define LIBTSAN_SPEC ADD_STATIC_LIBTSAN_LIBS
+#elif defined(HAVE_LD_STATIC_DYNAMIC)
#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \
- "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}"
+ "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
+ ADD_STATIC_LIBTSAN_LIBS
#else
-#define LIBTSAN_SPEC "-ltsan"
+#define LIBTSAN_SPEC "-ltsan" ADD_STATIC_LIBTSAN_LIBS
+#endif
#endif
+
+#ifndef LIBTSAN_EARLY_SPEC
+#define LIBTSAN_EARLY_SPEC ""
#endif
/* config.h can define LIBGCC_SPEC to override how and when libgcc.a is
@@ -691,6 +704,21 @@ proper position among the other output files. */
%e-fuse-linker-plugin is not supported in this configuration}"
#endif
+/* Linker command line options for -fsanitize= early on the command line. */
+#ifndef SANITIZER_EARLY_SPEC
+#define SANITIZER_EARLY_SPEC "\
+%{!nostdlib:%{!nodefaultlibs:%{fsanitize=address:" LIBASAN_EARLY_SPEC "} \
+ %{fsanitize=thread:" LIBTSAN_EARLY_SPEC "}}}"
+#endif
+
+/* Linker command line options for -fsanitize= late on the command line. */
+#ifndef SANITIZER_SPEC
+#define SANITIZER_SPEC "\
+%{!nostdlib:%{!nodefaultlibs:%{fsanitize=address:" LIBASAN_SPEC "\
+ %{static:%ecannot specify -static with -fsanitize=address}}\
+ %{fsanitize=thread:" LIBTSAN_SPEC "\
+ %{!pie:%{!shared:%e-fsanitize=thread linking must be done with -pie or -shared}}}}}"
+#endif
/* -u* was put back because both BSD and SysV seem to support it. */
/* %{static:} simply prevents an error message if the target machine
@@ -706,19 +734,16 @@ proper position among the other output files. */
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
%(linker) " \
LINK_PLUGIN_SPEC \
- "%{flto|flto=*:%<fcompare-debug*} \
+ "%{flto|flto=*:%<fcompare-debug*} \
%{flto} %{flto=*} %l " LINK_PIE_SPEC \
"%{fuse-ld=*:-fuse-ld=%*}\
%X %{o*} %{e*} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}}\
- %{static:} %{L*} %(mfwrap) %(link_libgcc) \
- %{fsanitize=address:" LIBASAN_EARLY_SPEC "} %o\
+ %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\
%{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
%{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
%(mflib) " STACK_SPLIT_SPEC "\
- %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
- %{fsanitize=address:" LIBASAN_SPEC "%{static:%ecannot specify -static with -fsanitize=address}}\
- %{fsanitize=thread:" LIBTSAN_SPEC "}\
+ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \
%{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
%{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}"
#endif