This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [arm] Use .init_array for static constructors.


On Fri, Sep 24, 2004 at 12:47:20AM +0100, Paul Brook wrote:
> +#ifdef __ARM_EABI__
> +#define CTORS_SECTION_FOR_TARGET "\t.section\t.init_array,\"aw\",%init_array"
> +#else
> +#define CTORS_SECTION_FOR_TARGET "\t.section\t.ctors,\"aw\",%progbits"
> +#endif
> +
> +#define CTOR_LIST_END \
> +static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { }; \
> +asm (CTORS_SECTION_FOR_TARGET); \
> +STATIC func_ptr __CTOR_END__[1] \
> +  __attribute__((aligned(sizeof(func_ptr)))) \
> +  = { (func_ptr) 0 };
> +#define CTOR_LIST_BEGIN \
> +static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { }; \
> +asm (CTORS_SECTION_FOR_TARGET); \
> +STATIC func_ptr __CTOR_LIST__[1] \
> +  __attribute__ ((__unused__, aligned(sizeof(func_ptr)))) \
> +  = { (func_ptr) (-1) };

I don't think this change is right.  In particular, it is Someone Else's
Job to run .init and .init_array.  Usually, ld.so, but you may not have
one of those, in which case whoever runs .init now.

C.f. ia64 crtbegin.asm, in which .init_array is used, but to invoke
__do_global_ctors_aux, and not to run the individual constructors.

You *could* use .init_array instead of .ctors, but that's a different
and more extensive change than what you're presenting here.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]