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

Christophe Lyon christophe.lyon@st.com
Thu Aug 29 15:39:00 GMT 2019


On 12/07/2019 08:06, Richard Sandiford wrote:
> Christophe Lyon <christophe.lyon@st.com> writes:
>> 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.
>>
>> 2019-XX-XX  Christophe Lyon  <christophe.lyon@st.com>
>> 	Mickaël Guêné <mickael.guene@st.com>
>>
>> 	* libgcc/crtstuff.c: Add support for FDPIC.
>>
>> Change-Id: I0bc4b1232fbf3c69068fb23a1b9cafc895d141b1
>>
>> diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c
>> index 4927a9f..159b461 100644
>> --- a/libgcc/crtstuff.c
>> +++ b/libgcc/crtstuff.c
>> @@ -429,9 +429,18 @@ __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"
>> +    "   .align 2\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)
> 
> It'd be good to avoid hard-coding the pointer size.  Would it work to do:
> 
> __asm__("\t.equ\.t__do_global_dtors_aux_alias, __do_global_dtors_aux\n");
> extern char __do_global_dtors_aux_alias;
> static void *__do_global_dtors_aux_fini_array_entry[]
>     __attribute__ ((__used__, section(".fini_array"), aligned(sizeof(void *))))
>     = { &__do_global_dtors_aux_alias };
> 
> ?  Similarly for the init_array.
> 
OK, done.

> AFAICT this and 02/21 are the only patches that aren't Arm-specific,
> is that right?
> 
> Thanks,
> Richard
> .
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-ARM-FDPIC-Fix-__do_global_dtors_aux-and-frame_dummy-.patch
Type: text/x-patch
Size: 2532 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190829/720d9348/attachment.bin>


More information about the Gcc-patches mailing list