Newbie: arm-elf-gcc generated asm question

Started by Ken Barlow May 28, 2004
Ken Barlow wrote:
>>>Is there a way of forcing all alignment onto four byte boundaries? I've >>>looked through the GCC and LD docs and can find switches for other >>>targets, but not the ARM. >> >>Compiler does this automatically. If you, say, have the structure >> >>struct { >> uint8_t one; >> uint32_t two; >>} foo; >> >>then foo.two will always be word aligned. >> >>What are your trying to do? If you would post a snippet of your data >>structure it might be easier to help. >> > > > Hi again, > > The structure is like this: > > struct { > uint8 aByte; > uint8 aByteArray[ 64 ]; > } foo; > > Hence my problem - the aByteArray is used as a generic buffer that can hold > anything. I was putting 32bit words into it, and as a byte array there is > no way of the compiler knowing that I wanted it 32bit aligned - a bit silly > now I come to look at it but sometimes it takes somebody else to point out > you are doing something daft ;-) >
I think you can force gcc to align the buffer using: struct { uint8 aByte; uint8 aByteArray[ 64 ] __attribute__ ((aligned (4))); } foo; (untested) -- Arne