I need to understand some internals of data structures by generating the assembly code for functions and global, local structures, variables.
From this link:
http://axelio.wordpress.com/2007/07/24/be-careful-with-packed-structures/
I can see that the structure members are shown the allocated size explicitly in assembly code.
_my:
.byte 10 <--- c
.long 20 <--- i
.byte 30 <--- s.c
.space 3 <--- 3 bytes of alignment
.long 40 <--- s.i
How to generate this kind of assembly.
Using
# gcc -S file.c
didnot generate the above output for structures.
It does.
Compile with
gcc -S strasm.cAnd in resulting
strasm.syou will see:All you need is explicitly initialized object.