I'm compiling a shared object (.so) that is supposed to be LD_PRELOAD
ed into other application. I'm linking with libstdc++ and libgcc statically using -static-libgcc -static-libstdc++
to avoid shard objects conflics.
Doing this however makes my so expose everything in libstdc++ as public symbols. When I do
nm -D mylib.so
I get a lot of stuff like
00000000000714e0 W _ZNKSt15basic_streambufIcSt11char_traitsIcEE4gptrEv
0000000000071530 W _ZNKSt15basic_streambufIcSt11char_traitsIcEE4pptrEv
00000000000714d0 W _ZNKSt15basic_streambufIcSt11char_traitsIcEE5ebackEv
00000000000714f0 W _ZNKSt15basic_streambufIcSt11char_traitsIcEE5egptrEv
0000000000071540 W _ZNKSt15basic_streambufIcSt11char_traitsIcEE5epptrEv
0000000000071520 W _ZNKSt15basic_streambufIcSt11char_traitsIcEE5pbaseEv
00000000000712a0 W _ZNKSt15basic_streambufIcSt11char_traitsIcEE6getlocEv
This is bad since when this so will be LD_PRELOADed into a c++ application, these symbols are going to override the applications symbols, causing unexpected behaviour.
So how do I make gcc link statically to libstdc++ without exposing all of these symbols publically?