From b915e7d5e3e226fa43ec68417b7cc2a49bf736e8 Mon Sep 17 00:00:00 2001 From: Michael LeMay Date: Sun, 26 Jul 2015 19:28:31 -0700 Subject: [PATCH] galileo: Omit exception handling unwind tables This patch modifies the newlib and Contiki C and C++ compiler flags to omit exception handling unwind tables (see http://wiki.dwarfstd.org/index.php?title=Exception_Handling). Removing these tables saves space in debug builds and has not caused any readily-apparent functional changes. Here is the size listing for an example program built without this patch: text data bss dec hex filename 76002 1508 21224 98734 181ae all-timers.galileo Here is the size listing for the same program with this patch: text data bss dec hex filename 72918 1508 21224 95650 175a2 all-timers.galileo The primary motivation for this patch is to help enable UEFI support. The .eh_frame and .eh_frame_hdr sections that are otherwise generated are treated as code sections by the EDK2 GenFw program, since they are read-only alloc sections. They get grouped with the actual code sections, ahead of the data sections. This perturbs symbols and complicates debugging. --- cpu/x86/Makefile.x86_common | 9 ++++++++- platform/galileo/bsp/libc/build_newlib.sh | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cpu/x86/Makefile.x86_common b/cpu/x86/Makefile.x86_common index 054cfcd68..c243dddcd 100644 --- a/cpu/x86/Makefile.x86_common +++ b/cpu/x86/Makefile.x86_common @@ -9,7 +9,14 @@ OBJCOPY = objcopy SIZE = size STRIP = strip -CFLAGS += -Wall -fno-asynchronous-unwind-tables +# Omit exception handling unwind tables (see +# http://wiki.dwarfstd.org/index.php?title=Exception_Handling). Removing these +# tables saves space and has not caused any readily-apparent functional +# changes. +# +# Synchronize the unwind table options here with the CFLAGS and CXXFLAGS in +# ./bsp/libc/build_newlib.sh. +CFLAGS += -Wall -fno-asynchronous-unwind-tables -fno-unwind-tables LDFLAGS += -Wl,-Map=contiki-$(TARGET).map,--build-id=none ifeq ($(BUILD_RELEASE),1) diff --git a/platform/galileo/bsp/libc/build_newlib.sh b/platform/galileo/bsp/libc/build_newlib.sh index cee34f3ff..89d3b870c 100755 --- a/platform/galileo/bsp/libc/build_newlib.sh +++ b/platform/galileo/bsp/libc/build_newlib.sh @@ -65,8 +65,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 -fno-stack-protector -DPREFER_SIZE_OVER_SPEED -ffunction-sections -fdata-sections" - export CXXFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -fno-stack-protector -DPREFER_SIZE_OVER_SPEED -ffunction-sections -fdata-sections" + export CFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -fno-stack-protector -DPREFER_SIZE_OVER_SPEED -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-unwind-tables" + export CXXFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -fno-stack-protector -DPREFER_SIZE_OVER_SPEED -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-unwind-tables" mkdir -p install ./configure --target=${TARGET} \