help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: to reduce footprint


From: Lin George
Subject: Re: to reduce footprint
Date: Sun, 24 Dec 2006 07:49:17 -0800 (PST)

Thanks and Merry X'mas Kristof! In my understanding, the major frunction of 
-gc-sections is,

Remove unnecessary functions if no functions are dependent on it (be invoked).

Is that correct? 

I am confused about this comment.

> you may need to use a
> customized linker script to move everything back into one section (more
> sections will use more space).

Does this function also achived by -gc-sections or achieved by some other 
options of gcc?


regards,
George


----- Original Message ----
From: Kristof Provost <address@hidden>
To: Lin George <address@hidden>
Cc: Michael Eager <address@hidden>; address@hidden
Sent: Saturday, December 23, 2006 6:50:52 PM
Subject: Re: to reduce footprint


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

- -gc-sections works in combination with
-fdata-sections/-ffunction-sections.

During the compilation steps gcc will put each function in a separate
section in the output file. When yuou link those output files together
ld will try to figure out which sections it needs, and which it doesn't.
(If A is the entry point and calls B, but no one calls C => A and B are
needed, C is not.)

It amounts to removing all unused functions. It may not work for all
output formats though (it does for ELF), and you may need to use a
customized linker script to move everything back into one section (more
sections will use more space).

The results will depends on how much unused code you've got in your
binary. In our case we managed to reduce the binary size by 170kB, and
memory use by around 500kB (which is pretty nice if you've only got 8MB
to work with).



> A great guide line Kristof! I have heard of all of them except this one, 
> "ld's -gc-sections". What its function?
> 
> 
> regards,
> George
> 
> 
>> As a rough guide:
>> - Strip debug information (strip)
>> - Optimize for size (-Os)
>> - Use gcc's -fdata-sections/-ffunction-sections and ld's -gc-sections
>> to remove unused functions.
>> - use a compressed file system like SquashFS. (depending on your target
>> and requirements of course)
>>
>> Kristof



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFjQoMUEZ9DhGwDugRA68oAKCfMlyWAo3Qs6bEEgD8OlqNYM9djACeOvvZ
sHLO5QTauGxukgW69kkE8e0=
=lACg
-----END PGP SIGNATURE-----

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]