This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [BUG] ld behavior varies for C++ static initializer dependingon .a or .o input
Ian Lance Taylor <ian at airs dot com> writes:
> Hal Black <black at ieee dot org> writes:
>> 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.
I'd like to point out that while this is true for static (.a)
libraries, it is not true for shared (.so) libraries -- the linker
generates DT_NEEDED entries for every shared library on the command
line, whether or not they satisfy undefined symbols. Personally I
consider this a bug.
zw