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 If this were a static library, you certainly would expect any static constructors to run that were defined in that library. The only difference in that scenario and this one is when the library is loaded into the image. I would hazard to say that Linux (and FreeBSD, HPUX, Solaris and other variants I've directly tried this on) are correct and MacOS X is not. I have submitted this as Radar bug report to Apple as well, so we'll see if anything comes of that. -Brian
From: Markus Hitter <mah@jump-ing.de> Date: Tue, 1 Mar 2005 00:53:11 +0100 To: Brian Dantes <brian@things.org> Cc: <darwin-dev@lists.apple.com> Subject: Re: __attribute__((constructor)) in dylib does not run with DYLD_INSERT_LIBRARIES
Am 28.02.2005 um 12:48 schrieb Brian Dantes:
I'm trying to port an LD_PRELOAD trick from Linux to MacOS X. Given the following two files:
foo.c: ------ [...] void __attribute__((constructor)) my_init() { printf("Constructor called!\n"); }
bar.c: ------ int main() { return 0; }
If I change the code such that bar.c references some symbol in foo.c, and link bar directly with the library, it works as expected[Constructor is called].
I'd say it works both times correctly and Linux wastes cycles with constructing unneeded objects. Loading is not constructing.
my 2 cents
Markus
- - - - - - - - - - - - - - - - - - - Dipl. Ing. Markus Hitter http://www.jump-ing.de/
_______________________________________________ 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