Pre-link static binaries/remove

Simon Richter Simon.Richter@hogyros.de
Tue Nov 11 12:10:49 GMT 2025


Hi,

On 11/11/25 7:58 PM, Thomas Richter wrote:

> is there a possibility to remove from a static library (not from a .so) 
> all symbols marked as "visibility ("hidden")"?

No, because these symbols are still required while linking against the 
static library.

Typically, libraries will have internal functions that are not visible 
to users, and these are called from different externally visible 
functions. The internal and external functions would then be defined in 
different translation units, to allow removing unused functions, but the 
reference to the internal function from the translation unit containing 
the symbol that is referenced by the external program will still need to 
be resolved.

Because that internal function is not externally visible, it will be 
declared with "hidden" visibility, but it cannot be removed before 
internal references are resolved. The symbol will not be copied to the 
dynamic symbol tables, so if you call "strip" on the final executable, 
the symbol will be removed from the final output.

    Simon


More information about the Binutils mailing list