From 5ce1fa415ee434dae9c4c3cc18fb20732b814b51 Mon Sep 17 00:00:00 2001
From: rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 17 Aug 2001 18:28:06 +0000
Subject: [PATCH]         * 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44966 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog  |  9 ++++++++-
 gcc/crtstuff.c | 36 +++++++++++++++++++++++-------------
 gcc/varasm.c   |  9 ++++++---
 3 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e5fb0e23775b..00b746c61b20 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,11 @@
-2001-08-10  Andrew Haley  <aph@cambridge.redhat.com>
+2001-08-17  Richard Henderson  <rth@redhat.com>
+
+	* 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.
+
+2001-08-17  Andrew Haley  <aph@cambridge.redhat.com>
 
 	* config/sh/sh.md: Add modes to unspecs in first insn to match
 	those in the second.
diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c
index 402ab0114e09..067639bc656b 100644
--- a/gcc/crtstuff.c
+++ b/gcc/crtstuff.c
@@ -369,12 +369,12 @@ CTOR_LIST_BEGIN;
 static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
 asm (CTORS_SECTION_ASM_OP);
 STATIC func_ptr __CTOR_LIST__[1]
-  __attribute__ ((__unused__))
+  __attribute__ ((__unused__, aligned(sizeof(func_ptr))))
   = { (func_ptr) (-1) };
 
 #else
 STATIC func_ptr __CTOR_LIST__[1]
-  __attribute__ ((__unused__, section(".ctors")))
+  __attribute__ ((__unused__, section(".ctors"), aligned(sizeof(func_ptr))))
   = { (func_ptr) (-1) };
 
 #endif
@@ -383,10 +383,12 @@ STATIC func_ptr __CTOR_LIST__[1]
 DTOR_LIST_BEGIN;
 #elif defined(DTORS_SECTION_ASM_OP)
 asm (DTORS_SECTION_ASM_OP);
-STATIC func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) };
+STATIC func_ptr __DTOR_LIST__[1]
+  __attribute__ ((aligned(sizeof(func_ptr))))
+  = { (func_ptr) (-1) };
 #else
 STATIC func_ptr __DTOR_LIST__[1]
-  __attribute__((section(".dtors")))
+  __attribute__((section(".dtors"), aligned(sizeof(func_ptr))))
   = { (func_ptr) (-1) };
 #endif
 
@@ -397,7 +399,7 @@ STATIC func_ptr __DTOR_LIST__[1]
 STATIC
 #endif
 char __EH_FRAME_BEGIN__[]
-     __attribute__((section(EH_FRAME_SECTION_NAME)))
+     __attribute__((section(EH_FRAME_SECTION_NAME), aligned(4)))
      = { };
 #endif /* EH_FRAME_SECTION_NAME */
 
@@ -405,7 +407,8 @@ char __EH_FRAME_BEGIN__[]
 /* 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)))
+STATIC void *__JCR_LIST__[]
+  __attribute__ ((unused, section(JCR_SECTION_NAME), aligned(sizeof(func_ptr))))
   = { 0 };
 #endif /* JCR_SECTION_NAME */
 
@@ -533,11 +536,13 @@ CTOR_LIST_END;
    __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 };
+STATIC func_ptr __CTOR_END__[1]
+  __attribute__((aligned(sizeof(func_ptr))))
+  = { (func_ptr) 0 };
 
 #else
 STATIC func_ptr __CTOR_END__[1]
-  __attribute__((section(".ctors")))
+  __attribute__((section(".ctors"), aligned(sizeof(func_ptr))))
   = { (func_ptr) 0 };
 #endif
 
@@ -545,11 +550,12 @@ STATIC func_ptr __CTOR_END__[1]
 DTOR_LIST_END;
 #elif defined(DTORS_SECTION_ASM_OP)
 asm (DTORS_SECTION_ASM_OP);
-STATIC func_ptr __DTOR_END__[1] __attribute__ ((unused))
+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")))
+  __attribute__((unused, section(".dtors"), aligned(sizeof(func_ptr))))
   = { (func_ptr) 0 };
 #endif
 
@@ -557,7 +563,8 @@ STATIC func_ptr __DTOR_END__[1]
 /* 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)))
+     __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME),
+		     aligned(4)))
      = { 0 };
 #endif /* EH_FRAME_SECTION */
 
@@ -566,7 +573,9 @@ STATIC int __FRAME_END__[]
    so we can register them properly.  */
 
 STATIC void *__JCR_END__[1] 
-     __attribute__ ((unused, section(JCR_SECTION_NAME))) = { 0 };
+   __attribute__ ((unused, section(JCR_SECTION_NAME),
+		   aligned(sizeof(func_ptr))))
+   = { 0 };
 #endif /* JCR_SECTION_NAME */
 
 #endif /* defined(CRT_END) */
@@ -627,7 +636,8 @@ __dereg_frame_dtor (void)
 
 /* Terminate the frame section with a final zero.  */
 STATIC int __FRAME_END__[]
-     __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME)))
+     __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME),
+		     aligned(4)))
      = { 0 };
 #endif /* CRT_END */
 
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 6cb2fb8ddfb6..8b752dc1e9bd 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1474,13 +1474,16 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
     }
 
   /* 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);
+      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);
+      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.  */
-- 
GitLab