help on GCC calling convention
Posted: Wed May 25, 2011 3:53 am
Hello,
I'm studying the GCC calling convention. I compile a C function:
using GCC 4.4.3 with no optimization: gcc -S add2.c. And I got:
So the stack seems like this:
I don't understand why the GCC reserves 12 Byte in the stack. What the "??" place store?
I'm studying the GCC calling convention. I compile a C function:
Code: Select all
int add2(int a, int b) //add two numbers
{
int tmp;
tmp = a+b;
return tmp;
}
Code: Select all
add2:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl 12(%ebp), %eax
movl 8(%ebp), %edx
leal (%edx,%eax), %eax
movl %eax, -4(%ebp)
movl -4(%ebp), %eax
leave
ret
Code: Select all
| arg b | | stack grow direction
+--------------+ |
| arg a | \ /
+--------------+
| return eip |
+--------------+
| ebp |
+--------------+
| ?? |
+--------------+
| tmp |
+--------------+
| ?? |
+--------------+
| ?? |
+--------------+