enormous executable

Manuel M. T. Chakravarty chak@cse.unsw.edu.au
Wed, 03 Oct 2001 10:37:24 +1000


"Simon Marlow" <simonmar@microsoft.com> wrote,

> > | Surely the executable itself is only linked with the 
> > | functions that are actually used by the program?  
> > 
> > AFAIUI the GNU linker is not clever enough to remove junk
> > on a per-function basis, only on a per-object basis.  This is
> > why we do object-splitting -- by breaking libraries up into 
> > thousands of .o files before rolling them into a .a, the
> > effectiveness of what GNU ld can do is enhanced.
> > 
> > Perhaps more recent GNU ld's do better on some platforms?
> > I have a vague recollection of some -gc-sections flag.
> 
> Yup, but it needs compiler support.  The idea is to get the compiler to
> put each function in its own section, then the linker removes unused
> sections from the linked image.

Sounds much better than the mess that -split-objs produces
on the harddisk.

Cheers,
Manuel