2015-11-17 17:13:12 +01:00
|
|
|
# Enable SSP and FORITFY_SOURCE=2 by default.
|
2015-11-17 17:24:54 +01:00
|
|
|
CFLAGS=" -fstack-protector-strong -D_FORTIFY_SOURCE=2 $CFLAGS"
|
|
|
|
CXXFLAGS="-fstack-protector-strong -D_FORTIFY_SOURCE=2 $CXXFLAGS"
|
2015-11-17 17:13:12 +01:00
|
|
|
# Enable as-needed and relro by default.
|
2015-11-17 17:24:54 +01:00
|
|
|
LDFLAGS="-Wl,--as-needed -Wl,-z,relro $LDFLAGS"
|
2015-11-17 17:13:12 +01:00
|
|
|
|
2015-12-12 08:32:38 +01: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 08:36:51 +01:00
|
|
|
nopie=yes
|
2015-12-12 08:32:38 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -z "$nopie" ]; then
|
2015-11-17 17:13:12 +01:00
|
|
|
_GCCSPECSDIR=${XBPS_COMMONDIR}/environment/configure/gccspecs
|
2015-11-17 17:24:54 +01:00
|
|
|
CFLAGS="-specs=${_GCCSPECSDIR}/hardened-cc1 $CFLAGS"
|
|
|
|
CXXFLAGS="-specs=${_GCCSPECSDIR}/hardened-cc1 $CXXFLAGS"
|
2015-11-17 17:13:12 +01:00
|
|
|
# We pass -z relro -z now here too, because libtool drops -specs...
|
2015-11-17 17:24:54 +01:00
|
|
|
LDFLAGS="-specs=${_GCCSPECSDIR}/hardened-ld -Wl,-z,relro -Wl,-z,now $LDFLAGS"
|
2015-11-17 17:13:12 +01:00
|
|
|
fi
|