
I've been investigating reducing the size of an omap3 uboot image to less than 64k to facilitate loading via the bootrom. I've been working with the Brian Silvermans' patch and some modifications to that. http://www.mail-archive.com/u-boot@lists.denx.de/msg16073.html
With Brians's patch, and some extra fiddling, I got to around 62k but needed to get lower (need to be under 60k ).
One thing I came across was that u-boot is not using function sections etc and as a result there's quite a bit of dead code that is included in the image.
Applying the following patch reduced the size by around 7k to approx 55k. That really helped :-) and lets me add back some functionality and still keep under 60k.
Note: 1) This only sorts out the overo. Other u-boot.lds files need to be modified in the same way. 2) This only does dead code stripping and not dead data stripping. I have not yet figured out why that is not working (hence the commented out line for -fdata-sections). This will save something, but I expect not very much.
-- Charles
--- a/board/omap3/overo/u-boot.lds +++ b/board/omap3/overo/u-boot.lds @@ -34,7 +34,7 @@ SECTIONS . = ALIGN(4); .text : { - cpu/arm_cortexa8/start.o (.text) + KEEP(cpu/arm_cortexa8/start.o (.text)) *(.text) }
diff --git a/config.mk b/config.mk index b1254e9..b129761 100644 --- a/config.mk +++ b/config.mk @@ -171,6 +171,11 @@ ifneq ($(TEXT_BASE),) LDFLAGS += -Ttext $(TEXT_BASE) endif
+# Stuff to strip out dead code +CFLAGS += -ffunction-sections +#CFLAGS += -fdata-sections +LDFLAGS += --cref --gc-sections + # Location of a usable BFD library, where we define "usable" as # "built for ${HOST}, supports ${TARGET}". Sensible values are # - When cross-compiling: the root of the cross-environment