Re: garbage collection of unused code

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

 



On 10-6-9 下午3:08, Ian Lance Taylor wrote:
> Da Zheng <zhengda1936@xxxxxxxxx> writes:
> 
>> gc-selections in ld can enable garbage collection of unused input sections. I
>> hope some functions can be preserved even though they are not called by other
>> parts of the code. I don't want to change the code. Could I somehow specify in
>> the command line so that some specific functions are excluded from ld's garbage
>> collection?
> 
> The easiest way is to find some set of symbols in the sections you can
> to keep and add a -u option to the linker for each such symbol.  When
> linking using the compiler, as you should, write -Wl,-u,SYMBOL.
> 
> Another way is to use a linker script and use KEEP with the sections
> you want to keep.  I don't recommend this approach unless you can't
> use the first one for some reason.  See the linker manual.
Thanks. The -u option works for me pretty well.

Zheng Da


[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