This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Global objects in shared libraries
- To: gcc at gcc dot gnu dot org
- Subject: Global objects in shared libraries
- From: Martin Reinecke <martin at MPA-Garching dot MPG dot DE>
- Date: Thu, 25 Nov 1999 14:32:07 +0100
- Organization: Max-Planck-Institut fuer Astrophysik
Hi,
I'm working on a small utility which allows the dynamic loading of classes in
shared libraries at runtime (http://www.mpa-garching.mpg.de/~martin/dlc/dlc-241199.tar.gz)
without the need of calling dlsym().
This utility relies on the fact that the constructors of global objects in the shared libraries
are called when the library is opened by dlopen(). This worked fine (under Linux-ELF) with
gcc-2.95; but the current CVS version doesn't seem to call the constructors, so that my
code breaks.
I'm not sure if this can be called a bug in gcc (the C++ standard doesn't say anything about
shared libraries, AFAIK), so I'd like to hear the opinion of the experts: should global
objects in shared libraries be constructed at load time and destroyed at unload time, or
is the behaviour undefined?
If you think the behaviour of the current CVS version is wrong, I will create a full bug report.
Thanks in advance,
Martin