2015-11-17 16:13:12 +00:00
|
|
|
# Enable SSP and FORITFY_SOURCE=2 by default.
|
2015-11-17 16:24:54 +00:00
|
|
|
CFLAGS=" -fstack-protector-strong -D_FORTIFY_SOURCE=2 $CFLAGS"
|
|
|
|
CXXFLAGS="-fstack-protector-strong -D_FORTIFY_SOURCE=2 $CXXFLAGS"
|
2015-11-17 16:13:12 +00:00
|
|
|
# Enable as-needed and relro by default.
|
2015-11-17 16:24:54 +00:00
|
|
|
LDFLAGS="-Wl,--as-needed -Wl,-z,relro $LDFLAGS"
|
2015-11-17 16:13:12 +00:00
|
|
|
|
2015-12-12 07:32:38 +00:00
|
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
|
|
i686-musl) # SSP currently broken (see https://github.com/voidlinux/void-packages/issues/2902)
|
|
|
|
CFLAGS+=" -fno-stack-protector"
|
|
|
|
CXXFLAGS+=" -fno-stack-protector"
|
|
|
|
;;
|
|
|
|
mips-musl|mipsel-musl) # PIE support broken
|
2015-12-12 07:36:51 +00:00
|
|
|
nopie=yes
|
2015-12-12 07:32:38 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -z "$nopie" ]; then
|
2015-11-17 16:13:12 +00:00
|
|
|
_GCCSPECSDIR=${XBPS_COMMONDIR}/environment/configure/gccspecs
|
2015-11-17 16:24:54 +00:00
|
|
|
CFLAGS="-specs=${_GCCSPECSDIR}/hardened-cc1 $CFLAGS"
|
|
|
|
CXXFLAGS="-specs=${_GCCSPECSDIR}/hardened-cc1 $CXXFLAGS"
|
2015-11-17 16:13:12 +00:00
|
|
|
# We pass -z relro -z now here too, because libtool drops -specs...
|
2015-11-17 16:24:54 +00:00
|
|
|
LDFLAGS="-specs=${_GCCSPECSDIR}/hardened-ld -Wl,-z,relro -Wl,-z,now $LDFLAGS"
|
2015-11-17 16:13:12 +00:00
|
|
|
fi
|