This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Global Constructors and Shared Libraries
At 12:26 AM 6/26/00 +0200, Martin v. Loewis wrote:
>2b) On systems without such a section, collecting is deferred to the
> time when main executable is linked. At that time, a function
> __main is constructed, which invokes all the functions. In turn,
> when the compiler encounters main, it adds an implicit call to
> __main. I believe __main will have only a single initializer
> function per shared library, so that recollection is not needed
> when a shared library changes - only when it changes so much that
> it needs initialization now, but didn't before.
Ah .. the missing piece! Thanks!
So collect should emit some "global initializer" into the library that
__main can invoke, and therefore invoke each constructor in the library?
I don't see my version of collect doing this, so there must be some
switches I'm missing in my build?
Also, what happens when one has a dependency chain such as:
myprog --> sharedlib1 --> sharedlib2 --> libstdc++.sl --> libc.sl
I assume that the initializer function must be uniquely named between
the two libraries. What controls that? Does that also imply I can
rebuild sharedlib2 without relinking myprog?
TIA!
Regards,
M.
--
Mark Klein DIS International, Ltd.
http://www.dis.com 415-892-8400
PGP Public Key Available