[ARM/FDPIC v3 05/21] [ARM] FDPIC: Fix __do_global_dtors_aux and frame_dummy generation

Richard Earnshaw (lists) Richard.Earnshaw@arm.com
Fri Oct 12 11:29:00 GMT 2018


On 11/10/18 14:34, Christophe Lyon wrote:
> In FDPIC, we need to make sure __do_global_dtors_aux and frame_dummy
> are referenced by their address, not by pointers to the function
> descriptors.
> 
> 2018-XX-XX  Christophe Lyon  <christophe.lyon@st.com>
> 	Mickaël Guêné <mickael.guene@st.com>
> 
> 	* libgcc/crtstuff.c: Add support for FDPIC.
> 

This looks a little bit hacky; and since it's to a generic file I'd like
a second opinion from the libgcc maintainer.

At the very least, don't you need an alignment directive before the entries?

R.

> Change-Id: Iff3aec3815e8ebd87276c0107752f00908a22100
> 
> diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c
> index d81c527..ad40719 100644
> --- a/libgcc/crtstuff.c
> +++ b/libgcc/crtstuff.c
> @@ -429,9 +429,17 @@ __do_global_dtors_aux (void)
>  #ifdef FINI_SECTION_ASM_OP
>  CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux)
>  #elif defined (FINI_ARRAY_SECTION_ASM_OP)
> +#if defined(__FDPIC__)
> +__asm__(
> +    "   .section .fini_array\n"
> +    "   .word __do_global_dtors_aux\n"
> +);
> +asm (TEXT_SECTION_ASM_OP);
> +#else /* defined(__FDPIC__) */
>  static func_ptr __do_global_dtors_aux_fini_array_entry[]
>    __attribute__ ((__used__, section(".fini_array"), aligned(sizeof(func_ptr))))
>    = { __do_global_dtors_aux };
> +#endif /* defined(__FDPIC__) */
>  #else /* !FINI_SECTION_ASM_OP && !FINI_ARRAY_SECTION_ASM_OP */
>  static void __attribute__((used))
>  __do_global_dtors_aux_1 (void)
> @@ -473,9 +481,17 @@ frame_dummy (void)
>  #ifdef __LIBGCC_INIT_SECTION_ASM_OP__
>  CRT_CALL_STATIC_FUNCTION (__LIBGCC_INIT_SECTION_ASM_OP__, frame_dummy)
>  #else /* defined(__LIBGCC_INIT_SECTION_ASM_OP__) */
> +#if defined(__FDPIC__)
> +__asm__(
> +    "   .section .init_array\n"
> +    "   .word frame_dummy\n"
> +);
> +asm (TEXT_SECTION_ASM_OP);
> +#else /* defined(__FDPIC__) */
>  static func_ptr __frame_dummy_init_array_entry[]
>    __attribute__ ((__used__, section(".init_array"), aligned(sizeof(func_ptr))))
>    = { frame_dummy };
> +#endif /* defined(__FDPIC__) */
>  #endif /* !defined(__LIBGCC_INIT_SECTION_ASM_OP__) */
>  #endif /* USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY */
>  
> 



More information about the Gcc-patches mailing list