This is the mail archive of the binutils@sources.redhat.com 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: [BUG] ld behavior varies for C++ static initializer depending on .a or .o input


Hal Black <black at ieee dot org> writes:

> > It means that including any class with a static initializer in a .a
> > file would mean that that class would be included in all programs
> > linked with that .a file.
> 
> Yes.  That's the desired behavior.  If a developer were to develop a
> library with a static initializer with side-effects, it would be
> something that should be called whenever that library was used.

No Unix linker has ever worked that way.

Basically, you misunderstand how ld and ar work.  If you feel that you
have been misled by existing documentation, please let us know so that
we can fix it.

Also, while this is not the reason for not making the change, it turns
out that it is not an efficient change to make.  It would require the
linker to examine every object in every archive, which obviates the
entire point of having archives in the first place.  Again, this
inefficiency, while severe, is not the reason for not making the
change; the reason for not making the change is that ld and ar
implement behaviour which has not changed for decades, and should not
be changed now.

Ian


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