diff options
author | Marcos Pividori <mpividori@google.com> | 2017-01-31 18:31:38 +0000 |
---|---|---|
committer | Marcos Pividori <mpividori@google.com> | 2017-01-31 18:31:38 +0000 |
commit | 7eeaf901933fddf254839b0fa9bb547e85dbe696 (patch) | |
tree | a1614a7659564e71160e9cfb099c8a75b2d4cb53 /clang/lib/Driver/Tools.cpp | |
parent | d763c4cc8574c258fcad9b4fca578c0b2ed61469 (diff) | |
download | bcm5719-llvm-7eeaf901933fddf254839b0fa9bb547e85dbe696.tar.gz bcm5719-llvm-7eeaf901933fddf254839b0fa9bb547e85dbe696.zip |
[windows] [asan] Add wholearchive flag when including static lib asan.
In Windows, when the sanitizer is implemented as a static library, we use
auxiliary static library dll_thunk that will be linked to the dlls that have
instrumentation, so they can refer to the runtime in the main executable.
It uses interception to get a pointer the function in the main executable and
override its function with that pointer.
Because of that, we need to ensure that the main executable exports all the
sanitizers' interface, otherwise the initialization in dll_thunk will fail.
In this commit we add the flag -wholearchive to clang driver to ensure that
the linker does not omit any object files from asan library.
Differential Revision: https://reviews.llvm.org/D29334
llvm-svn: 293668
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 0e5511c5522..910b5106e98 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -11002,6 +11002,11 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, } else { for (const auto &Lib : {"asan", "asan_cxx"}) CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib)); + // Make sure the linker consider all object files from the static library. + // This is necessary because instrumented dlls need access to all the + // interface exported by the static lib in the main executable. + CmdArgs.push_back(Args.MakeArgString(std::string("-wholearchive:") + + TC.getCompilerRT(Args, "asan"))); } } |