This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
suppress optional alignment for user variables
- To: gcc-patches at gcc dot gnu dot org
- Subject: suppress optional alignment for user variables
- From: Richard Henderson <rth at redhat dot com>
- Date: Fri, 17 Aug 2001 11:32:10 -0700
Found in the course of trying to fix Irix alignment problems.
The list header and trailer variables from crtstuff want
exactly pointer alignment, as extra alignment adds padding
that corrupts the lists.
It turned out that even adding "aligned" didn't solve the
problem, since we ignored DECL_USER_ALIGN when deciding on
extra alignment in assemble_variable.
r~
* varasm.c (assemble_variable): Don't overalign if DECL_USER_ALIGN.
* crtstuff.c (__CTOR_LIST__, __DTOR_LIST__, __EH_FRAME_BEGIN__,
__JCR_LIST__, __CTOR_END__, __DTOR_END__, __FRAME_END__,__JCR_END__):
Add aligned attribute.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.196
diff -c -p -d -r1.196 varasm.c
*** varasm.c 2001/08/17 13:50:15 1.196
--- varasm.c 2001/08/17 18:18:38
*************** assemble_variable (decl, top_level, at_e
*** 1474,1486 ****
}
/* On some machines, it is good to increase alignment sometimes. */
#ifdef DATA_ALIGNMENT
! align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
#endif
#ifdef CONSTANT_ALIGNMENT
! if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
! align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
#endif
/* Reset the alignment in case we have made it tighter, so we can benefit
from it in get_pointer_alignment. */
--- 1478,1493 ----
}
/* On some machines, it is good to increase alignment sometimes. */
+ if (! DECL_USER_ALIGN (decl))
+ {
#ifdef DATA_ALIGNMENT
! align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
#endif
#ifdef CONSTANT_ALIGNMENT
! if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
! align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
#endif
+ }
/* Reset the alignment in case we have made it tighter, so we can benefit
from it in get_pointer_alignment. */
Index: crtstuff.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/crtstuff.c,v
retrieving revision 1.43
diff -c -p -d -r1.43 crtstuff.c
*** crtstuff.c 2001/08/09 22:33:17 1.43
--- crtstuff.c 2001/08/17 18:18:38
*************** CTOR_LIST_BEGIN;
*** 369,380 ****
static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
asm (CTORS_SECTION_ASM_OP);
STATIC func_ptr __CTOR_LIST__[1]
! __attribute__ ((__unused__))
= { (func_ptr) (-1) };
#else
STATIC func_ptr __CTOR_LIST__[1]
! __attribute__ ((__unused__, section(".ctors")))
= { (func_ptr) (-1) };
#endif
--- 369,380 ----
static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
asm (CTORS_SECTION_ASM_OP);
STATIC func_ptr __CTOR_LIST__[1]
! __attribute__ ((__unused__, aligned(sizeof(func_ptr))))
= { (func_ptr) (-1) };
#else
STATIC func_ptr __CTOR_LIST__[1]
! __attribute__ ((__unused__, section(".ctors"), aligned(sizeof(func_ptr))))
= { (func_ptr) (-1) };
#endif
*************** STATIC func_ptr __CTOR_LIST__[1]
*** 383,392 ****
DTOR_LIST_BEGIN;
#elif defined(DTORS_SECTION_ASM_OP)
asm (DTORS_SECTION_ASM_OP);
! STATIC func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) };
#else
STATIC func_ptr __DTOR_LIST__[1]
! __attribute__((section(".dtors")))
= { (func_ptr) (-1) };
#endif
--- 383,394 ----
DTOR_LIST_BEGIN;
#elif defined(DTORS_SECTION_ASM_OP)
asm (DTORS_SECTION_ASM_OP);
! STATIC func_ptr __DTOR_LIST__[1]
! __attribute__ ((aligned(sizeof(func_ptr))))
! = { (func_ptr) (-1) };
#else
STATIC func_ptr __DTOR_LIST__[1]
! __attribute__((section(".dtors"), aligned(sizeof(func_ptr))))
= { (func_ptr) (-1) };
#endif
*************** STATIC func_ptr __DTOR_LIST__[1]
*** 397,403 ****
STATIC
#endif
char __EH_FRAME_BEGIN__[]
! __attribute__((section(EH_FRAME_SECTION_NAME)))
= { };
#endif /* EH_FRAME_SECTION_NAME */
--- 399,405 ----
STATIC
#endif
char __EH_FRAME_BEGIN__[]
! __attribute__((section(EH_FRAME_SECTION_NAME), aligned(4)))
= { };
#endif /* EH_FRAME_SECTION_NAME */
*************** char __EH_FRAME_BEGIN__[]
*** 405,411 ****
/* Stick a label at the beginning of the java class registration info
so we can register them properly. */
! STATIC void *__JCR_LIST__[] __attribute__ ((unused, section(JCR_SECTION_NAME)))
= { 0 };
#endif /* JCR_SECTION_NAME */
--- 407,414 ----
/* Stick a label at the beginning of the java class registration info
so we can register them properly. */
! STATIC void *__JCR_LIST__[]
! __attribute__ ((unused, section(JCR_SECTION_NAME), aligned(sizeof(func_ptr))))
= { 0 };
#endif /* JCR_SECTION_NAME */
*************** CTOR_LIST_END;
*** 533,543 ****
__CTOR_LIST__ does not undo our behind-the-back change to .ctors. */
static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
asm (CTORS_SECTION_ASM_OP);
! STATIC func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
#else
STATIC func_ptr __CTOR_END__[1]
! __attribute__((section(".ctors")))
= { (func_ptr) 0 };
#endif
--- 536,548 ----
__CTOR_LIST__ does not undo our behind-the-back change to .ctors. */
static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
asm (CTORS_SECTION_ASM_OP);
! STATIC func_ptr __CTOR_END__[1]
! __attribute__((aligned(sizeof(func_ptr))))
! = { (func_ptr) 0 };
#else
STATIC func_ptr __CTOR_END__[1]
! __attribute__((section(".ctors"), aligned(sizeof(func_ptr))))
= { (func_ptr) 0 };
#endif
*************** STATIC func_ptr __CTOR_END__[1]
*** 545,555 ****
DTOR_LIST_END;
#elif defined(DTORS_SECTION_ASM_OP)
asm (DTORS_SECTION_ASM_OP);
! STATIC func_ptr __DTOR_END__[1] __attribute__ ((unused))
= { (func_ptr) 0 };
#else
STATIC func_ptr __DTOR_END__[1]
! __attribute__((unused, section(".dtors")))
= { (func_ptr) 0 };
#endif
--- 550,561 ----
DTOR_LIST_END;
#elif defined(DTORS_SECTION_ASM_OP)
asm (DTORS_SECTION_ASM_OP);
! STATIC func_ptr __DTOR_END__[1]
! __attribute__ ((unused, aligned(sizeof(func_ptr))))
= { (func_ptr) 0 };
#else
STATIC func_ptr __DTOR_END__[1]
! __attribute__((unused, section(".dtors"), aligned(sizeof(func_ptr))))
= { (func_ptr) 0 };
#endif
*************** STATIC func_ptr __DTOR_END__[1]
*** 557,563 ****
/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
this would be the 'length' field in a real FDE. */
STATIC int __FRAME_END__[]
! __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME)))
= { 0 };
#endif /* EH_FRAME_SECTION */
--- 563,570 ----
/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
this would be the 'length' field in a real FDE. */
STATIC int __FRAME_END__[]
! __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME),
! aligned(4)))
= { 0 };
#endif /* EH_FRAME_SECTION */
*************** STATIC int __FRAME_END__[]
*** 566,572 ****
so we can register them properly. */
STATIC void *__JCR_END__[1]
! __attribute__ ((unused, section(JCR_SECTION_NAME))) = { 0 };
#endif /* JCR_SECTION_NAME */
#endif /* defined(CRT_END) */
--- 573,581 ----
so we can register them properly. */
STATIC void *__JCR_END__[1]
! __attribute__ ((unused, section(JCR_SECTION_NAME),
! aligned(sizeof(func_ptr))))
! = { 0 };
#endif /* JCR_SECTION_NAME */
#endif /* defined(CRT_END) */
*************** __dereg_frame_dtor (void)
*** 627,633 ****
/* Terminate the frame section with a final zero. */
STATIC int __FRAME_END__[]
! __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME)))
= { 0 };
#endif /* CRT_END */
--- 636,643 ----
/* Terminate the frame section with a final zero. */
STATIC int __FRAME_END__[]
! __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME),
! aligned(4)))
= { 0 };
#endif /* CRT_END */