Skip to content

Instantly share code, notes, and snippets.

@thierry-FreeBSD
Created June 17, 2015 18:00
Show Gist options
  • Save thierry-FreeBSD/18732c3ff9e05116f89a to your computer and use it in GitHub Desktop.
Save thierry-FreeBSD/18732c3ff9e05116f89a to your computer and use it in GitHub Desktop.
Addind PIE support in FreeBSD ports/bsd.port.mk
Index: Mk/bsd.port.mk
===================================================================
--- Mk/bsd.port.mk (revision 389737)
+++ Mk/bsd.port.mk (working copy)
@@ -322,6 +322,8 @@
#
# WITH_DEBUG_PORTS - A list of origins for which WITH_DEBUG will be set
#
+# WITHOUT_PIE - Do not build with PIE for full ASLR.
+#
# WITHOUT_SSP - Disable SSP.
#
# SSP_CFLAGS - Defaults to -fstack-protector. This value
@@ -1621,7 +1623,13 @@
.endif
# XXX PIE support to be added here
+.if defined(WITHOUT_PIE)
MAKE_ENV+= NO_PIE=yes
+.else
+CFLAGS+= -fPIE
+CXXFLAGS+= -fPIE
+LDFLAGS+= -pie
+.endif
.if defined(NOPORTDOCS)
PLIST_SUB+= PORTDOCS="@comment "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment