This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: LD: function-level linking


I got a warning from ld: "gc-sections option ignored."

The compilation command:
[quote]
or32-elf-gcc -o a.o -c -ffunction-sections -fdata-sections a.c
[/quote]

The link command is:
[quote]
or32-elf-gcc -o program a.o b.o c.o -lfoo -Wl,-gc-sections, -Wl,-static
[/quote]

I've check the object files by objdump, and each function was in its
own section (.text.function name), so I'm probably sure that the
compiler did the correct job.

According to LD manual (2.16.x):

[quote]
--no-gc-sections
--gc-sections
   Enable garbage collection of unused input sections. It is ignored
on targets that do not support this option.
[/quote]

I'm using a cross gnu-tool-chain, it may not be very well ported. What
should I check if the target (or the toolchain) support this option.

Thank you.



2006/7/10, Thiemo Seufer <ths@networkno.de>:
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




--
Tzu-Chien Chiu - SMedia Technology Corp.
URL: http://www.csie.nctu.edu.tw/~jwchiu/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]