]> granicus.if.org Git - clang/commitdiff
[windows] [asan] Add linker flag when including "asan_dynamic_runtime_thunk".
authorMarcos Pividori <mpividori@google.com>
Sun, 29 Jan 2017 06:03:05 +0000 (06:03 +0000)
committerMarcos Pividori <mpividori@google.com>
Sun, 29 Jan 2017 06:03:05 +0000 (06:03 +0000)
I modify clang driver for windows to include:
"-wholearchive:asan_dynamic_runtime_thunk", so all object files in the
static library: asan_dynamic_runtime_thunk are considered by the linker.
This is necessary, because some object files only include linker pragmas,
and doesn't resolve any symbol. If we don't include that flag, the
linker will ignore them, and won't read the linker pragmas.

Differential Revision: https://reviews.llvm.org/D29159

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293420 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/cl-link.c

index 24a9336a2eea33af58f58ea65a2b184daba5e727..94d22190ecfd1bed0aa520556a948b0a282dbe34 100644 (file)
@@ -10990,6 +10990,10 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
           TC.getArch() == llvm::Triple::x86
               ? "-include:___asan_seh_interceptor"
               : "-include:__asan_seh_interceptor"));
+      // Make sure the linker consider all object files from the dynamic runtime
+      // thunk.
+      CmdArgs.push_back(Args.MakeArgString(std::string("-wholearchive:") +
+          TC.getCompilerRT(Args, "asan_dynamic_runtime_thunk")));
     } else if (DLL) {
       CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dll_thunk"));
     } else {
index b195676250e803c0ccb1a8de2cbecd1582247494..c1078f906a0565e9cf1ec031bdbf4c1b6723dcfd 100644 (file)
@@ -22,8 +22,9 @@
 // ASAN-MD: "-debug"
 // ASAN-MD: "-incremental:no"
 // ASAN-MD: "{{.*}}clang_rt.asan_dynamic-i386.lib"
-// ASAN-MD: "{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib"
+// ASAN-MD: "{{[^"]*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib"
 // ASAN-MD: "-include:___asan_seh_interceptor"
+// ASAN-MD: "-wholearchive:{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib"
 // ASAN-MD: "{{.*}}cl-link{{.*}}.obj"
 
 // RUN: %clang_cl /LD -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s