help-gplusplus
[Top][All Lists]
Advanced

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

Re: Having the GNU linker *not* remove unused symbols...


From: Carsten Fuchs
Subject: Re: Having the GNU linker *not* remove unused symbols...
Date: Sat, 08 Apr 2006 23:27:12 +0200
User-agent: Thunderbird 1.5 (Windows/20051201)

Hi,

first of all, Maett and Paul, thank you very much for your replies!  :-)

Paul Pluzhnikov wrote:
I guess what happens is that when the linker links the executable, it
removes all symbols from libcfsLib.a that are unused by the
executable.

Not quite: the linker doesn't remove anything from anywhere; it
simply doesn't pull in the objects that it doesn't need.

Ah, okay. ;) My thought was that it first just duplicates or "concatenates" everything that I specify on the command line in scratch memory, then does a "flood fill" to flag everything that is needed, and finally creates the final executable by removing the non-flagged parts from scratch memory again. So as your text about linkers makes clear, my assumption that executables are entirely pre-built in (scratch) memory was somewhat wrong.

You may wish to read this for an explanation:
 http://webpages.charter.net/ppluzhnikov/linker.html

If you only care about GNU ld, the --whole-archive is a good
solution. If you care about portability to other linkers, use
multiple '-u needed_symbol_1' ...

If there are too many needed symbols, another alternative is to
create an object file which will "pull" them all in:

Great!  Many thanks for your detailed answer!

Best,
Carsten



--
Ca3D - Engine    http://www.Ca3D-Engine.de
Carsten Fuchs    http://www.Ca3D-Engine.de/c_Carsten.php


reply via email to

[Prev in Thread] Current Thread [Next in Thread]