From: Timur Iskhodzhanov Date: Tue, 26 Aug 2014 10:08:24 +0000 (+0000) Subject: [ASan/Win] Add an extra thunk.lib to handle stack-use-after-return option X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94705efc4ea9c08b042d617ce43f3891fcf581a1;p=clang [ASan/Win] Add an extra thunk.lib to handle stack-use-after-return option With this patch, "check-asan" passes all the tests with both MT and MD ASan RTL if you set COMPILER_RT_BUILD_SHARED_ASAN to ON (PR20214) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216447 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index fe3baa8fa7..08130890cf 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -7820,7 +7820,10 @@ void visualstudio::Link::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString("-debug")); CmdArgs.push_back(Args.MakeArgString("-incremental:no")); // FIXME: Handle 64-bit. - if (DLL) { + if (Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd)) { + addSanitizerRTWindows(getToolChain(), Args, CmdArgs, "asan_dynamic-i386"); + addSanitizerRTWindows(getToolChain(), Args, CmdArgs, "asan_uar_thunk-i386"); + } else if (DLL) { addSanitizerRTWindows(getToolChain(), Args, CmdArgs, "asan_dll_thunk-i386"); } else { diff --git a/test/Driver/cl-link.c b/test/Driver/cl-link.c index f4717465d3..9603c68518 100644 --- a/test/Driver/cl-link.c +++ b/test/Driver/cl-link.c @@ -19,6 +19,14 @@ // ASAN: "{{.*}}clang_rt.asan_cxx-i386.lib" // ASAN: "{{.*}}cl-link{{.*}}.obj" +// RUN: %clang_cl /MD /Tc%s -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-MD %s +// ASAN-MD: link.exe +// ASAN-MD: "-debug" +// ASAN-MD: "-incremental:no" +// ASAN-MD: "{{.*}}clang_rt.asan_dynamic-i386.lib" +// ASAN-MD: "{{.*}}clang_rt.asan_uar_thunk-i386.lib" +// ASAN-MD: "{{.*}}cl-link{{.*}}.obj" + // RUN: %clang_cl /LD -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s // RUN: %clang_cl /LDd -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s // DLL: link.exe