|
From: Tom H. <to...@co...> - 2008-04-06 07:32:55
|
In message <e2e...@ma...>
"Bart Van Assche" <bar...@gm...> wrote:
> The comments in coregrind/m_replacemalloc/vg_replace_malloc.c suggest
> that the init() function in that file is called just after the shared
> library this file is linked with has been loaded. This is not correct:
> __attribute__((constructor)) only makes sense in object files that are
> linked into an executable, not in object files that are linked into a
> shared library. See also the gcc manual about this attribute
> (http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html#Function-Attributes).
That description is incorrect, or at least misleading.
It never actually says that constructors don't work in shared
objects (they do) it just implies that by saying that they are
run before main is entered.
That is only true for constructors in the main executable and
any shared objects it is linked against however - constructors
in a shared object that it dlopened will be run when the object
is first opened.
In short that attribute is doing something, and shouldn't be
removed.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|