Add some hardening options from:
https://wiki.debian.org/Hardening
These protect against basic buffer overruns.
Although debian/rules can have an "export DEB_BUILD_HARDENING=1",
it's useful to have these available across all builds that support
the compiler options.
# Common compiler flags
#
-CFLAGS += -g
+# https://wiki.debian.org/Hardening
+CFLAGS += -g -D_FORTIFY_SOURCE=2
ifeq ($(CONFIG_CCDEBUG),yes)
CFLAGS += -O0
else
check_cc_option mmx
check_cc_option sse2
check_cc_optionW unused-result
+# Some options from https://wiki.debian.org/Hardening
+check_cc_optionf stack-protector
+check_cc_optionf stack-protector-strong
+# Useful for multi-threaded programs
+check_cc_optionf stack-check
+check_cc_optionf PIE
if check_cc '
#if !defined(__clang__)
fi
}
+# Check compiler option
+check_cc_optionf ()
+{
+ local opt=$1
+ local nam=$2
+ [ -z "$nam" ] && nam=$opt
+ nam=$(echo "f_$nam" | sed -e 's/[-=]/_/g')
+
+ printf "$TAB" "checking for cc -f$opt ..."
+
+ # Enable if supported
+ if check_cc "" -f${opt}; then
+ echo "ok"
+ enable $nam
+ else
+ echo "fail"
+ return 1
+ fi
+}
+
+
# Check compiler library
check_cc_lib ()
{