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: Gnu assembler question for ARM


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....


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