static lib drops objects with side-effects

Zack Weinberg zack@codesourcery.com
Tue Feb 11 08:04:00 GMT 2003


Alan Modra <amodra@bigpond.net.au> writes:

> On Mon, Feb 10, 2003 at 05:03:04PM +0100, Wesley W. Terpstra wrote:
>> This is a bug.
>
> No it isn't.  Objects are extracted from archives during linking only
> if the object contains a symbol satisfying an undefined symbol
> reference.  If this behaviour is incompatible with your C++ model then
> don't use archives.

This reminds me that I have wanted for some time to complain about the
converse behavior: if you are using shared objects and you put say -lm
on the link line, a NEEDED entry for libm.so will appear in the linked
object even if libm.so doesn't satisfy undefined symbol references.  I
consider this to be wrong, because people tend to throw libraries onto
their link lines just because they exist, assuming that ld will ignore
them if they don't provide any useful symbols.

zw



More information about the Binutils mailing list