public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] Easy reduction to u-boot image size
@ 2010-05-26  0:44 Charles Manning
  2010-05-26  4:36 ` Mike Frysinger
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Manning @ 2010-05-26  0:44 UTC (permalink / raw)
  To: u-boot

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 at 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-26  4:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26  0:44 [U-Boot] Easy reduction to u-boot image size Charles Manning
2010-05-26  4:36 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox