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]

Support large alignments for commons on arm-elf


Hi Guys,

  Intel have reported that the arm-elf toolchain does not properly
  support the aligned() attribute for large (> 4) alignments on
  commons.  For example, this test fails:

	typedef struct align
	{
	  unsigned long a[1];
	  unsigned long b[1] __attribute__ ((aligned (8)));
	  unsigned long c[1] __attribute__ ((aligned (16)));
	  unsigned long d[1] __attribute__ ((aligned (32)));
	} ALIGN;
	
	ALIGN gs;
	
	int
	main (void)
	{
	  if ((((unsigned int) gs.b) & 0x00000007) || 
	      (((unsigned int) gs.c) & 0x0000000f) ||
	      (((unsigned int) gs.d) & 0x0000001f))
	    {
	      printf ("GLOBAL STRUCT TEST: FAIL\n");
	
	      printf ("%x %x %x\n",
		      (unsigned int) gs.b,
		      (unsigned int) gs.c,
		      (unsigned int) gs.d);
	    }
	  else
	    printf ("GLOBAL STRUCT TEST: PASS\n");
	
	  return 0;
	}

  The problem is that the port is not talking advantage of the
  alignment field support by the assembler .comm directive on ELF
  based ports.

  I am applying the patch below to fix this.

Cheers
        Nick


2001-05-04  Nick Clifton  <nickc@cambridge.redhat.com>

	* config/arm/elf.h (ASM_OUTPUT_ALIGNED_COMMON): Define.

Index: config/arm/elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/elf.h,v
retrieving revision 1.25
diff -p -r1.25 elf.h
*** elf.h	2001/04/16 18:30:36	1.25
--- elf.h	2001/05/04 16:14:03
*************** dtors_section ()						\
*** 367,372 ****
--- 367,383 ----
      }						\
    while (0)
  
+ #ifndef ASM_OUTPUT_ALIGNED_COMMON
+ #define ASM_OUTPUT_ALIGNED_COMMON(STREAM, NAME, SIZE, ALIGN)	\
+   do								\
+     {								\
+       fprintf (STREAM, "\t.comm\t");				\
+       assemble_name (STREAM, NAME);				\
+       fprintf (STREAM, ", %d, %d\n", SIZE, ALIGN);		\
+     }								\
+   while (0)
+ #endif
+ 
  /* For PIC code we need to explicitly specify (PLT) and (GOT) relocs.  */
  #define NEED_PLT_RELOC	flag_pic
  #define NEED_GOT_RELOC	flag_pic


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