Re: Symbols which were not used, still in binary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Eager wrote:

> Arguably, the linker should know
> that add is not referenced and could remove it, but linkers are not
> usually able to slice and dice object files.

You address this limitation by compiling with "-ffunction-sections
-fdata-sections -Wl,--gc-sections".  However, it's still better to use
"static" on these kinds of local functions that are only used from the
same .o file.  This has a number of benefits:

- it ensures that internal functions of a library are not exported for
use by other code when they are not part of the defined ABI/API
- it prevents them from taking up needless relocations, which can slow
linking
- when compiled -fpic (as in a shared library) it allows for direct
calls to the function instead of having to go through the PLT which is
slower
- it allows the compiler freedom to inline

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux