Gnu assembler question for ARM

Dave Korn dave.korn@artimi.com
Sun May 6 22:58:00 GMT 2007


On 06 May 2007 23:51, Ciaccia wrote:

> Could you please give me some examples on how to use the .struct
> expression? Online there is not much information, the only useful file I
> could find was the "struct.s" fine in the gas testsuite.  
> 
> I tried to convert this C-struct
> 
> struct test {
>     int x;
>     char y;
>     int z;
> };
> 
> to assember with the following:
> 
>     .struct 0
> x:    .int    0
> y:    .byte    0
> z:    .int    0
> 
> But the offset for the z field is 5 instead of the expected 8. How to fix
> that? 
> I would really be happy to see an example of struct in action...

  The compiler alway aligns the members of structs, so you would really need
to precede each member with alignment directive:

	.struct  0

	.balign  4 
 x:    .int     0

	.balign  1
 y:    .byte    0

	.balign  4
 z:    .int     0

except if the struct has __attribute__ ((packed)), then there is no padding.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....



More information about the Binutils mailing list