This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [arm] Use .init_array for static constructors.
- From: Richard Henderson <rth at redhat dot com>
- To: Paul Brook <paul at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Mark Mitchell <mark at codesourcery dot com>, Richard Earnshaw <rearnsha at arm dot com>
- Date: Sat, 25 Sep 2004 15:21:59 -0700
- Subject: Re: [arm] Use .init_array for static constructors.
- References: <200409240047.20463.paul@codesourcery.com>
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~