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.6.040913.0 Static objects and constructors of any kind must be by their very nature always be considered "used" - unless the compiler can determine for a fact that the code initializing them has no side-effects. It's not the same as a simple integral global variable which is never referenced. The same would be true of a basic global variable in the main image initialized by a function call of some sort (C++, not C, of course). But even if what you said were the case, even under MacOS X, the static constructors run for *all* static objects in a library if even one symbol in that library is referenced. So the behavior is not consistent with your reasoning. So the Mach-O lazy symbol evaluation is coming into play here. I tried setting DYLD_BIND_AT_LAUNCH - but it didn't help. But the bottom line is that there needs to be some way of injecting a custom preamble into third party code. If not this technique that works on other Unixes, then what is the right sauce for Mach? -Brian
From: Markus Hitter <mah@jump-ing.de> Date: Tue, 1 Mar 2005 10:20:39 +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 01.03.2005 um 00:58 schrieb Brian Dantes:
If this were a static library, you certainly would expect any static constructors to run that were defined in that library.
(No). Constructors should be run when an object is created, if it is "used".
With your understanding, behaviour of a program would be different depending on wether unused code is stripped or not.
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