[U-Boot] [RFC PATCH] ppc4xx: Use gc-sections to reduce image size
Stefan Roese
sr at denx.de
Thu Sep 23 11:50:28 CEST 2010
This patch enables gc-sections for PPC4xx. This is done to
generate smaller U-Boot images. For this the linker script
also needs some tweaking:
- For example change *(text) to *(text*)
- Add KEEP to some of the symbols, especially "resetvec"
This patch is tested on the following boards and reduces
the image size by the these values:
Canyonlands: 11,642
Katmai: 9,170
Kilauea: 10,742
Sequoia: 11,398
Additionally this patch integrates a bit of cleanup to the
PPC4xx default linker script.
Please note that this patch only enables gc-sections for PPC4xx.
Other PowerPC's may enable it as well but also need to change
the linker scripts accordingly. I didn't do this in this patch
since I can't test all those platforms/boards.
Once all PowerPC platforms have gc-sections enabled, the
changes to arch/powerpc/cpu/ppc4xx/config.mk should be moved
to arch/powerpc/config.mk
Signed-off-by: Stefan Roese <sr at denx.de>
---
arch/powerpc/cpu/ppc4xx/config.mk | 6 ++++
arch/powerpc/cpu/ppc4xx/u-boot.lds | 53 +++++++-----------------------------
2 files changed, 16 insertions(+), 43 deletions(-)
diff --git a/arch/powerpc/cpu/ppc4xx/config.mk b/arch/powerpc/cpu/ppc4xx/config.mk
index 5bda710..b0d346a 100644
--- a/arch/powerpc/cpu/ppc4xx/config.mk
+++ b/arch/powerpc/cpu/ppc4xx/config.mk
@@ -33,5 +33,11 @@ else
PLATFORM_CPPFLAGS += -Wa,-m405 -mcpu=405
endif
+# Enable gc-sections to enable generation of smaller images.
+# Please note that the linker scripts may need some tweaking with this
+# change as well.
+PLATFORM_LDFLAGS += --gc-sections
+PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+
# Use default linker script. Board port can override in board/*/config.mk
LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/ppc4xx/u-boot.lds
diff --git a/arch/powerpc/cpu/ppc4xx/u-boot.lds b/arch/powerpc/cpu/ppc4xx/u-boot.lds
index eca1f9d..c3e0e16 100644
--- a/arch/powerpc/cpu/ppc4xx/u-boot.lds
+++ b/arch/powerpc/cpu/ppc4xx/u-boot.lds
@@ -27,8 +27,7 @@
#endif
OUTPUT_ARCH(powerpc)
-/* Do we need any of these for elf?
- __DYNAMIC = 0; */
+
PHDRS
{
text PT_LOAD;
@@ -39,43 +38,16 @@ SECTIONS
{
/* Read-only sections, merged into text segment: */
. = + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .rel.text : { *(.rel.text) }
- .rela.text : { *(.rela.text) }
- .rel.data : { *(.rel.data) }
- .rela.data : { *(.rela.data) }
- .rel.rodata : { *(.rel.rodata) }
- .rela.rodata : { *(.rela.rodata) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : { *(.init) }
- .plt : { *(.plt) }
.text :
{
- *(.text)
- *(.got1)
+ *(.text*)
} :text
_etext = .;
PROVIDE (etext = .);
.rodata :
{
- *(.eh_frame)
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
} :text
- .fini : { *(.fini) } =0
- .ctors : { *(.ctors) }
- .dtors : { *(.dtors) }
/* Read-write section, merged into data segment: */
. = (. + 0x00FF) & 0xFFFFFF00;
@@ -83,23 +55,19 @@ SECTIONS
PROVIDE (erotext = .);
.reloc :
{
- *(.got)
+ KEEP(*(.got))
_GOT2_TABLE_ = .;
- *(.got2)
+ KEEP(*(.got2))
_FIXUP_TABLE_ = .;
- *(.fixup)
+ KEEP(*(.fixup))
}
__got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
__fixup_entries = (. - _FIXUP_TABLE_) >> 2;
.data :
{
- *(.data)
- *(.data1)
- *(.sdata)
- *(.sdata2)
- *(.dynamic)
- CONSTRUCTORS
+ *(.data*)
+ *(.sdata*)
}
_edata = .;
PROVIDE (edata = .);
@@ -138,7 +106,7 @@ SECTIONS
.resetvec RESET_VECTOR_ADDRESS :
{
- *(.resetvec)
+ KEEP(*(.resetvec))
} :text = 0xffff
. = RESET_VECTOR_ADDRESS + 0x4;
@@ -157,9 +125,8 @@ SECTIONS
__bss_start = .;
.bss (NOLOAD) :
{
- *(.sbss) *(.scommon)
- *(.dynbss)
- *(.bss)
+ *(.sbss*)
+ *(.bss*)
*(COMMON)
} :bss
--
1.7.3
More information about the U-Boot
mailing list