Removing unwanted symbols from a .so

Miah Gregory miah@picsel.com
Mon Nov 8 12:49:00 GMT 2004


On Sat, 2004-11-06 at 04:35 +0100, Thomas Lopatic wrote:

> [unwanted symbols end up in the dynamic symbol table]

> > Is there either (a) a way to prevent these symbols from being added to
> > the .so in the first place (maybe through partial linking?) or (b) a way
> > to strip these extra symbols whilst keeping the library functional and
> > keeping the API symbols available?

> You might want to try writing a linker version script, for example as 
> follows:

-snip-

> This would make functions func1() and func2() visible to the outside 
> ("global") and hide all other symbols ("local", "*" wildcard). Save this 
> to a file, say script.txt, and add the following command line option to 
> GCC when linking:
> 
> -Wl,--version-script=script.txt

Superb, does exactly what I was after. Thanks for the quick reply.

-- 
Miah Gregory




More information about the Binutils mailing list