This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: LD: function-level linking
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