summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'hardened/toolchain/branches/pieworld/eclass/flag-o-matic.eclass')
-rw-r--r--hardened/toolchain/branches/pieworld/eclass/flag-o-matic.eclass30
1 files changed, 17 insertions, 13 deletions
diff --git a/hardened/toolchain/branches/pieworld/eclass/flag-o-matic.eclass b/hardened/toolchain/branches/pieworld/eclass/flag-o-matic.eclass
index 7dfb2f6..670ca84 100644
--- a/hardened/toolchain/branches/pieworld/eclass/flag-o-matic.eclass
+++ b/hardened/toolchain/branches/pieworld/eclass/flag-o-matic.eclass
@@ -121,16 +121,18 @@ setup-allowed-flags() {
return 0
}
+# Internal function for _filter-hardened
+# _manage_hardened <flag being filtered> <minispec to use> <cflag to use>
_manage-hardened() {
- local newspec=$1
- [[ -z $2 ]] && die "Internal flag-o-matic error ($*) - please report"
+ local filter=$1 newspec=$2
+ [[ -z $3 ]] && die "Internal flag-o-matic error ($*) - please report"
if _gcc-specs-exists ${newspec}.specs; then
[[ -z ${GCC_SPECS} ]] || newspec=":${newspec}"
export GCC_SPECS="${GCC_SPECS}${newspec}.specs"
- einfo "Hardened compiler filtered $2 - GCC_SPECS set to ${GCC_SPECS}"
+ einfo "Hardened compiler filtered $1 - GCC_SPECS set to ${GCC_SPECS}"
else
local oldspec=${GCC_SPECS/*\/} newspec=""
- case $1 in
+ case $2 in
"nopie")
case ${oldspec} in
"" | "hardened.specs")
@@ -150,17 +152,19 @@ _manage-hardened() {
"noznow" | "nozrelro")
newspec="vanilla.specs";;
*)
- die "Internal flag-o-matic.eclass error - unrecognised hardened filter $1"
+ die "Internal flag-o-matic.eclass error - unrecognised hardened filter $2"
;;
esac
if [[ -n ${newspec} ]]; then
if _gcc-specs-exists ${newspec}; then
export GCC_SPECS="${newspec}"
- einfo "Hardened compiler filtered $2 - GCC_SPECS set to ${GCC_SPECS}"
+ einfo "Hardened compiler filtered $1 - GCC_SPECS set to ${GCC_SPECS}"
+ else
+ die "Internal flag-o-matic error ($*) - please report"
fi
else
- _raw_append_flag $2
- einfo "Hardened compiler filtered $2 - CFLAGS set to ${CFLAGS}"
+ _raw_append_flag $3
+ einfo "Hardened compiler filtered $1 - CFLAGS set to ${CFLAGS}"
fi
fi
}
@@ -176,19 +180,19 @@ _filter-hardened() {
# thinking about -fPIE.
-fPIC|-fpic|-fPIE|-fpie|-Wl,pie|-pie)
gcc-specs-pie &&
- _manage-hardened nopie -nopie ;;
+ _manage-hardened ${f} nopie -nopie ;;
-fstack-protector)
gcc-specs-ssp &&
- _manage-hardened nossp -fno-stack-protector ;;
+ _manage-hardened ${f} nossp -fno-stack-protector ;;
-fstack-protector-all)
gcc-specs-ssp-to-all &&
- _manage-hardened nosspall -fno-stack-protector-all ;;
+ _manage-hardened ${f} nosspall -fno-stack-protector-all ;;
-now|-Wl,-z,now)
gcc-specs-now &&
- _manage-hardened noznow -nonow ;;
+ _manage-hardened ${f} noznow -nonow ;;
-relro|-Wl,-z,relro)
gcc-specs-now &&
- _manage-hardened nozrelro -norelro ;;
+ _manage-hardened ${f} nozrelro -norelro ;;
esac
done
}