summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin F. Quinn <kevquinn@gentoo.org>2006-12-18 01:22:56 +0000
committerKevin F. Quinn <kevquinn@gentoo.org>2006-12-18 01:22:56 +0000
commit0e094b225889de52495453f883676be1613a849a (patch)
tree5a15096cb17ce8aa25b3669b36d8bdbf904a236c
parentlast sed fix - honest! (diff)
downloadkevquinn-0e094b225889de52495453f883676be1613a849a.tar.gz
kevquinn-0e094b225889de52495453f883676be1613a849a.tar.bz2
kevquinn-0e094b225889de52495453f883676be1613a849a.zip
Sorted fixing of make config for normal crtstuff
svn path=/; revision=122
-rw-r--r--hardened/toolchain/eclass/toolchain.eclass41
1 files changed, 35 insertions, 6 deletions
diff --git a/hardened/toolchain/eclass/toolchain.eclass b/hardened/toolchain/eclass/toolchain.eclass
index a01317f..36f0caa 100644
--- a/hardened/toolchain/eclass/toolchain.eclass
+++ b/hardened/toolchain/eclass/toolchain.eclass
@@ -2135,8 +2135,26 @@ update_gcc_for_libssp() {
-i "${S}"/gcc/Makefile.in || die "Failed to update gcc!"
}
+fixup_crtstuff_for_nopie() {
+ # First try modifying an existing assignmet; if that fails, insert
+ # a new one.
+ if [[ -f "${S}"/$1 ]]; then
+ if grep -q '^CRTSTUFF_T_CFLAGS =' "${S}"/$1; then
+ sed -e 's/^CRTSTUFF_T_CFLAGS =/CRTSTUFF_T_CFLAGS = -fno-PIE /' \
+ -i "${S}"/$1 ||
+ die "Failed to modify $1 for no-PIE crtstuff"
+ else
+ sed -e '1 iCRTSTUFF_T_CFLAGS = -fno-PIE' \
+ -i "${S}"/$1 ||
+ die "Failed to add to $1 for no-PIE crtstuff"
+ fi
+ fi
+}
+
# do various updates to PIE logic
do_gcc_PIE_patches() {
+ local arch
+
if ! want_pie || \
(want_boundschecking && [[ ${HTB_EXCLUSIVE} == "true" ]])
then
@@ -2157,14 +2175,25 @@ do_gcc_PIE_patches() {
# adds non-default pie support (rs6000)
EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
epatch "${WORKDIR}"/piepatch/nondef
+
# Force crt{begin,end}.o to be built normally; for all linux
# If Gentoo/FreeBSD ever want hardened, need to do the same to t-freebsd
- sed -e '/^CRTSTUFF_T_CFLAGS_S =/iCRTSTUFF_T_CFLAGS = -fno-PIE' \
- -i "${S}"/gcc/config/t-linux ||
- die "Failed to fixup gcc/config/t-linux for no-PIE crtstuff"
- sed -e 's/^CRTSTUFF_T_CFLAGS =/CRTSTUFF_T_CFLAGS = -fno-PIE /' \
- -i "${S}"/gcc/Makefile.in ||
- die "Failed to fixup gcc/Makefile.in for no-PIE crtstuff"
+ # If an arch has t-crtstuff, it'll take precedence over t-linux*. If the
+ # arch doesn't have t-crtstuff, try t-linux/t-linux64; then try the
+ # generic t-linux.
+ einfo "Fixing up make configuration to build crtstuff properly with pie compiler"
+ for arch in $(ls -1 "${S}"/gcc/config); do
+ [[ -d "${S}"/gcc/config/${arch} ]] || continue
+ fixup_crtstuff_for_nopie gcc/config/${arch}/t-crtstuff
+ fixup_crtstuff_for_nopie gcc/config/${arch}/t-linux
+ fixup_crtstuff_for_nopie gcc/config/${arch}/t-linux64
+ done
+ fixup_crtstuff_for_nopie gcc/config/t-linux
+ # powerpc (32) is an exception - it sets CRTSTUFF_T_CFLAGS in t-ppccomm
+ fixup_crtstuff_for_nopie gcc/config/rs6000/t-ppccomm
+ # Lastly, rig it in Makefile.in (the last fall-back)
+ fixup_crtstuff_for_nopie gcc/Makefile.in
+
# adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined
want_minispecs ||
EPATCH_MULTI_MSG="Applying default pie patches ..." \