This is enabled by -fvisibility=hidden
. The other option which is the default is fvisibility=default
This hides most of the ELF symbols that would otherwise have been public. This gives numerous benefits:
- Improved load time of the DSO (Dynamic Shared Object).
- Lets the optimiser produce better code. A PLT indirection is when a function call or variable access must be looked up via the GOT such as in PIC code. These indirections can be avoided for hidden symbols as they can’t be accessed/called from outside the DSO
- Reduces the DSO size by 5-20%
- Lower chance of symbol collision