summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Stumpf <pascal@cvs.openbsd.org>2012-08-22 19:41:57 +0000
committerPascal Stumpf <pascal@cvs.openbsd.org>2012-08-22 19:41:57 +0000
commitce27f09fe97100a0a9ad8706bc946e5b40c840ee (patch)
tree0559a5919012037b9ff03f8387774791598d4d9d
parent5d18b583a71dba96884a01a2875e7c86bfa76db7 (diff)
share/mk bits for PIE, currently disabled.
ok matthew@ deraadt@ kettenis@, manpage prodding and ok jmc@
-rw-r--r--share/man/man5/mk.conf.56
-rw-r--r--share/mk/bsd.README4
-rw-r--r--share/mk/bsd.own.mk19
-rw-r--r--share/mk/bsd.prog.mk8
4 files changed, 32 insertions, 5 deletions
diff --git a/share/man/man5/mk.conf.5 b/share/man/man5/mk.conf.5
index 1193e1f131f..91625570484 100644
--- a/share/man/man5/mk.conf.5
+++ b/share/man/man5/mk.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mk.conf.5,v 1.22 2012/04/08 17:36:21 jmc Exp $
+.\" $OpenBSD: mk.conf.5,v 1.23 2012/08/22 19:41:56 pascal Exp $
.\"
.\" Copyright (c) 2003 Jason McIntyre
.\"
@@ -24,7 +24,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: April 8 2012 $
+.Dd $Mdocdate: August 22 2012 $
.Dt MK.CONF 5
.Os
.Sh NAME
@@ -197,6 +197,8 @@ updated GNU programs.
.It Ev NOPIC
Do not build PIC versions of system libraries,
and do not build shared libraries.
+.It Ev NOPIE
+Do not build PIE objects or executables.
.It Ev NOPROFILE
Do not build profiled versions of system libraries.
.It Ev PIPE
diff --git a/share/mk/bsd.README b/share/mk/bsd.README
index d4c5e5b34f2..9e850d586f3 100644
--- a/share/mk/bsd.README
+++ b/share/mk/bsd.README
@@ -1,4 +1,4 @@
-# $OpenBSD: bsd.README,v 1.47 2012/04/08 15:56:28 jsg Exp $
+# $OpenBSD: bsd.README,v 1.48 2012/08/22 19:41:56 pascal Exp $
# $NetBSD: bsd.README,v 1.17 1996/04/13 02:08:08 thorpej Exp $
# @(#)bsd.README 5.1 (Berkeley) 5/11/90
@@ -235,6 +235,8 @@ NOPROFILE Do not build profiled versions of system libraries.
NOPIC Do not build PIC versions of system libraries, and
do not build shared libraries.
+NOPIE Do not build PIE objects or executables.
+
DEBUG Add -g to assembly, C compiler and linking passes. Also
doesn't set STRIP to -s per default if defined.
diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
index e3dfbb7e2be..ce5571bebee 100644
--- a/share/mk/bsd.own.mk
+++ b/share/mk/bsd.own.mk
@@ -1,4 +1,4 @@
-# $OpenBSD: bsd.own.mk,v 1.120 2012/08/20 20:44:26 sthen Exp $
+# $OpenBSD: bsd.own.mk,v 1.121 2012/08/22 19:41:56 pascal Exp $
# $NetBSD: bsd.own.mk,v 1.24 1996/04/13 02:08:09 thorpej Exp $
# Host-specific overrides
@@ -34,6 +34,7 @@ ELF_TOOLCHAIN?= yes
GCC2_ARCH=m68k m88k vax
GCC4_ARCH=alpha amd64 arm avr32 hppa hppa64 i386 ia64 mips64 mips64el powerpc sparc sparc64 sh
BINUTILS217_ARCH=avr32 hppa64 ia64
+PIE_ARCH=
.for _arch in ${MACHINE_ARCH}
.if !empty(GCC2_ARCH:M${_arch})
@@ -49,6 +50,14 @@ BINUTILS_VERSION=binutils-2.17
.else
BINUTILS_VERSION=binutils
.endif
+
+.if !empty(PIE_ARCH:M${_arch})
+NOPIE_FLAGS=-fno-pie
+GCC_PIE_DEFAULT=${DEFAULT_PIE_DEF}
+.else
+NOPIE_FLAGS=
+GCC_PIE_DEFAULT=
+.endif
.endfor
.if ${COMPILER_VERSION} == "gcc4"
@@ -153,6 +162,14 @@ ASPICFLAG=-KPIC
ASPICFLAG=-k
.endif
+.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
+# big PIE
+DEFAULT_PIE_DEF=-DPIE_DEFAULT=2
+.else
+# small pie
+DEFAULT_PIE_DEF=-DPIE_DEFAULT=1
+.endif
+
# don't try to generate PROFILED versions of libraries on machines
# which don't support profiling.
.if 0
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
index c17a5bf2583..bea7b01b6df 100644
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -1,4 +1,4 @@
-# $OpenBSD: bsd.prog.mk,v 1.53 2012/04/08 15:56:28 jsg Exp $
+# $OpenBSD: bsd.prog.mk,v 1.54 2012/08/22 19:41:56 pascal Exp $
# $NetBSD: bsd.prog.mk,v 1.55 1996/04/08 21:19:26 jtc Exp $
# @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
@@ -10,6 +10,12 @@
.SUFFIXES: .out .o .c .cc .C .cxx .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
+.if defined(LDSTATIC) || defined(NOPIE)
+CFLAGS+= ${NOPIE_FLAGS}
+AFLAGS+= ${NOPIE_FLAGS}
+LDFLAGS+= ${NOPIE_FLAGS}
+.endif
+
.if ${WARNINGS:L} == "yes"
CFLAGS+= ${CDIAGFLAGS}
CXXFLAGS+= ${CXXDIAGFLAGS}