[PATCH] Allow for changing the stack protector level for -fstack-protector

Brad Smith brad at comstyle.com
Thu May 22 14:52:00 PDT 2014


On Thu, May 22, 2014 at 04:58:57PM -0400, Rafael Esp??ndola wrote:
> Can't you just use the max of GetDefaultStackProtectorLevel and
> LangOptions::SSPOn?

Ya, that does the trick and is simpler. Is this Ok?

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-------------- next part --------------
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 209474)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -3379,9 +3379,10 @@
                                options::OPT_fstack_protector_all,
                                options::OPT_fstack_protector_strong,
                                options::OPT_fstack_protector)) {
-    if (A->getOption().matches(options::OPT_fstack_protector))
-      StackProtectorLevel = LangOptions::SSPOn;
-    else if (A->getOption().matches(options::OPT_fstack_protector_strong))
+    if (A->getOption().matches(options::OPT_fstack_protector)) {
+      StackProtectorLevel = std::max<unsigned>(LangOptions::SSPStrong,
+        getToolChain().GetDefaultStackProtectorLevel(KernelOrKext));
+    } else if (A->getOption().matches(options::OPT_fstack_protector_strong))
       StackProtectorLevel = LangOptions::SSPStrong;
     else if (A->getOption().matches(options::OPT_fstack_protector_all))
       StackProtectorLevel = LangOptions::SSPReq;
Index: test/Driver/stack-protector.c
===================================================================
--- test/Driver/stack-protector.c	(revision 209474)
+++ test/Driver/stack-protector.c	(working copy)
@@ -13,6 +13,9 @@
 // RUN: %clang -target i386-pc-openbsd -### %s 2>&1 | FileCheck %s -check-prefix=OPENBSD
 // OPENBSD: "-stack-protector" "2"
 
+// RUN: %clang -target i386-pc-openbsd -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=OPENBSD_SPS
+// OPENBSD_SPS: "-stack-protector" "2"
+
 // RUN: %clang -target i386-pc-openbsd -fno-stack-protector -### %s 2>&1 | FileCheck %s -check-prefix=OPENBSD_OFF
 // OPENBSD_OFF-NOT: "-stack-protector"
 


More information about the cfe-commits mailing list