diff options
| author | Nick Lewycky <nicholas@mxc.ca> | 2013-10-19 00:27:23 +0000 |
|---|---|---|
| committer | Nick Lewycky <nicholas@mxc.ca> | 2013-10-19 00:27:23 +0000 |
| commit | 2492169aeee4e28809442d8a1b586350cde74dff (patch) | |
| tree | 595ee831223c40fd4f5a5650dfe41da96c05f49a /clang/lib/Driver/Tools.cpp | |
| parent | 1bda72144dc1ca4c3250998dfccac7b0ab0c7402 (diff) | |
| download | bcm5719-llvm-2492169aeee4e28809442d8a1b586350cde74dff.tar.gz bcm5719-llvm-2492169aeee4e28809442d8a1b586350cde74dff.zip | |
When building ubsan, link in ubsan parts first and sanitizer-common second, to
pick up the common bits ubsan actually needs. Also remove whole-archive when we
aren't trying to re-export the symbols.
llvm-svn: 193022
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index d6ddd024437..c85ff8d60c8 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1705,13 +1705,15 @@ static void addSanitizerRTLinkFlagsLinux( // Sanitizer runtime may need to come before -lstdc++ (or -lc++, libstdc++.a, // etc.) so that the linker picks custom versions of the global 'operator // new' and 'operator delete' symbols. We take the extreme (but simple) - // strategy of inserting it at the front of the link command. It also - // needs to be forced to end up in the executable, so wrap it in - // whole-archive. + // strategy of inserting it at the front of the link command. If we're + // responsible for exporting the symbols then it also needs to be forced to + // end up in the executable, so wrap it in whole-archive. SmallVector<const char *, 3> LibSanitizerArgs; - LibSanitizerArgs.push_back("-whole-archive"); + if (ExportSymbols) + LibSanitizerArgs.push_back("-whole-archive"); LibSanitizerArgs.push_back(Args.MakeArgString(LibSanitizer)); - LibSanitizerArgs.push_back("-no-whole-archive"); + if (ExportSymbols) + LibSanitizerArgs.push_back("-no-whole-archive"); CmdArgs.insert(BeforeLibStdCXX ? CmdArgs.begin() : CmdArgs.end(), LibSanitizerArgs.begin(), LibSanitizerArgs.end()); @@ -1777,17 +1779,17 @@ static void addLsanRTLinux(const ToolChain &TC, const ArgList &Args, static void addUbsanRTLinux(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs, bool IsCXX, bool HasOtherSanitizerRt) { - // Need a copy of sanitizer_common. This could come from another sanitizer - // runtime; if we're not including one, include our own copy. - if (!HasOtherSanitizerRt) - addSanitizerRTLinkFlagsLinux(TC, Args, CmdArgs, "san", true, false); - - addSanitizerRTLinkFlagsLinux(TC, Args, CmdArgs, "ubsan", false); + addSanitizerRTLinkFlagsLinux(TC, Args, CmdArgs, "ubsan", false, false); // Only include the bits of the runtime which need a C++ ABI library if // we're linking in C++ mode. if (IsCXX) - addSanitizerRTLinkFlagsLinux(TC, Args, CmdArgs, "ubsan_cxx", false); + addSanitizerRTLinkFlagsLinux(TC, Args, CmdArgs, "ubsan_cxx", false, false); + + // Need a copy of sanitizer_common. This could come from another sanitizer + // runtime; if we're not including one, include our own copy. + if (!HasOtherSanitizerRt) + addSanitizerRTLinkFlagsLinux(TC, Args, CmdArgs, "san", false, false); } static void addDfsanRTLinux(const ToolChain &TC, const ArgList &Args, |

