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

* [U-Boot] Easy reduction to u-boot image size
  2010-05-26  0:44 [U-Boot] Easy reduction to u-boot image size Charles Manning
@ 2010-05-26  4:36 ` Mike Frysinger
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2010-05-26  4:36 UTC (permalink / raw)
  To: u-boot

On Tuesday 25 May 2010 20:44:26 Charles Manning wrote:
> 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.

FWIW, Blackfin has been using function/data sections and gc sections for quite 
a while now without any problems.  i vaguely recall things breaking with 1.1.6 
when i first implemented it, but 1.3.x+ havent caused troubles.

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

might be better to add this to one arch at a time as maintainers can verify 
it.  that way they can take advantage of things while the others catch up.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100526/6c839ad5/attachment.pgp 

^ permalink raw reply	[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