dlopen() does not call static constructors on HP-UX
H. J. Lu
hjl@lucon.org
Fri Dec 6 00:44:00 GMT 2002
On Fri, Dec 06, 2002 at 08:06:14AM +0100, Harri Pasanen wrote:
> 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()?
I have an impression that DT_INIT_ARRAY/DT_FINI_ARRAY may work with
HP-UX if ELF is used.
H.J.
More information about the Gcc
mailing list