This is the mail archive of the
mailing list for the binutils project.
Re: Removing unwanted symbols from a .so
- From: Thomas Lopatic <thomas at lopatic dot de>
- To: Miah Gregory <miah at picsel dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Sat, 06 Nov 2004 04:35:46 +0100
- Subject: Re: Removing unwanted symbols from a .so
- References: <1099708078.4990.22.camel@localhost>
[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
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:
Alternatively you can use visibility attributes in you source code, e.g.
as follows (assuming you use C or C++):
int i __attribute__ ((visibility ("hidden")));
This will define a variable "i" and set it to "hidden" visibility, which
again means that it will not show up in your dynamic symbol table.
So basically "hidden" visibility does to shared objects what "static"
does to object files - limit the scope of a symbol.