Skip to content

Commit

Permalink
Makefile: Disable stack protector due to gcc problems
Browse files Browse the repository at this point in the history
Depending on how it was built, gcc will use the canary from a global
(works for us) or from the TLS (doesn't work for us and accesses
random stuff instead).

Fixing that would be tricky. There are talks of adding a gcc option
to force use of globals, but in the meantime, disable the stack
protector

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[stewart@linux.vnet.ibm.com: add -fno-stack-protector]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>

(cherry picked from commit fe6f1f9)
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
ozbenh authored and stewartsmith committed Dec 22, 2016
1 parent 635cb0e commit f518486
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Makefile.main
Expand Up @@ -78,12 +78,18 @@ ifeq ($(SKIBOOT_GCOV),1)
CFLAGS += -fprofile-arcs -ftest-coverage -DSKIBOOT_GCOV=1
endif

# Stack protector disabled for now. gcc tends to use the TLS to
# access the canary (depending on how gcc was built), and this won't
# work for us.
#
ifeq ($(STACK_CHECK),1)
CFLAGS += -fstack-protector-all -pg
#CFLAGS += -fstack-protector-all -pg
CFLAGS += -fno-stack-protector -pg
CPPFLAGS += -DSTACK_CHECK_ENABLED
else
CFLAGS += -fstack-protector
CFLAGS += $(call try-cflag,$(CC),-fstack-protector-strong)
CFLAGS += -fno-stack-protector
#CFLAGS += -fstack-protector
#CFLAGS += $(call try-cflag,$(CC),-fstack-protector-strong)
endif

CFLAGS += $(call try-cflag,$(CC),-Wjump-misses-init) \
Expand Down

0 comments on commit f518486

Please sign in to comment.