Linkers, Loaders & Executables
When building a shared library, what is the advantage of exporting only the public functions and giving internal functions "hidden" symbol visibility?
- AInternal functions are encrypted and cannot be analyzed
- BThe dynamic linker has fewer symbols to process, loading is faster, and internal calls can skip the PLT
- CThe library becomes runnable on any OS
Show answer and explanation
Answer: B. The dynamic linker has fewer symbols to process, loading is faster, and internal calls can skip the PLT
A shared library's exported symbols might be overridden by a same-named definition in another module, so even internal calls must go through the PLT or GOT. Making them hidden removes them from outside view, reduces the symbols the dynamic linker must process and lets internal calls be direct PC-relative calls. It also avoids name collisions with other libraries and keeps the public ABI small.
- A. Nothing is encrypted.
- B. Correct. It also prevents name collisions.
- C. It does not bridge different OSes.