This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
dlopen() does not call static constructors on HP-UX
- From: Harri Pasanen <harri at nerim dot net>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 6 Dec 2002 08:06:14 +0100
- Subject: dlopen() does not call static constructors on HP-UX
- Reply-to: harri dot pasanen at trema dot com
I suppose this is an old can of worms, but after multiple searches
through the mailing list I'm still not enlightened in my specific
problem, so here I go.
Looks like on HP-UX 11.00, using g++ 3.2, when I link against a shared
library containing static objects, their constructors are called. But
if I do dlopen(), or shl_load() for the shared library, the static
objects are not initialized.
Now seems like a HP-UX specific bug, and searching gnats it indeed looks
like the same one
as PR 8360.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8360
Having full control of the dlopen(), which happens in my C++ source, I'm
looking for a way to manually circumvent this bug. Examining my shared
library symbols, looks like there is something called
__static_initialization_and_destruction, which I guess arranges for the
constructors and destructors to be called. Is there a way I can
arrange my code to call this function after I've done the dlopen()?
Regards,
Harri