From 9f8d22961fa5224043fd032b0c9a13a1ae72fd55 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sat, 11 Aug 2012 20:13:09 -0400 Subject: [PATCH] cc makefile: enable -ffunction-sections and -fdata-sections These compiler options place each function and each global variable into its own ELF section in each .o file. This, combined with the linker option --gc-sections allows the linker to evict unused functions and variables from the final ELF file. On CC, the firmware flash bank is only 118784 bytes in total. This commit reduces the .text segment from 114120 to 83536 and .data from 572 bytes to 560 bytes. That frees up a grand total of 30596 bytes of flash and 12 bytes of RAM. --- flight/CopterControl/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 9acfdff41..f786df65c 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -503,6 +503,7 @@ endif CFLAGS += -Wall CFLAGS += -Werror +CFLAGS += -ffunction-sections -fdata-sections CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) # Compiler flags to generate dependency files: CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d