LD: function-level linking

Thiemo Seufer ths@networkno.de
Mon Jul 10 08:15:00 GMT 2006


Tzu-Chien Chiu wrote:
> Hello all.
> 
> I'm looking for a similar feature available in Visual C++.
> Function-level linking.
> 
> In Visual C++, there is an option "/Gy" which enables "function-level
> linking". That is, each function is packaged separately as a COMDAT,
> and later the linker option "/OPT:REF" eliminates the COMDATs which
> are never referenced.
> 
> FYI: http://msdn2.microsoft.com/en-us/library/bxwfs976.aspx
> 
> In this way, the entire object file won't have to be linked as a whole
> when only one of the functions in it is referenced. It's preferred
> linking for embedded system software. Not all libraries are design ed
> as glibc, which has a separate file for each file, and it's sometimes
> not easy or feasible to modify the source code of the libraries.
> 
> I can not find similar compiler and linker options in the GNU tool
> chain. What I missed?

There's gcc's -ffunction-sections, and ld's -Wl,--gc-sections.


Thiemo



More information about the Binutils mailing list