On Wed, Jun 22, 2005 at 11:11:56PM +0000, Alexey Toptygin wrote: > Since I had such good luck with my last question, I figure I'll give this > one a go: > > Is there some trickery that one can use to either hide some symbols from > export or specufy the list of exported symbols when linking a shared > object, other than using a linker script? > > With gcc + binutils? > > With gcc + the solaris 8 native linker? > > I'm writing a shared library, and I'd rather export just the 3 symbols > that users of the lib will need and not the 100+ I have internally. If > not, I'll have to try to give them all names that wouldn't collide with > anyone else's stuff...
I think what you want is to compile with the option "-Wl,-x" , i.e.: gcc -Wl,-x -shared -fPIC -o foo.so *.o the "-Wl" says pass the rest of this option on to the linker, and the "-x" from `man ld` says: `-x' Delete all local symbols. Haven't actually tried it, but it should do the trick. If that doesn't work, the "oh duh" way to do it is to preprocess your code with a script that scrambles all of the symbols (but maybe this is what you meant by a linker script ;-) - Rob .
