Re: dlopen() on 10.3 and static initializers
Re: dlopen() on 10.3 and static initializers
- Subject: Re: dlopen() on 10.3 and static initializers
- From: "Peter O'Gorman" <email@hidden>
- Date: Thu, 06 Apr 2006 11:27:22 +0900
On Wed, 2006-04-05 at 19:12 -0700, David Litwin wrote:
> I’m in the process of qualifying my app on 10.3.
>
>
> My app uses dlopen() to load some libraries, which contain a number of
> static objects that register themselves to the app in their
> constructors.
>
> While this works fine in 10.4, on 10.3 these registrations never
> occur. There are no errors loading the libraries, but it seems that
> no C++ static object constructors are being called.
>
Are you dlopening dynamic shared libraries or bundles? On 10.3 static
constructors were more likely to be called for MH_BUNDLE than MH_DYLIB.
If they are dynamic shared libraries and you can not change that, are
they two level namespace or flat namespace? (hint otool -hv).
If twolevel, try adding this to each library:
void _init(void);
void _init() {;}
And ensure that you link your libraries with -single_module.
dlcompat's dlopen will look up and call _init for each library it
explicitly dlopens, and if the library is linked single_module, all the
module's static initializers will be called at that time.
On 10.4 the dynamic linker was rewritten to work better and dlopen()
became part of the dynamic linker, not an external function that used
dyld.
Hope this helps,
Peter
Attachment:
signature.asc
Description: This is a digitally signed message part
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden