aboutsummaryrefslogtreecommitdiffstats
path: root/demos/ARM7-LPC214x-GCC/Makefile.thumb
diff options
context:
space:
mode:
Diffstat (limited to 'demos/ARM7-LPC214x-GCC/Makefile.thumb')
-rw-r--r--demos/ARM7-LPC214x-GCC/Makefile.thumb15
1 files changed, 13 insertions, 2 deletions
diff --git a/demos/ARM7-LPC214x-GCC/Makefile.thumb b/demos/ARM7-LPC214x-GCC/Makefile.thumb
index 0e426e5b7..b388e64d7 100644
--- a/demos/ARM7-LPC214x-GCC/Makefile.thumb
+++ b/demos/ARM7-LPC214x-GCC/Makefile.thumb
@@ -26,6 +26,9 @@ BIN = $(CP) -O binary
MCU = arm7tdmi
+# Enable this if you want the linker to remove unused code and data
+LINK_GC = yes
+
# List all default C defines here, like -D_DEBUG=1
DDEFS =
@@ -108,6 +111,10 @@ OPT = -Os -ggdb -fomit-frame-pointer -mabi=apcs-gnu
#OPT += -ffixed-r7
OPT += -falign-functions=16
+ifeq ($(LINK_GC),yes)
+ OPT += -ffunction-sections -fdata-sections
+endif
+
# Define warning options here
WARN = -Wall -Wstrict-prototypes
@@ -126,10 +133,14 @@ ASMOBJS = $(ASMSRC:.s=.o)
LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)
+ODFLAGS = -x --syms
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
CPFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-alms=$(<:.c=.lst) $(DEFS)
-LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
-ODFLAGS = -x --syms
+ifeq ($(LINK_GC),yes)
+ LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LIBDIR)
+else
+ LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
+endif
# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(TSRC),)