]> granicus.if.org Git - clang/commitdiff
[Driver] SafeStack does not need a runtime library on Fuchsia
authorPetr Hosek <phosek@chromium.org>
Wed, 16 Aug 2017 19:06:05 +0000 (19:06 +0000)
committerPetr Hosek <phosek@chromium.org>
Wed, 16 Aug 2017 19:06:05 +0000 (19:06 +0000)
Patch by Roland McGrath

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

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

include/clang/Driver/SanitizerArgs.h
lib/Driver/SanitizerArgs.cpp
test/Driver/fuchsia.c

index a9645d463fa16ac833ff36b128201fab3b0f09cd..b6154da50ae15aa736bc1de1d09955c476b8f48b 100644 (file)
@@ -38,6 +38,7 @@ class SanitizerArgs {
   bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
+  bool SafeStackRuntime = false;
   bool Stats = false;
   bool TsanMemoryAccess = true;
   bool TsanFuncEntryExit = true;
@@ -58,9 +59,7 @@ class SanitizerArgs {
   }
   bool needsUbsanRt() const;
   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
-  bool needsSafeStackRt() const {
-    return Sanitizers.has(SanitizerKind::SafeStack);
-  }
+  bool needsSafeStackRt() const { return SafeStackRuntime; }
   bool needsCfiRt() const;
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }
index e411629ca425e0fec51255d8f0b97fb2bb04d440..0a737756d908ee13e8258da620a7729afa98f0b8 100644 (file)
@@ -605,6 +605,11 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
     AsanUseAfterScope = false;
   }
 
+  if (AllAddedKinds & SafeStack) {
+    // SafeStack runtime is built into the system on Fuchsia.
+    SafeStackRuntime = !TC.getTriple().isOSFuchsia();
+  }
+
   // Parse -link-cxx-sanitizer flag.
   LinkCXXRuntimes =
       Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX();
index 5b61bf424f55bb30f4de2f691dc551ac658493bd..a5491c4ab97edfa8905620d98a9c29d71dc097c7 100644 (file)
@@ -45,6 +45,8 @@
 // RUN:     -fsanitize=safe-stack 2>&1 \
 // RUN:     | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
+// CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-NOT: "__safestack_init"
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN:     -fsanitize=address 2>&1 \