
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