help-make
[Top][All Lists]
Advanced

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

Re: to reduce footprint


From: Kristof Provost
Subject: Re: to reduce footprint
Date: Sun, 24 Dec 2006 18:37:23 +0100
User-agent: Thunderbird 1.5.0.9 (Windows/20061207)

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

It may be easier to understand once you've got a little information
about ELF files. On linux 'man elf' will give you some in-depth info,
the series on http://www.linuxjournal.com/article/1059 should be a good
introduction.

It may also be interesting to create a sample program and see what
happens when you pass different objects. (readelf, objdump and nm can
give you a lot of information).

Kristof

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

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


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

iD8DBQFFjrrTUEZ9DhGwDugRA0iYAJ9zQBjIfK1cEX609StYVjKIAXZmyQCgm05d
9tdjfXI5t4Le/ELJnHevpUE=
=Rh3L
-----END PGP SIGNATURE-----




reply via email to

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