Howto: Repackage a library with only the routines of interest?

Thomas Charron twaffle at gmail.com
Wed Jun 2 21:53:20 EDT 2010


On Wed, Jun 2, 2010 at 9:46 AM,  <bruce.labitt at autoliv.com> wrote:
> Is there a way to repackage a static library (to reduce it size) by
> including only the functions (and their dependencies) that are needed?

  Trying adding --gc-sections to the command line compile.  This will
garbage collect unused stuff, so it's not included.  I'm unsure how
well this will work with something compiled without
-ffunction-sections tho.

> Are there any tools to help do this?  (Help find dependencies, especially.
>  I think doing this manually would take months...)

  The archives will normally do this themselves, however, it will only
limit it to only including the object files in the library, not always
the *functions* only.  What you want is called 'function level
linking'.  It occured to me that, I'm not sure how it can work with
newer versions of gcc, however, a good pointer on using rlink:

https://ribosome.helixcommunity.org/2005/devdocs/FuncLevelLinking

-- 
-- Thomas



More information about the gnhlug-discuss mailing list