summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-06-04 23:28:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-06-04 23:28:46 +0000
commit4244ea9ca13926d65ddeb79f1b72331ddede0ab1 (patch)
tree61e96429781109afdc097130d77ea73586b98b06 /clang/lib/Driver/Tools.cpp
parent5659c866f4bf64ee42dccfdce338c78b3f4a14fc (diff)
downloadbcm5719-llvm-4244ea9ca13926d65ddeb79f1b72331ddede0ab1.tar.gz
bcm5719-llvm-4244ea9ca13926d65ddeb79f1b72331ddede0ab1.zip
[ubsan] Don't add a --dynamic-list for ubsan symbols when building a shared
library. That results in the linker resolving all references to weak symbols in the DSO to the definition from within that DSO. Ironically, this rarely causes observable problems, except that it causes ubsan's own dynamic type check to spuriously fail (because we fail to properly merge type_info object names). llvm-svn: 210220
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index ee3b7ff3424..7817f826150 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -2033,17 +2033,23 @@ static void addLsanRT(const ToolChain &TC, const ArgList &Args,
static void addUbsanRT(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs, bool IsCXX,
bool HasOtherSanitizerRt) {
+ // Export symbols if we're not building a shared library. This allows two
+ // models: either every DSO containing ubsan-sanitized code contains the
+ // ubsan runtime, or the main executable does (or both).
+ const bool ExportSymbols = !Args.hasArg(options::OPT_shared);
+
// 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)
addSanitizerRTLinkFlags(TC, Args, CmdArgs, "san", true, false);
- addSanitizerRTLinkFlags(TC, Args, CmdArgs, "ubsan", false);
+ addSanitizerRTLinkFlags(TC, Args, CmdArgs, "ubsan", false, ExportSymbols);
// Only include the bits of the runtime which need a C++ ABI library if
// we're linking in C++ mode.
if (IsCXX)
- addSanitizerRTLinkFlags(TC, Args, CmdArgs, "ubsan_cxx", false);
+ addSanitizerRTLinkFlags(TC, Args, CmdArgs, "ubsan_cxx", false,
+ ExportSymbols);
}
static void addDfsanRT(const ToolChain &TC, const ArgList &Args,
OpenPOWER on IntegriCloud