From 71664fd8d2d2550a56cc6a9c2b81797bfe90d613 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Mon, 17 Nov 2014 18:22:04 +1100 Subject: Stack checking extensions This patch adds: - Normal builds are done with -fstack-protector (we want to investigate using -fstack-protector-strong on gcc4.9 but for now we just use that - Build with STACK_CHECK=1 will use -fstack-protector-all and -pg and will check the stack in mcount Signed-off-by: Benjamin Herrenschmidt --- Makefile.main | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Makefile.main') diff --git a/Makefile.main b/Makefile.main index 4df3cfd..aff145e 100644 --- a/Makefile.main +++ b/Makefile.main @@ -50,7 +50,16 @@ CPPFLAGS += -DBITS_PER_LONG=64 -m64 -DHAVE_BIG_ENDIAN # causing all our printf's to warn CPPFLAGS += -ffreestanding -CFLAGS := -fno-strict-aliasing -fno-stack-protector -pie +CFLAGS := -fno-strict-aliasing -fstack-protector-all -pie + +ifeq ($(STACK_CHECK),1) +CFLAGS += -fstack-protector-all -pg +CPPFLAGS += -DSTACK_CHECK_ENABLED +else +# XXX Add -fstack-protector-strong on gcc 4.9 +CFLAGS += -fstack-protector +endif + CFLAGS += $(CWARNS) $(OPTS) $(DBG) LDFLAGS := -m64 -static -nostdlib -Wl,--gc-sections -pie -- cgit v1.1