gcc -O2 -S -c b.c gives the answer but if we declare a structure say
struct test_t {
int a;
char b;
int c;
};
main()
{
struct test_t test= { 13,30, 40};
}
Now in command prompt if we type gcc -O2 -S -c b.c will give output in b.s file as
30 .align 4
31 .LC0:
32 0000 0D000000 .long 13
33 0004 1E .byte 30
34 0005 000000 .zero 3 ( structure padding of 3 Bytes)
35 0008 28000000 .long 40
with the help of gcc -S command we can see the padding done by compiler but if we don't
declare the structure say:
struct test_t {
int a;
char b;
int c;
};
main()
{
struct test_t test;/*= { 13,30, 40};*/
}
here the output is:
.LC0:
31 0000 256400 .string "%d"
32 .text
33 .align 4
35 .globl main
37 main:..
Here i can't see the structure, only if i assign the structure with a value then only "gcc
-S" is effective. Is their any other way to find padding done by structure.