summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorBrandon Hale <tseng@gentoo.org>2004-04-06 03:45:00 +0000
committerBrandon Hale <tseng@gentoo.org>2004-04-06 03:45:00 +0000
commit250d466308db99c4548d93baeec2be0b041251ee (patch)
tree9a603fbccc13f513162ac4dda828169ef6fac776 /eclass
parent*** empty log message *** (diff)
downloadgentoo-2-250d466308db99c4548d93baeec2be0b041251ee.tar.gz
gentoo-2-250d466308db99c4548d93baeec2be0b041251ee.tar.bz2
gentoo-2-250d466308db99c4548d93baeec2be0b041251ee.zip
update flag-o-matic.eclass with has_{pic,pie,ssp}, hardened@gentoo.org
Diffstat (limited to 'eclass')
-rw-r--r--eclass/flag-o-matic.eclass47
1 files changed, 38 insertions, 9 deletions
diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 940bd106e81d..21cc2c45dd92 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.41 2004/03/16 21:37:09 solar Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.42 2004/04/06 03:45:00 tseng Exp $
#
# Author Bart Verwilst <verwilst@gentoo.org>
@@ -265,6 +265,29 @@ get-flag() {
return 1
}
+has_pic() {
+ [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0
+ [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0
+ [ has_version sys-devel/hardened-gcc ] && return 0
+ [ ! -z "`${CC/ .*/} --version| grep pie`" ] && return 0
+ return 1
+}
+
+has_pie() {
+ [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0
+ [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0
+ [ has_version sys-devel/hardened-gcc ] && return 0
+ [ ! -z "`${CC/ .*/} --version| grep pie`" ] && return 0
+ return 1
+}
+
+has_ssp() {
+ [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0
+ [ has_version sys-devel/hardened-gcc ] && return 0
+ [ ! -z "`${CC/ .*/} --version| grep ssp`" ] && return 0
+ return 1
+}
+
replace-sparc64-flags() {
local SPARC64_CPUS="ultrasparc v9"
@@ -312,23 +335,29 @@ filter-ldflags() {
}
etexec-flags() {
- has_version sys-devel/hardened-gcc
+ has_pie || has_pic
if [ $? == 0 ] ; then
+ # strip -fPIC regardless if you've gotten this far
+ strip-flags -fPIC -fpic -fPIE -fpie -pie
if [ "`is-flag -yet_exec`" != "true" ]; then
- debug-print ">>> appending flags -yet_exec"
- append-flags -yet_exec
- append-ldflags -yet_exec
+ # If our compile support -yet_exec, append it now
+ [ -z "`gcc -yet_exec -S -o /dev/null -xc /dev/null 2>&1`" ] \
+ && ( debug-print ">>> appending flags -yet_exec" ; \
+ append-flags -yet_exec ; append-ldflags -yet_exec )
fi
fi
}
fstack-flags() {
- has_version sys-devel/hardened-gcc
+ has_ssp
if [ $? == 0 ] ; then
+ # strip -fstack-protector regardless if you've gotten this far
+ strip-flags -fstack-protector -fstack-protector-all
if [ "`is-flag -yno_propolice`" != "true" ]; then
- debug-print ">>> appending flags -yno_propolice"
- append-flags -yno_propolice
- append-ldflags -yno_propolice
+ # If our compile support -yno_propolice, append it now
+ [ -z "`gcc -yno_propolice -S -o /dev/null -xc /dev/null 2>&1`" ] \
+ && ( debug-print ">>> appending flags -yno_propolice" ; \
+ append-flags -yno_propolice ; append-ldflags -yno_propolice )
fi
fi
}