I am trying to understand how functions are called in C. When I parse this code (gcc - gdb; I'm on Linux with i5-3320M) to get the prologue of the toto function:
void nop(){return ;} void toto(int i, int j) { return; } int main(int argc, char **argv) { int i = 1; int* pt; i = 0; }
I get the prologue:
0x0000000000400523 <+0>: push %rbp 0x0000000000400524 <+1>: mov %rsp,%rbp 0x0000000000400527 <+4>: sub $0x8,%rsp
Here I do not understand why rsp reduced by 8, since I do not use a local variable in toto . Moreover, if I use a local variable:
void toto(int i, int j) { int i=1 return; }
I get the following prologue:
0x0000000000400523 <+0>: push %rbp 0x0000000000400524 <+1>: mov %rsp,%rbp 0x0000000000400527 <+4>: sub $0x18,%rsp
And here I do not understand why rsp reduced by 0x18 (24 bytes). I would expect something like 16 bytes, because I already have a mysterious offset of 8, plus I need 4 bytes for int. But my architecture is 64 bits, the word on the stack cannot be less than 8 bytes, so 8 + 8 = 16.
source share