Driver: Do not link safestack with --whole-archive.

This allows it to be used with the other sanitizers.

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

llvm-svn: 294274
This commit is contained in:
Peter Collingbourne 2017-02-07 03:21:57 +00:00
parent 1ea1fd893c
commit 8e6a25feca
2 changed files with 7 additions and 3 deletions

View File

@ -3365,8 +3365,10 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
if (SanArgs.linkCXXRuntimes())
StaticRuntimes.push_back("ubsan_standalone_cxx");
}
if (SanArgs.needsSafeStackRt())
StaticRuntimes.push_back("safestack");
if (SanArgs.needsSafeStackRt()) {
NonWholeStaticRuntimes.push_back("safestack");
RequiredSymbols.push_back("__safestack_init");
}
if (SanArgs.needsCfiRt())
StaticRuntimes.push_back("cfi");
if (SanArgs.needsCfiDiagRt()) {
@ -3417,7 +3419,7 @@ static bool addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
if (SanArgs.hasCrossDsoCfi() && !AddExportDynamic)
CmdArgs.push_back("-export-dynamic-symbol=__cfi_check");
return !StaticRuntimes.empty();
return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
}
static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,

View File

@ -416,7 +416,9 @@
//
// CHECK-SAFESTACK-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-SAFESTACK-LINUX-NOT: "-lc"
// CHECK-SAFESTACK-LINUX-NOT: whole-archive
// CHECK-SAFESTACK-LINUX: libclang_rt.safestack-x86_64.a"
// CHECK-SAFESTACK-LINUX: "-u" "__safestack_init"
// CHECK-SAFESTACK-LINUX: "-lpthread"
// CHECK-SAFESTACK-LINUX: "-ldl"