diff options
-rw-r--r-- | include/clang/Driver/ToolChain.h | 4 | ||||
-rw-r--r-- | lib/Driver/ToolChains.h | 9 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 6 |
3 files changed, 13 insertions, 6 deletions
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index eaa1172723..767b7439bf 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -139,7 +139,9 @@ public: /// GetDefaultStackProtectorLevel - Get the default stack protector level for /// this tool chain (0=off, 1=on, 2=all). - virtual unsigned GetDefaultStackProtectorLevel() const { return 0; } + virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const { + return 0; + } /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables /// by default. diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 24545ec4b7..cfb8869f47 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -237,9 +237,12 @@ public: return !(!isTargetIPhoneOS() && isMacosxVersionLT(10, 6)); } virtual bool IsUnwindTablesDefault() const; - virtual unsigned GetDefaultStackProtectorLevel() const { - // Stack protectors default to on for 10.6 and beyond. - return !isTargetIPhoneOS() && !isMacosxVersionLT(10, 6); + virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const { + // Stack protectors default to on for user code on 10.5, + // and for everything in 10.6 and beyond + return !isTargetIPhoneOS() && + (!isMacosxVersionLT(10, 6) || + (!isMacosxVersionLT(10, 5) && !KernelOrKext)); } virtual const char *GetDefaultRelocationModel() const; virtual const char *GetForcedPicModel() const; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 160c006263..e147c05ffe 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1671,8 +1671,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, StackProtectorLevel = 1; else if (A->getOption().matches(options::OPT_fstack_protector_all)) StackProtectorLevel = 2; - } else - StackProtectorLevel = getToolChain().GetDefaultStackProtectorLevel(); + } else { + StackProtectorLevel = + getToolChain().GetDefaultStackProtectorLevel(KernelOrKext); + } if (StackProtectorLevel) { CmdArgs.push_back("-stack-protector"); CmdArgs.push_back(Args.MakeArgString(Twine(StackProtectorLevel))); |