[PATCH] D19170: [safestack] Link SafeStack runtime only when not using separate stack segment

Michael LeMay via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 15 14:59:58 PDT 2016


mlemay-intel updated this revision to Diff 53956.
mlemay-intel added a comment.

Add test.


http://reviews.llvm.org/D19170

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

Index: test/Driver/sanitizer-ld.c
===================================================================
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -347,6 +347,15 @@
 // CHECK-SAFESTACK-LINUX: "-lpthread"
 // CHECK-SAFESTACK-LINUX: "-ldl"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target i386-unknown-linux -fsanitize=safe-stack \
+// RUN:     -mseparate-stack-seg \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SAFESTACK-LINUX-SEP-STK %s
+//
+// CHECK-SAFESTACK-LINUX-SEP-STK: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-SAFESTACK-LINUX-SEP-STK-NOT: libclang_rt.safestack-i386.a"
+
 // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
 // RUN:     -target x86_64-unknown-linux \
 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2993,7 +2993,9 @@
     if (SanArgs.linkCXXRuntimes())
       StaticRuntimes.push_back("ubsan_standalone_cxx");
   }
-  if (SanArgs.needsSafeStackRt())
+  // Using a separate stack segment with SafeStack requires more extensive
+  // runtime support than this provides.
+  if (SanArgs.needsSafeStackRt() && !Args.hasArg(options::OPT_mseparate_stack_seg))
     StaticRuntimes.push_back("safestack");
   if (SanArgs.needsCfiRt())
     StaticRuntimes.push_back("cfi");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19170.53956.patch
Type: text/x-patch
Size: 1477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160415/2c551509/attachment.bin>


More information about the cfe-commits mailing list