forked from OSchip/llvm-project
Driver: CrossWindows sanitizers link support
Add the required libraries to the linker invocation when building with sanitizers. llvm-svn: 251600
This commit is contained in:
parent
b48f1fe4ee
commit
bb2e5e4c4a
|
@ -9746,6 +9746,22 @@ void CrossWindows::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
}
|
||||
}
|
||||
|
||||
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));
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue