From b79fcaa7d8875f33861b640c6f3424236e4b0f69 Mon Sep 17 00:00:00 2001 From: Michael LeMay Date: Thu, 2 Jul 2015 19:14:04 -0700 Subject: [PATCH] galileo: Override Ubuntu's default GCC flags to avoid link errors Ubuntu enables GCC's stack protector by default (see https://wiki.ubuntu.com/Security/Features). This causes link errors like the following: ...undefined reference to `__stack_chk_fail' To avoid these errors, this patch adds the "-fno-stack-protector" flag to both the CFLAGS used by the Contiki build process and the CFLAGS used by the newlib build process. --- platform/galileo/Makefile.galileo | 2 +- platform/galileo/bsp/libc/build_newlib.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/galileo/Makefile.galileo b/platform/galileo/Makefile.galileo index 7dce1a5c8..05a2b7280 100644 --- a/platform/galileo/Makefile.galileo +++ b/platform/galileo/Makefile.galileo @@ -8,7 +8,7 @@ CONTIKI_SOURCEFILES += contiki-main.c newlib-syscalls.c clock.c rtimer-arch.c CONTIKI_CPU=$(CONTIKI)/cpu/x86 include $(CONTIKI)/cpu/x86/Makefile.x86_quarkX1000 -CFLAGS += -m32 -march=i586 -nostdinc -isystem $(LIBC)/include -isystem $(LIBGCC_PATH)/include -isystem $(LIBGCC_PATH)/include-fixed +CFLAGS += -m32 -march=i586 -fno-stack-protector -nostdinc -isystem $(LIBC)/include -isystem $(LIBGCC_PATH)/include -isystem $(LIBGCC_PATH)/include-fixed LDFLAGS += -m32 -nostdlib -T $(LINKERSCRIPT) ASFLAGS += --32 -march=i586 -mtune=i586 diff --git a/platform/galileo/bsp/libc/build_newlib.sh b/platform/galileo/bsp/libc/build_newlib.sh index a187a7838..baf2cab93 100755 --- a/platform/galileo/bsp/libc/build_newlib.sh +++ b/platform/galileo/bsp/libc/build_newlib.sh @@ -57,8 +57,8 @@ build() { export COMPILER_AS_FOR_TARGET=as export COMPILER_LD_FOR_TARGET=ld export COMPILER_NM_FOR_TARGET=nm - export CFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -DPREFER_SIZE_OVER_SPEED" - export CXXFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -DPREFER_SIZE_OVER_SPEED" + export CFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -fno-stack-protector -DPREFER_SIZE_OVER_SPEED" + export CXXFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -fno-stack-protector -DPREFER_SIZE_OVER_SPEED" mkdir -p install ./configure --target=${TARGET} \