forked from OSchip/llvm-project
[ASan] Do not imply -undefined dynamic_lookup when linking dylibs with -fsanitize=address.
Instead add the ASan runtime to the linker command line so that only the ASan API functions can be undefined in the target library. Fixes http://llvm.org/bugs/show_bug.cgi?id=17275 llvm-svn: 191076
This commit is contained in:
parent
fc8ca53329
commit
ce87633ff9
|
@ -314,15 +314,13 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
|
|||
getDriver().Diag(diag::err_drv_clang_unsupported_per_platform)
|
||||
<< "-fsanitize=address";
|
||||
} else {
|
||||
if (Args.hasArg(options::OPT_dynamiclib) ||
|
||||
Args.hasArg(options::OPT_bundle)) {
|
||||
// Assume the binary will provide the ASan runtime.
|
||||
} else {
|
||||
AddLinkRuntimeLib(Args, CmdArgs,
|
||||
"libclang_rt.asan_osx_dynamic.dylib", true);
|
||||
if (!Args.hasArg(options::OPT_dynamiclib) &&
|
||||
!Args.hasArg(options::OPT_bundle)) {
|
||||
// The ASAN runtime library requires C++.
|
||||
AddCXXStdlibLibArgs(Args, CmdArgs);
|
||||
}
|
||||
AddLinkRuntimeLib(Args, CmdArgs,
|
||||
"libclang_rt.asan_osx_dynamic.dylib", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4817,20 +4817,6 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
|
||||
Args.AddAllArgs(CmdArgs, options::OPT_L);
|
||||
|
||||
const SanitizerArgs &Sanitize =
|
||||
getToolChain().getDriver().getOrParseSanitizerArgs(Args);
|
||||
// If we're building a dynamic lib with -fsanitize=address,
|
||||
// unresolved symbols may appear. Mark all
|
||||
// of them as dynamic_lookup. Linking executables is handled in
|
||||
// lib/Driver/ToolChains.cpp.
|
||||
if (Sanitize.needsAsanRt()) {
|
||||
if (Args.hasArg(options::OPT_dynamiclib) ||
|
||||
Args.hasArg(options::OPT_bundle)) {
|
||||
CmdArgs.push_back("-undefined");
|
||||
CmdArgs.push_back("dynamic_lookup");
|
||||
}
|
||||
}
|
||||
|
||||
if (Args.hasArg(options::OPT_fopenmp))
|
||||
// This is more complicated in gcc...
|
||||
CmdArgs.push_back("-lgomp");
|
||||
|
|
Loading…
Reference in New Issue