This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] mips: Allow larger values for __aligned__


On Wed, Sep 20, 2006 at 10:44:56PM -0700, Ian Lance Taylor wrote:
> I think the question here is why MAX_OFILE_ALIGNMENT is defined to be
> 32768 * 8 in config/elfos.h.  ELF supports section alignment up to
> 0x80000000 * 8 (actually 64-bit ELF supports alignment up to
> 0x8000000000000000 * 8).  It appears that the value in elfos.h was
> moved there from svr4.h, and the value in svr4.h was added here:
> 
> Sun Jan  7 16:56:56 1996  Michael Meissner  <meissner@wombat.gnu.ai.mit.edu>
> 
> 	* {svr4,mips/elf{,64}}.h (MAX_OFILE_ALIGNMENT):  Define as 32768*8.
> 
> I suspect the right patch is going to be putting something like this
> in elfos.h:
> 
> #ifdef HOST_BITS_PER_WIDEST_INT >= 64
> #define MAX_OFILE_ALIGNMENT (((unsigned HOST_WIDEST_INT) 1 << 31) * 8)
> #else
> #define MAX_OFILE_ALIGNMENT (((unsigned HOST_WIDEST_INT) 1 << 28) * 8)
> #endif
> 
> with appropriate comments of course.  I think that would be both
> correct and would solve your particular problem.
> 
> (If we had some way of saying that we were using 64-bit ELF, then of
> course we could make it even larger.)

Ian, thanks for your input on this particular issue. Would you consider
the following patch?

Tested without regression on i686-pc-linux-gnu.

Cheers,
Carlos.
-- 
Carlos O'Donell
CodeSourcery
carlos@codesourcery.com
(650) 331-3385 x716

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 117317)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2006-09-29  Carlos O'Donell  <carlos@codesourcery.com>
+
+	* config/elfos.h (MAX_OFILE_ALIGNMENT): Default to largest
+	alignment supported by 32-bit ELF.
+
 2006-09-28  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* builtins.c (expand_builtin_setjmp): Delete.
Index: gcc/config/elfos.h
===================================================================
--- gcc/config/elfos.h	(revision 117317)
+++ gcc/config/elfos.h	(working copy)
@@ -40,12 +40,17 @@ Boston, MA 02110-1301, USA.  */
 #undef  USER_LABEL_PREFIX
 #define USER_LABEL_PREFIX ""
 
-/* Biggest alignment supported by the object file format of this
-   machine.  Use this macro to limit the alignment which can be
-   specified using the `__attribute__ ((aligned (N)))' construct.  If
-   not defined, the default value is `BIGGEST_ALIGNMENT'.  */
-#ifndef MAX_OFILE_ALIGNMENT
-#define MAX_OFILE_ALIGNMENT (32768 * 8)
+/* The biggest alignment supported by ELF. 32-bit ELF supports 
+   section alignment up to (0x80000000 * 8), while 64-bit ELF
+   supports (0x8000000000000000 * 8). If this macro is not
+   defined, the default is the largest alignment supported by
+   32-bit ELF. Use this macro to limit the alignment which can 
+   be specified using the `__attribute__ ((aligned (N)))' 
+   construct.  */
+#if (HOST_BITS_PER_WIDEST_INT >= 64)
+#define MAX_OFILE_ALIGNMENT (((unsigned HOST_WIDEST_INT) 1 << 31) * 8)
+#else
+#define MAX_OFILE_ALIGNMENT (((unsigned HOST_WIDEST_INT) 1 << 28) * 8)
 #endif
 
 /* Use periods rather than dollar signs in special g++ assembler names.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]