[U-Boot] [RFC PATCH] ppc4xx: Use gc-sections to reduce image size
Detlev Zundel
dzu at denx.de
Fri Sep 24 12:07:26 CEST 2010
Hi Stefan,
> 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
Interesting.
Just for whoever is interested - I wondered how to find out what is
actually unused to find pointers to unused crufty code.
Actually this is pretty easy by adding "--print-gc-sections" to the
PLATFORM_LDFLAGS:
-----8<-----
diff --git a/arch/powerpc/cpu/ppc4xx/config.mk b/arch/powerpc/cpu/ppc4xx/config.mk
index b0d346a..f1e15c9 100644
--- a/arch/powerpc/cpu/ppc4xx/config.mk
+++ b/arch/powerpc/cpu/ppc4xx/config.mk
@@ -36,7 +36,7 @@ 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_LDFLAGS += --gc-sections --print-gc-sections
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
# Use default linker script. Board port can override in board/*/config.mk
-----8<-----
Using this, the linker prints lots of message slike this:
ppc_4xxFP-ld: Removing unused section '.data' in file 'arch/powerpc/cpu/ppc4xx/start.o'
ppc_4xxFP-ld: Removing unused section '.bss' in file 'arch/powerpc/cpu/ppc4xx/start.o'
ppc_4xxFP-ld: Removing unused section '.text' in file 'board/amcc/sequoia/init.o'
ppc_4xxFP-ld: Removing unused section '.data' in file 'board/amcc/sequoia/init.o'
ppc_4xxFP-ld: Removing unused section '.bss' in file 'board/amcc/sequoia/init.o'
ppc_4xxFP-ld: Removing unused section '.text' in file 'arch/powerpc/cpu/ppc4xx/resetvec.o'
ppc_4xxFP-ld: Removing unused section '.data' in file 'arch/powerpc/cpu/ppc4xx/resetvec.o'
ppc_4xxFP-ld: Removing unused section '.bss' in file 'arch/powerpc/cpu/ppc4xx/resetvec.o'
I believe they can be gladly ignored, because the "generic" segments are
now empty thanks to the "-ffunction-sections -fdata-sections"
directives. What is really interesting are messages like this:
ppc_4xxFP-ld: Removing unused section '.text.gpio_read_out_bit' in file 'arch/powerpc/cpu/ppc4xx/libppc4xx.a(gpio.o)'
ppc_4xxFP-ld: Removing unused section '.text.gpio_read_in_bit' in file 'arch/powerpc/cpu/ppc4xx/libppc4xx.a(gpio.o)'
ppc_4xxFP-ld: Removing unused section '.text.gpio_config' in file 'arch/powerpc/cpu/ppc4xx/libppc4xx.a(gpio.o)'
ppc_4xxFP-ld: Removing unused section '.text.gpio_write_bit' in file 'arch/powerpc/cpu/ppc4xx/libppc4xx.a(gpio.o)'
They essentially show the functions that are not used in this link run.
Cheers
Detlev
--
There are three kinds of people in the world; those who can count and
those who can't.
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
More information about the U-Boot
mailing list