Commit dccc537a authored by Andrew Thoelke's avatar Andrew Thoelke
Browse files

Use --gc-sections during link

All common functions are being built into all binary images,
whether or not they are actually used. This change enables the
use of -ffunction-sections, -fdata-sections and --gc-sections
in the compiler and linker to remove unused code and data from
the images.

Change-Id: Ia9f78c01054ac4fa15d145af38b88a0d6fb7d409
parent 2eb01d34
...@@ -150,8 +150,10 @@ ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ ...@@ -150,8 +150,10 @@ ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
CFLAGS := -nostdinc -pedantic -ffreestanding -Wall \ CFLAGS := -nostdinc -pedantic -ffreestanding -Wall \
-Werror -mgeneral-regs-only -std=c99 -c -Os \ -Werror -mgeneral-regs-only -std=c99 -c -Os \
-DDEBUG=${DEBUG} ${INCLUDES} ${CFLAGS} -DDEBUG=${DEBUG} ${INCLUDES} ${CFLAGS}
CFLAGS += -ffunction-sections -fdata-sections
LDFLAGS += --fatal-warnings -O1 LDFLAGS += --fatal-warnings -O1
LDFLAGS += --gc-sections
vpath %.ld.S bl1:bl2:bl31 vpath %.ld.S bl1:bl2:bl31
......
...@@ -43,8 +43,8 @@ SECTIONS ...@@ -43,8 +43,8 @@ SECTIONS
{ {
ro : { ro : {
__RO_START__ = .; __RO_START__ = .;
*bl1_entrypoint.o(.text) *bl1_entrypoint.o(.text*)
*(.text) *(.text*)
*(.rodata*) *(.rodata*)
*(.vectors) *(.vectors)
__RO_END__ = .; __RO_END__ = .;
...@@ -57,7 +57,7 @@ SECTIONS ...@@ -57,7 +57,7 @@ SECTIONS
. = NEXT(16); /* Align LMA */ . = NEXT(16); /* Align LMA */
.data : ALIGN(16) { /* Align VMA */ .data : ALIGN(16) { /* Align VMA */
__DATA_RAM_START__ = .; __DATA_RAM_START__ = .;
*(.data) *(.data*)
__DATA_RAM_END__ = .; __DATA_RAM_END__ = .;
} >RAM AT>ROM } >RAM AT>ROM
...@@ -73,7 +73,7 @@ SECTIONS ...@@ -73,7 +73,7 @@ SECTIONS
*/ */
.bss : ALIGN(16) { .bss : ALIGN(16) {
__BSS_START__ = .; __BSS_START__ = .;
*(.bss) *(.bss*)
*(COMMON) *(COMMON)
__BSS_END__ = .; __BSS_END__ = .;
} >RAM } >RAM
......
...@@ -47,8 +47,8 @@ SECTIONS ...@@ -47,8 +47,8 @@ SECTIONS
ro . : { ro . : {
__RO_START__ = .; __RO_START__ = .;
*bl2_entrypoint.o(.text) *bl2_entrypoint.o(.text*)
*(.text) *(.text*)
*(.rodata*) *(.rodata*)
*(.vectors) *(.vectors)
__RO_END_UNALIGNED__ = .; __RO_END_UNALIGNED__ = .;
...@@ -63,7 +63,7 @@ SECTIONS ...@@ -63,7 +63,7 @@ SECTIONS
.data . : { .data . : {
__DATA_START__ = .; __DATA_START__ = .;
*(.data) *(.data*)
__DATA_END__ = .; __DATA_END__ = .;
} >RAM } >RAM
...@@ -79,7 +79,7 @@ SECTIONS ...@@ -79,7 +79,7 @@ SECTIONS
*/ */
.bss : ALIGN(16) { .bss : ALIGN(16) {
__BSS_START__ = .; __BSS_START__ = .;
*(SORT_BY_ALIGNMENT(.bss)) *(SORT_BY_ALIGNMENT(.bss*))
*(COMMON) *(COMMON)
__BSS_END__ = .; __BSS_END__ = .;
} >RAM } >RAM
......
...@@ -48,14 +48,14 @@ SECTIONS ...@@ -48,14 +48,14 @@ SECTIONS
ro . : { ro . : {
__RO_START__ = .; __RO_START__ = .;
*bl31_entrypoint.o(.text) *bl31_entrypoint.o(.text*)
*(.text) *(.text*)
*(.rodata*) *(.rodata*)
/* Ensure 8-byte alignment for descriptors */ /* Ensure 8-byte alignment for descriptors and ensure inclusion */
. = ALIGN(8); . = ALIGN(8);
__RT_SVC_DESCS_START__ = .; __RT_SVC_DESCS_START__ = .;
*(rt_svc_descs) KEEP(*(rt_svc_descs))
__RT_SVC_DESCS_END__ = .; __RT_SVC_DESCS_END__ = .;
*(.vectors) *(.vectors)
...@@ -71,7 +71,7 @@ SECTIONS ...@@ -71,7 +71,7 @@ SECTIONS
.data . : { .data . : {
__DATA_START__ = .; __DATA_START__ = .;
*(.data) *(.data*)
__DATA_END__ = .; __DATA_END__ = .;
} >RAM } >RAM
...@@ -87,7 +87,7 @@ SECTIONS ...@@ -87,7 +87,7 @@ SECTIONS
*/ */
.bss : ALIGN(16) { .bss : ALIGN(16) {
__BSS_START__ = .; __BSS_START__ = .;
*(.bss) *(.bss*)
*(COMMON) *(COMMON)
__BSS_END__ = .; __BSS_END__ = .;
} >RAM } >RAM
......
...@@ -48,8 +48,8 @@ SECTIONS ...@@ -48,8 +48,8 @@ SECTIONS
ro . : { ro . : {
__RO_START__ = .; __RO_START__ = .;
*tsp_entrypoint.o(.text) *tsp_entrypoint.o(.text*)
*(.text) *(.text*)
*(.rodata*) *(.rodata*)
*(.vectors) *(.vectors)
__RO_END_UNALIGNED__ = .; __RO_END_UNALIGNED__ = .;
...@@ -64,7 +64,7 @@ SECTIONS ...@@ -64,7 +64,7 @@ SECTIONS
.data . : { .data . : {
__DATA_START__ = .; __DATA_START__ = .;
*(.data) *(.data*)
__DATA_END__ = .; __DATA_END__ = .;
} >RAM } >RAM
...@@ -80,7 +80,7 @@ SECTIONS ...@@ -80,7 +80,7 @@ SECTIONS
*/ */
.bss : ALIGN(16) { .bss : ALIGN(16) {
__BSS_START__ = .; __BSS_START__ = .;
*(SORT_BY_ALIGNMENT(.bss)) *(SORT_BY_ALIGNMENT(.bss*))
*(COMMON) *(COMMON)
__BSS_END__ = .; __BSS_END__ = .;
} >RAM } >RAM
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment