Re: __attribute__((constructor)) in dylib does not run with DYLD_INSERT_LIBRARIES
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com User-agent: Microsoft-Entourage/10.1.4.030702.0 Peter, I was hoping you might chime in - but of course I don't like the answer. ;-> There may not be any committee official standard requiring the preload static constructor behavior I want, but I would argue there certainly is a de facto one. I'm trying to think of some hack where I override some weak symbol (does dyld even support those?) that's referenced during the static initialization phase of any program. Is there any way I could hijack _main itself? Of course, my library would need to find its way back to the original entry point (ala something like Jonathan Rentzsch's mach_override) somehow. I haven't tried this - I suspect dyld will either complain at runtime or simply ignore my definition of _main entirely. Is there some undocumented hook in Panther? -Brian
From: "Peter O'Gorman" <peter@pogma.com> Date: Wed, 02 Mar 2005 08:24:36 +0900 To: Andreas Tobler <toa@pop.agri.ch> Cc: darwin-dev@lists.apple.com Subject: Re: __attribute__((constructor)) in dylib does not run with DYLD_INSERT_LIBRARIES
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Andreas Tobler wrote:
| | So if you build libhello with -bundle instead of -dynamiclib it works | somehow. But this is a no go for me.
Why?
| | I'm not aware of any workaround for panther.
Since you are dlopening the library, and panther uses dlcompat, and dlcompat looks for a symbol named "_init", you can use a hack. Inserting a "void _init() { ; }" into the .c file which has your static constructors should cause them to be called. They must appear in the same translation unit as the static constructor, or you must link your library using the - -single_module flag if you want dyld to call them.
If I were you I'd check for different dlopen and dyld behavior on tiger...
There is no workaround for getting libraries inserted with DYLD_INSERT_LIBRARIES to have their static constructors called on panther that I know of. Nor is there any standard that I am aware of which requires this functionality.
Peter - -- Peter O'Gorman - http://www.pogma.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (Darwin)
iQCVAwUBQiT5s7iDAg3OZTLPAQIPogP/b0oAFLodhHCTH3aQHq7o++Za/b61kTm/ TpL8y9mSmtlqdxLKFdLklncZ8foGd+QE0sGDCGs6oJCwRQiYRga6lSFwnAqoe2aE crLnwwKCKfUHlqfF4XZMdut7qu3BgrgBAVklKMCH5HzVx/NWwQmIMEp5x+MWalZK hI4gzVszV3s= =b4cx -----END PGP SIGNATURE----- _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/brian%40things.org
This email sent to brian@things.org
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Brian Dantes