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 |
+--------------+
| ?? |
+--------------+
| ?? |
+--------------+