diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-08-25 14:17:38 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-08-25 14:17:38 +0000 |
commit | 65baafa9e6e82293a202c96e832c7779b7216550 (patch) | |
tree | 5e8168a51d1d8f8e54deb9d2b9394f9955e18705 /demos | |
parent | 01afd268a5f8bb48007b44e6c2aa7c0d3eafe757 (diff) | |
download | ChibiOS-65baafa9e6e82293a202c96e832c7779b7216550.tar.gz ChibiOS-65baafa9e6e82293a202c96e832c7779b7216550.tar.bz2 ChibiOS-65baafa9e6e82293a202c96e832c7779b7216550.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@404 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos')
-rw-r--r-- | demos/ARM7-AT91SAM7X-GCC/Makefile | 15 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-GCC/Makefile.thumb | 15 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-GCC/ch.ld | 14 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-WEB-GCC/Makefile | 14 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb | 14 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-WEB-GCC/ch.ld | 14 | ||||
-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 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-GCC-minimal/Makefile | 15 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb | 15 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-GCC-minimal/ch.ld | 13 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-GCC/Makefile | 8 | ||||
-rw-r--r-- | demos/ARM7-LPC214x-GCC/Makefile.thumb | 8 | ||||
-rw-r--r-- | demos/ARMCM3-STM32F103-GCC/Makefile | 15 | ||||
-rw-r--r-- | demos/ARMCM3-STM32F103-GCC/ch.ld | 14 |
16 files changed, 174 insertions, 35 deletions
diff --git a/demos/ARM7-AT91SAM7X-GCC/Makefile b/demos/ARM7-AT91SAM7X-GCC/Makefile index 7d3a7b71e..5629c9842 100644 --- a/demos/ARM7-AT91SAM7X-GCC/Makefile +++ b/demos/ARM7-AT91SAM7X-GCC/Makefile @@ -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 =
@@ -114,6 +117,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
@@ -125,10 +132,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),)
diff --git a/demos/ARM7-AT91SAM7X-GCC/Makefile.thumb b/demos/ARM7-AT91SAM7X-GCC/Makefile.thumb index 0b2779708..4ca9bded5 100644 --- a/demos/ARM7-AT91SAM7X-GCC/Makefile.thumb +++ b/demos/ARM7-AT91SAM7X-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 =
@@ -114,6 +117,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
@@ -125,10 +132,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),)
diff --git a/demos/ARM7-AT91SAM7X-GCC/ch.ld b/demos/ARM7-AT91SAM7X-GCC/ch.ld index 541c73b5b..7459bdac1 100644 --- a/demos/ARM7-AT91SAM7X-GCC/ch.ld +++ b/demos/ARM7-AT91SAM7X-GCC/ch.ld @@ -45,11 +45,16 @@ SECTIONS .text :
{
_text = .;
- *(.text);
+ KEEP(*(.startup))
+ *(.text)
+ *(.text.*);
*(.rodata);
- *(.rodata*);
+ *(.rodata.*);
*(.glue_7t);
*(.glue_7);
+ *(.gcc*);
+ *(.ctors);
+ *(.dtors);
. = ALIGN(4);
_etext = .;
} > flash
@@ -59,8 +64,11 @@ SECTIONS .data :
{
_data = .;
+ _data = .;
*(.data)
. = ALIGN(4);
+ *(.data.*)
+ . = ALIGN(4);
*(.ramtext)
. = ALIGN(4);
_edata = .;
@@ -71,6 +79,8 @@ SECTIONS _bss_start = .;
*(.bss)
. = ALIGN(4);
+ *(.bss.*)
+ . = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_bss_end = .;
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile index 77651350c..243d525f8 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile @@ -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 =
@@ -127,6 +130,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
@@ -138,10 +145,15 @@ 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),)
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb index 431111305..0b5c72349 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile.thumb +++ b/demos/ARM7-AT91SAM7X-WEB-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 =
@@ -128,6 +131,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
@@ -139,10 +146,15 @@ 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),)
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/ch.ld b/demos/ARM7-AT91SAM7X-WEB-GCC/ch.ld index 541c73b5b..7459bdac1 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/ch.ld +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/ch.ld @@ -45,11 +45,16 @@ SECTIONS .text :
{
_text = .;
- *(.text);
+ KEEP(*(.startup))
+ *(.text)
+ *(.text.*);
*(.rodata);
- *(.rodata*);
+ *(.rodata.*);
*(.glue_7t);
*(.glue_7);
+ *(.gcc*);
+ *(.ctors);
+ *(.dtors);
. = ALIGN(4);
_etext = .;
} > flash
@@ -59,8 +64,11 @@ SECTIONS .data :
{
_data = .;
+ _data = .;
*(.data)
. = ALIGN(4);
+ *(.data.*)
+ . = ALIGN(4);
*(.ramtext)
. = ALIGN(4);
_edata = .;
@@ -71,6 +79,8 @@ SECTIONS _bss_start = .;
*(.bss)
. = ALIGN(4);
+ *(.bss.*)
+ . = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_bss_end = .;
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.*);
diff --git a/demos/ARM7-LPC214x-GCC-minimal/Makefile b/demos/ARM7-LPC214x-GCC-minimal/Makefile index 93e7df446..d035f6f23 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/Makefile +++ b/demos/ARM7-LPC214x-GCC-minimal/Makefile @@ -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 =
@@ -111,6 +114,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
@@ -122,10 +129,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),)
diff --git a/demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb b/demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb index 11b393c47..ace728b15 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/Makefile.thumb +++ b/demos/ARM7-LPC214x-GCC-minimal/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 =
@@ -111,6 +114,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
@@ -122,10 +129,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),)
diff --git a/demos/ARM7-LPC214x-GCC-minimal/ch.ld b/demos/ARM7-LPC214x-GCC-minimal/ch.ld index a71fac21b..bb59cec1c 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/ch.ld +++ b/demos/ARM7-LPC214x-GCC-minimal/ch.ld @@ -48,11 +48,16 @@ SECTIONS .text :
{
_text = .;
- *(.text);
+ KEEP(*(.startup))
+ *(.text)
+ *(.text.*);
*(.rodata);
- *(.rodata*);
+ *(.rodata.*);
*(.glue_7t);
*(.glue_7);
+ *(.gcc*);
+ *(.ctors);
+ *(.dtors);
. = ALIGN(4);
_etext = .;
} > flash
@@ -64,6 +69,8 @@ SECTIONS _data = .;
*(.data)
. = ALIGN(4);
+ *(.data.*)
+ . = ALIGN(4);
*(.ramtext)
. = ALIGN(4);
_edata = .;
@@ -74,6 +81,8 @@ SECTIONS _bss_start = .;
*(.bss)
. = ALIGN(4);
+ *(.bss.*)
+ . = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_bss_end = .;
diff --git a/demos/ARM7-LPC214x-GCC/Makefile b/demos/ARM7-LPC214x-GCC/Makefile index c10ff9d94..8e1790bb2 100644 --- a/demos/ARM7-LPC214x-GCC/Makefile +++ b/demos/ARM7-LPC214x-GCC/Makefile @@ -111,10 +111,6 @@ OPT = -O2 -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
@@ -122,6 +118,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
diff --git a/demos/ARM7-LPC214x-GCC/Makefile.thumb b/demos/ARM7-LPC214x-GCC/Makefile.thumb index b388e64d7..4b62f9091 100644 --- a/demos/ARM7-LPC214x-GCC/Makefile.thumb +++ b/demos/ARM7-LPC214x-GCC/Makefile.thumb @@ -111,10 +111,6 @@ 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
@@ -122,6 +118,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
diff --git a/demos/ARMCM3-STM32F103-GCC/Makefile b/demos/ARMCM3-STM32F103-GCC/Makefile index dbf9fd9eb..a0c76a43b 100644 --- a/demos/ARMCM3-STM32F103-GCC/Makefile +++ b/demos/ARMCM3-STM32F103-GCC/Makefile @@ -27,6 +27,9 @@ BIN = $(CP) -O binary MCU = cortex-m3
+# 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 =
@@ -103,6 +106,10 @@ WARN = -Wall -Wstrict-prototypes # 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)
@@ -113,10 +120,14 @@ OBJS = $(ASMOBJS) $(COBJS) LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU) -mthumb
+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
# Generate dependency information
CPFLAGS += -MD -MP -MF .dep/$(@F).d
diff --git a/demos/ARMCM3-STM32F103-GCC/ch.ld b/demos/ARMCM3-STM32F103-GCC/ch.ld index d5f948476..b6b390f80 100644 --- a/demos/ARMCM3-STM32F103-GCC/ch.ld +++ b/demos/ARMCM3-STM32F103-GCC/ch.ld @@ -41,12 +41,16 @@ SECTIONS .text :
{
_text = .;
- *(INTVEC);
- *(.text);
+ KEEP(*(INTVEC));
+ *(.text)
+ *(.text.*);
*(.rodata);
- *(.rodata*);
+ *(.rodata.*);
*(.glue_7t);
*(.glue_7);
+ *(.gcc*);
+ *(.ctors);
+ *(.dtors);
. = ALIGN(4);
_etext = .;
} > flash
@@ -58,6 +62,8 @@ SECTIONS _data = .;
*(.data)
. = ALIGN(4);
+ *(.data.*)
+ . = ALIGN(4);
*(.ramtext)
. = ALIGN(4);
_edata = .;
@@ -68,6 +74,8 @@ SECTIONS _bss_start = .;
*(.bss)
. = ALIGN(4);
+ *(.bss.*)
+ . = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_bss_end = .;
|