I have the following code:
int main()
{
volatile char a;
return 0;
}
When I disassemble it with arm-linux-gnueabihf-gcc -o align.txt -O0 -S align.c
I get the following:
push {r7}
sub sp, sp, #12
...
Now, I know the ARM EABI requires the stack to be 8-byte aligned, which would explain gcc allocating some more space than the single byte required by a
. However, I'd have thought it'd allocate 4 bytes to make room for a
and 3 padding bytes.
It looks like it's allocating 4 bytes to make the pushed r7 aligned, then another 8 (1 for a
and 7 for padding). If I define a 9-member char array instead, it'll allocate 20 bytes.
Why does the pushed r7 need its own padding?