I compiled a C++ library under Linux/Mac with its symbols hidden. I’ve used __attribute__ ((visibility("hidden"))) for all my classes and compiled with options (-c -O2 -fPIC -MMD -MP -MF). Under Mac, using MacDependencies, the job is done just fine as I see only my exports (I actually saw the difference before and after).
However, I noticed that using nm I still see all the names of the symbols. This happens under both Mac and Linux.
Why is that? Is there any way to avoid this?
Public or hidden, symbols are still there.
nmshows all symbols. The difference is that hidden symbols are not available to the dynamic linker, i.e. not exported and can not be interposed.You might also like the following
man gcc: