r251600 - Driver: CrossWindows sanitizers link support
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 28 20:36:46 PDT 2015
Author: compnerd
Date: Wed Oct 28 22:36:45 2015
New Revision: 251600
URL: http://llvm.org/viewvc/llvm-project?rev=251600&view=rev
Log:
Driver: CrossWindows sanitizers link support
Add the required libraries to the linker invocation when building with
sanitizers.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/windows-cross.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=251600&r1=251599&r2=251600&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Oct 28 22:36:45 2015
@@ -9746,6 +9746,22 @@ void CrossWindows::Linker::ConstructJob(
}
}
+ if (TC.getSanitizerArgs().needsAsanRt()) {
+ // TODO handle /MT[d] /MD[d]
+ if (Args.hasArg(options::OPT_shared)) {
+ CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dll_thunk"));
+ } else {
+ for (const auto &Lib : {"asan_dynamic", "asan_dynamic_runtime_thunk"})
+ CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib));
+ // Make sure the dynamic runtime thunk is not optimized out at link time
+ // to ensure proper SEH handling.
+ CmdArgs.push_back(Args.MakeArgString("--undefined"));
+ CmdArgs.push_back(Args.MakeArgString(TC.getArch() == llvm::Triple::x86
+ ? "___asan_seh_interceptor"
+ : "__asan_seh_interceptor"));
+ }
+ }
+
Exec = Args.MakeArgString(TC.GetLinkerPath());
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
Modified: cfe/trunk/test/Driver/windows-cross.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-cross.c?rev=251600&r1=251599&r2=251600&view=diff
==============================================================================
--- cfe/trunk/test/Driver/windows-cross.c (original)
+++ cfe/trunk/test/Driver/windows-cross.c Wed Oct 28 22:36:45 2015
@@ -47,6 +47,19 @@
// RUN: | FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS
// CHECK-SANITIZE-ADDRESS: "-fsanitize=address"
+// CHECK-SANITIZE-ADDRESS: "{{.*}}clang_rt.asan_dll_thunk-arm.lib"
+
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=lld-link2 -o test.exe -fsanitize=address -x c++ %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS-EXE
+
+// CHECK-SANITIZE-ADDRESS-EXE: "-fsanitize=address"
+// CHECK-SANITIZE-ADDRESS-EXE: "{{.*}}clang_rt.asan_dynamic-arm.lib" "{{.*}}clang_rt.asan_dynamic_runtime_thunk-arm.lib" "--undefined" "__asan_seh_interceptor"
+
+// RUN: %clang -### -target i686-windows-itanium -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=lld-link2 -o test.exe -fsanitize=address -x c++ %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS-EXE-X86
+
+// CHECK-SANITIZE-ADDRESS-EXE-X86: "-fsanitize=address"
+// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i686.lib" "{{.*}}clang_rt.asan_dynamic_runtime_thunk-i686.lib" "--undefined" "___asan_seh_interceptor"
// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=lld-link2 -shared -o shared.dll -fsanitize=tsan -x c++ %s 2>&1 \
// RUN: | FileCheck %s --check-prefix CHECK-SANITIZE-TSAN
More information about the cfe-commits
mailing list