Re: __attribute__((constructor)) in dylib does not run with DYLD_INSERT_LIBRARIES
Re: __attribute__((constructor)) in dylib does not run with DYLD_INSERT_LIBRARIES
- Subject: Re: __attribute__((constructor)) in dylib does not run with DYLD_INSERT_LIBRARIES
- From: Brian Dantes <email@hidden>
- Date: Tue, 01 Mar 2005 02:03:29 -0800
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 <email@hidden>
> Date: Tue, 1 Mar 2005 10:20:39 +0100
> To: Brian Dantes <email@hidden>
> Cc: <email@hidden>
> 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden