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: Paul Pluzhnikov
Subject: Re: Having the GNU linker *not* remove unused symbols...
Date: Fri, 07 Apr 2006 21:42:52 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

Carsten Fuchs <CarstenFuchs@T-Online.de> writes:

> 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.

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:

void needed_symbol_1();
void needed_symbol_2();
...
void not_called()
{
    needed_symbol_1();
    needed_symbol_2();
    ...
}

[You'll have to explicitly list that "dummy" object on the link line.]

> Thus, is there a way to make the linker *not* remove some or all
> unused symbols somehow? Isn't that the supposed purpose of the
> --export-dynamic parameter?

No: --export-dynamic has totally different meaning and purpose.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

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