Patch to enable -fPIE and -fstack-protector by default on OpenBSD

Matthew Dempsky matthew at dempsky.org
Fri May 31 19:09:24 PDT 2013


On OpenBSD, we enable -fPIE and -fstack-protector by default in GCC.
Patch below does the same for Clang.

--- tools/clang/lib/Driver/ToolChains.h.orig	Mon Apr 29 18:21:43 2013
+++ tools/clang/lib/Driver/ToolChains.h	Fri May 31 18:23:13 2013
@@ -427,6 +427,11 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic
 
   virtual bool IsMathErrnoDefault() const { return false; }
   virtual bool IsObjCNonFragileABIDefault() const { return true; }
+  virtual bool isPIEDefault() const { return true; }
+
+  virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const {
+    return 1;
+  }
 
 protected:
   virtual Tool *buildAssembler() const;



More information about the cfe-commits mailing list