]> granicus.if.org Git - clang/commitdiff
Driver: Do not link safestack with --whole-archive.
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 7 Feb 2017 03:21:57 +0000 (03:21 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 7 Feb 2017 03:21:57 +0000 (03:21 +0000)
This allows it to be used with the other sanitizers.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294274 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/sanitizer-ld.c

index 1cefce6848c41ddb19531b3e43b94d12ac819adb..1eddefd4f03a5e0bdc1f8712c59646a4d9ef9d7a 100644 (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,
index c98ce8a0c4c751e41df4825b0d520ac600dd7815..c4a6f4377b896782a7b84c405a2b44cfbc4a90f0 100644 (file)
 //
 // 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"