diff options
Diffstat (limited to 'demos/ARM7-LPC214x-G++')
-rw-r--r-- | demos/ARM7-LPC214x-G++/Makefile | 15 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-G++/Makefile.thumb | 15 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-G++/ch.ld | 5 |
3 files changed, 29 insertions, 6 deletions
diff --git a/demos/ARM7-LPC214x-G++/Makefile b/demos/ARM7-LPC214x-G++/Makefile index f54c1ba2d..95d6bfdb8 100644 --- a/demos/ARM7-LPC214x-G++/Makefile +++ b/demos/ARM7-LPC214x-G++/Makefile @@ -32,6 +32,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 =
@@ -129,6 +132,10 @@ WARN = -Wall # End of user defines
##############################################################################################
+ifeq ($(LINK_GC),yes)
+ OPT += -ffunction-sections -fdata-sections
+endif
+
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS = $(DDEFS) $(UDEFS)
@@ -145,11 +152,15 @@ OBJS = $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS) LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)
+ODFLAGS = -x --syms
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
CFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-alms=$(<:.c=.lst) $(DEFS)
CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(WARN) -Wa,-alms=$(<:.cpp=.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),)
diff --git a/demos/ARM7-LPC214x-G++/Makefile.thumb b/demos/ARM7-LPC214x-G++/Makefile.thumb index 4e2fd2f7c..29f2a61a4 100644 --- a/demos/ARM7-LPC214x-G++/Makefile.thumb +++ b/demos/ARM7-LPC214x-G++/Makefile.thumb @@ -32,6 +32,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 =
@@ -129,6 +132,10 @@ WARN = -Wall # End of user defines
##############################################################################################
+ifeq ($(LINK_GC),yes)
+ OPT += -ffunction-sections -fdata-sections
+endif
+
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS = $(DDEFS) $(UDEFS)
@@ -145,11 +152,15 @@ OBJS = $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS) LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)
+ODFLAGS = -x --syms
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
CFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-alms=$(<:.c=.lst) $(DEFS)
CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(WARN) -Wa,-alms=$(<:.cpp=.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),)
diff --git a/demos/ARM7-LPC214x-G++/ch.ld b/demos/ARM7-LPC214x-G++/ch.ld index 5fe907142..bb59cec1c 100644 --- a/demos/ARM7-LPC214x-G++/ch.ld +++ b/demos/ARM7-LPC214x-G++/ch.ld @@ -25,7 +25,7 @@ __abt_stack_size__ = 0x0004; __fiq_stack_size__ = 0x0010;
__irq_stack_size__ = 0x0080;
__svc_stack_size__ = 0x0004;
-__sys_stack_size__ = 0x0400;
+__sys_stack_size__ = 0x0100;
__stacks_total_size__ = __und_stack_size__ + __abt_stack_size__ + __fiq_stack_size__ + __irq_stack_size__ + __svc_stack_size__ + __sys_stack_size__;
MEMORY
@@ -48,7 +48,8 @@ SECTIONS .text :
{
_text = .;
- *(.text);
+ KEEP(*(.startup))
+ *(.text)
*(.text.*);
*(.rodata);
*(.rodata.*);
|