IT lexicon › Programming › Symbol visibility

Symbol visibility

Programming På svenska → Updated: 2026-11-05

The attribute that decides whether a symbol in a shared library can be seen from outside it or only from within.

ELF exports everything that isn't static by default. A large C++ library can therefore carry tens of thousands of symbols in its dynamic symbol table, most of them internal helpers nobody outside should ever touch. Windows went the other way from the start: nothing leaves a DLL without __declspec(dllexport). GCC 4.0 (2005) gave the ELF world -fvisibility=hidden and the default, hidden and protected attributes.

The payoff is bigger than a shorter table. An exported function can be replaced at load time by one with the same name from another library, so the compiler may not inline it and calls have to go through the PLT. Once the symbol is hidden, the compiler knows exactly which function is being called, and inlining and direct calls are back on the table.

← Back to the lexicon