From: Rafael Espindola Date: Thu, 22 May 2014 22:57:39 +0000 (+0000) Subject: Don't reduce the stack protector level given -fstack-protector. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d1cc5772794c17a4bcf74a2db0c1289c60e25b2;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209479 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 3fe552db82..7670daa171 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -3379,9 +3379,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, 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(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; diff --git a/test/Driver/stack-protector.c b/test/Driver/stack-protector.c index cf2cc34de5..7576c3abe6 100644 --- a/test/Driver/stack-protector.c +++ b/test/Driver/stack-protector.c @@ -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"