Patchwork Fix ctrstuff.c with init_array support

login
register
mail settings
Submitter Andrew Pinski
Date Dec. 6, 2011, 1:42 a.m.
Message ID <CA+=Sn1kupjGi1vq9+hEi8FiFqNNCi1U0xpb3DffAydr3F8Gf9w@mail.gmail.com>
Download mbox | patch
Permalink /patch/129491/
State New
Headers show

Comments

Andrew Pinski - Dec. 6, 2011, 1:42 a.m.
Hi,
  Like the .ctors array, __do_global_dtors_aux_fini_array_entry and
__frame_dummy_init_array_entry arrays need a specific alignment.  This
patch fixes those two arrays.  This patch fixes the bootstrap on
mips64-linux-gnu.

Bootstrapped on mips64-linux-gnu.
Bootstrapped and tested on x86-linux-gnu with no regressions.

Thanks,
Andrew Pinski

libgcc/ChangeLog:
* crtstuff.c (__do_global_dtors_aux_fini_array_entry): Align to the
size of func_ptr.
(__frame_dummy_init_array_entry): Likewise.
eirc.lew@gmail.com - Dec. 6, 2011, 2:10 a.m.
Hi, All

	I am freshman in the GCC community. If I want to use gcc to get the dependence analysis information, how should I get it? And how to debug gcc middle end ?


Thanks!

Eric
H.J. Lu - Dec. 6, 2011, 3:38 a.m.
On Mon, Dec 5, 2011 at 5:42 PM, Andrew Pinski
<andrew.pinski@caviumnetworks.com> wrote:
> Hi,
>  Like the .ctors array, __do_global_dtors_aux_fini_array_entry and
> __frame_dummy_init_array_entry arrays need a specific alignment.  This
> patch fixes those two arrays.  This patch fixes the bootstrap on
> mips64-linux-gnu.
>
> Bootstrapped on mips64-linux-gnu.
> Bootstrapped and tested on x86-linux-gnu with no regressions.
>
> Thanks,
> Andrew Pinski
>
> libgcc/ChangeLog:
> * crtstuff.c (__do_global_dtors_aux_fini_array_entry): Align to the
> size of func_ptr.
> (__frame_dummy_init_array_entry): Likewise.

.eh_frame section has similar problem:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27576
David Daney - Dec. 6, 2011, 5:27 p.m.
On 12/05/2011 07:38 PM, H.J. Lu wrote:
> On Mon, Dec 5, 2011 at 5:42 PM, Andrew Pinski
> <andrew.pinski@caviumnetworks.com>  wrote:
>> Hi,
>>   Like the .ctors array, __do_global_dtors_aux_fini_array_entry and
>> __frame_dummy_init_array_entry arrays need a specific alignment.  This
>> patch fixes those two arrays.  This patch fixes the bootstrap on
>> mips64-linux-gnu.
>>
>> Bootstrapped on mips64-linux-gnu.
>> Bootstrapped and tested on x86-linux-gnu with no regressions.
>>
>> Thanks,
>> Andrew Pinski
>>
>> libgcc/ChangeLog:
>> * crtstuff.c (__do_global_dtors_aux_fini_array_entry): Align to the
>> size of func_ptr.
>> (__frame_dummy_init_array_entry): Likewise.
>
> .eh_frame section has similar problem:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27576
>

But you have known about that for over five years and x86_64 still seems 
to work, so it must not really be hurting anything.

Andrew's patch fixes bad code in libgcc which causes bootstrap breakage 
on MIPS when used with recent binutils releases.  So I would propose 
that it be considered as-is, without changing the .eh_frame bits.

If someone wants to change the .eh_frame things in crtstuff.c, they are 
free to do that, but it shouldn't really be gating factor for this patch.

David Daney
Richard Henderson - Dec. 6, 2011, 9:08 p.m.
On 12/05/2011 05:42 PM, Andrew Pinski wrote:
> libgcc/ChangeLog:
> * crtstuff.c (__do_global_dtors_aux_fini_array_entry): Align to the
> size of func_ptr.
> (__frame_dummy_init_array_entry): Likewise.

Ok.


r~

Patch

Index: crtstuff.c
===================================================================
--- crtstuff.c	(revision 181901)
+++ crtstuff.c	(working copy)
@@ -412,7 +412,7 @@ 
 CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux)
 #elif defined (FINI_ARRAY_SECTION_ASM_OP)
 static func_ptr __do_global_dtors_aux_fini_array_entry[]
-  __attribute__ ((__used__, section(".fini_array")))
+  __attribute__ ((__used__, section(".fini_array"), aligned(sizeof(func_ptr))))
   = { __do_global_dtors_aux };
 #else /* !FINI_SECTION_ASM_OP && !FINI_ARRAY_SECTION_ASM_OP */
 static void __attribute__((used))
@@ -466,7 +466,7 @@ 
 CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, frame_dummy)
 #else /* defined(INIT_SECTION_ASM_OP) */
 static func_ptr __frame_dummy_init_array_entry[]
-  __attribute__ ((__used__, section(".init_array")))
+  __attribute__ ((__used__, section(".init_array"), aligned(sizeof(func_ptr))))
   = { frame_dummy };
 #endif /* !defined(INIT_SECTION_ASM_OP) */
 #endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME || USE_TM_CLONE_REGISTRY */