diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-12-04 22:54:37 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-12-04 22:54:37 +0000 |
commit | 210c77b38c6c3176137f5b52b3a298fee5c6fbec (patch) | |
tree | 587e3b7a996b0e45985c4c4e6f28d57d0bda8eb0 /clang/lib/Driver/Tools.cpp | |
parent | b4eae1361ce72dc085de922feae1bf0647487ca9 (diff) | |
download | bcm5719-llvm-210c77b38c6c3176137f5b52b3a298fee5c6fbec.tar.gz bcm5719-llvm-210c77b38c6c3176137f5b52b3a298fee5c6fbec.zip |
Add -whole-archive around the ASan runtime archive in the link command.
This ensures that even though it comes first, we pick up its .o files.
Note that if we can use this (or something similar / equivalent) on
other platforms, we could potentially remove
ReplaceOperatorsNewAndDelete from the ASan runtimes.
We should probably do something similar for TSan and MSan as well.
llvm-svn: 169328
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 92f41063e2d..d5f191cf8ad 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1524,8 +1524,14 @@ static void addAsanRTLinux(const ToolChain &TC, const ArgList &Args, // The ASan runtime needs to come before -lstdc++ (or -lc++, libstdc++.a, // etc.) so that the linker picks ASan's 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. - CmdArgs.insert(CmdArgs.begin(), Args.MakeArgString(LibAsan)); + // 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. + SmallVector<const char*, 3> PrefixArgs; + PrefixArgs.push_back("-whole-archive"); + PrefixArgs.push_back(Args.MakeArgString(LibAsan)); + PrefixArgs.push_back("-no-whole-archive"); + CmdArgs.insert(CmdArgs.begin(), PrefixArgs.begin(), PrefixArgs.end()); CmdArgs.push_back("-lpthread"); CmdArgs.push_back("-ldl"); CmdArgs.push_back("-export-dynamic"); |