This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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] coff: fix alignment issues when building on ARM


Hi Guys,

OK, What do we think of this revised version of Michael's patch ?

I took the liberty of defining ATTRIBUTE_PACKED in ansidecl.h since it looks like this attribute might be need in more places in the future. I did not add a gcc version test for this since I could not find out when the packed attribute was introduced. (I think that it came in when attributes came in, but I am not sure).

I am currently running regression tests, but I am not expecting any problems.

Cheers
  Nick

include/ChangeLog
2006-12-05  Michael Tautschnig  <tautschn@model.in.tum.de>
	    Nick Clifton  <nickc@redhat.com>

* ansidecl.h (ATTRIBUTE_PACKED): Define.

include/elf/ChangeLog
2006-12-05  Michael Tautschnig  <tautschn@model.in.tum.de>
	    Nick Clifton  <nickc@redhat.com>

* external.h (struct Elf_External_Versym): Use ATTRIBUTE_PACKED.

include/coff/ChangeLog
2006-12-05  Michael Tautschnig  <tautschn@model.in.tum.de>
	    Nick Clifton  <nickc@redhat.com>

	* external.h (struct external_aouthdr): Add ATTRIBUTE_PACKED.
	(struct external_syment): Likewise.
	(union external_auxent): Likewise.
Index: include/ansidecl.h
===================================================================
RCS file: /cvs/src/src/include/ansidecl.h,v
retrieving revision 1.21
diff -c -3 -p -r1.21 ansidecl.h
*** include/ansidecl.h	3 Jul 2005 19:16:16 -0000	1.21
--- include/ansidecl.h	5 Dec 2006 16:17:02 -0000
*************** So instead we use the macro below and te
*** 361,366 ****
--- 361,372 ----
  # endif /* GNUC >= 3.0 */
  #endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
  
+ /* Useful for structures whoes layout must much some binary specification
+    regardless of the alignment and padding qualities of the compiler.  */
+ #ifndef ATTRIBUTE_PACKED
+ # define ATTRIBUTE_PACKED __attribute__ ((packed))
+ #endif
+ 
  /* We use __extension__ in some places to suppress -pedantic warnings
     about GCC extensions.  This feature didn't work properly before
     gcc 2.8.  */
Index: include/coff/external.h
===================================================================
RCS file: /cvs/src/src/include/coff/external.h,v
retrieving revision 1.6
diff -c -3 -p -r1.6 external.h
*** include/coff/external.h	20 Sep 2006 11:35:11 -0000	1.6
--- include/coff/external.h	5 Dec 2006 16:17:02 -0000
*************** typedef struct external_aouthdr
*** 50,56 ****
      char entry[4];	/* entry pt.				*/
      char text_start[4];	/* base of text used for this file 	*/
      char data_start[4];	/* base of data used for this file 	*/
!   }
  AOUTHDR;
  
  #define AOUTHDRSZ 28
--- 50,56 ----
      char entry[4];	/* entry pt.				*/
      char text_start[4];	/* base of text used for this file 	*/
      char data_start[4];	/* base of data used for this file 	*/
!   } ATTRIBUTE_PACKED
  AOUTHDR;
  
  #define AOUTHDRSZ 28
*************** struct external_syment 
*** 164,170 ****
    char e_type[2];
    char e_sclass[1];
    char e_numaux[1];
! };
  
  #define	SYMENT	struct external_syment
  #define	SYMESZ	18	
--- 164,170 ----
    char e_type[2];
    char e_sclass[1];
    char e_numaux[1];
! } ATTRIBUTE_PACKED ;
  
  #define	SYMENT	struct external_syment
  #define	SYMESZ	18	
*************** union external_auxent
*** 256,262 ****
      char x_tvlen[2];	/* length of .tv */
      char x_tvran[2][2];	/* tv range */
    } x_tv;		/* info about .tv section (in auxent of symbol .tv)) */
! };
  
  #define	AUXENT	union external_auxent
  #define	AUXESZ	18
--- 256,262 ----
      char x_tvlen[2];	/* length of .tv */
      char x_tvran[2][2];	/* tv range */
    } x_tv;		/* info about .tv section (in auxent of symbol .tv)) */
! } ATTRIBUTE_PACKED ;
  
  #define	AUXENT	union external_auxent
  #define	AUXESZ	18
Index: include/elf/external.h
===================================================================
RCS file: /cvs/src/src/include/elf/external.h,v
retrieving revision 1.8
diff -c -3 -p -r1.8 external.h
*** include/elf/external.h	17 Jun 2005 13:37:23 -0000	1.8
--- include/elf/external.h	5 Dec 2006 16:17:02 -0000
*************** typedef struct {
*** 245,255 ****
  
  typedef struct {
    unsigned char		vs_vers[2];
! }
! #ifdef __GNUC__
!   __attribute__ ((packed))
! #endif
!   Elf_External_Versym;
  
  /* Structure for syminfo section.  */
  typedef struct
--- 245,251 ----
  
  typedef struct {
    unsigned char		vs_vers[2];
! } ATTRIBUTE_PACKED  Elf_External_Versym;
  
  /* Structure for syminfo section.  */
  typedef struct

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