r209479 - Don't reduce the stack protector level given -fstack-protector.
Rafael Espindola
rafael.espindola at gmail.com
Thu May 22 15:57:40 PDT 2014
Author: rafael
Date: Thu May 22 17:57:39 2014
New Revision: 209479
URL: http://llvm.org/viewvc/llvm-project?rev=209479&view=rev
Log:
Don't reduce the stack protector level given -fstack-protector.
Before -fstack-protector would always force a level of 1, even if the default
was 2.
Patch by Brad Smith.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/stack-protector.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=209479&r1=209478&r2=209479&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu May 22 17:57:39 2014
@@ -3379,9 +3379,10 @@ void Clang::ConstructJob(Compilation &C,
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::SSPOn,
+ 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;
Modified: cfe/trunk/test/Driver/stack-protector.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stack-protector.c?rev=209479&r1=209478&r2=209479&view=diff
==============================================================================
--- cfe/trunk/test/Driver/stack-protector.c (original)
+++ cfe/trunk/test/Driver/stack-protector.c Thu May 22 17:57:39 2014
@@ -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