This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch] coff: fix alignment issues when building on ARM
On Tue, 2006-12-05 at 07:56 -0800, H. J. Lu wrote:
> On Tue, Dec 05, 2006 at 03:52:19PM +0000, Nick Clifton wrote:
> > Hi Michael,
> >
> > >The issue is the alignment/padding added on ARM, such that the effective
> > >size
> > >(as reported by sizeof) is 2 bytes larger than the #define'd sizes.
> >
> > Is it possible to provide a test case that demonstrates this please ?
> >
> > >This causes
> > >invalid coff files to be generated by gas. The attached patch fixed all
> > >problems
> > >while building gcc packages for the h8300-hitachi-coff target.
> >
> > Built by what compiler ? On what host machine ?
> >
> > >--- binutils-h8300-hms-2.16.1.orig/include/coff/external.h
> > >+++ binutils-h8300-hms-2.16.1/include/coff/external.h
> > >@@ -50,7 +50,7 @@
> > > 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;
> >
>
> All fields are char []. Why is __attribute__((packed)) needed?
Because the C standard says that structures can have alignment
requirements beyond the alignment requirements of their components.
This is true in older ARM ABIs (as used in the old arm-linux ABI). On
those platforms structures are aligned to a word boundary and must,
therefore also be rounded to a multiple of 32 bits in size.
R.