源代码:
void run(int n)
{
int m = n;
}
int main()
{
run(1000);
return 0;
}
without -fomit-frame-pointer:
08048374 <run>:
8048374: 55 push %ebp
8048375: 89 e5 mov %esp,%ebp
8048377: 83 ec 10 sub $0x10,%esp
804837a: 8b 45 08 mov 0x8(%ebp),%eax
804837d: 89 45 fc mov %eax,0xfffffffc(%ebp)
8048380: c9 leave
8048381: c3 ret
%ebp + 8 (last function addr + return ptr)
with -fomit-frame-pointer,忽略ebp成为栈指针,不能使用ebp作为栈帧回溯的途径,push %ebp;movl %esp,%ebp也就免了:
08048374 <run>:
8048374: 83 ec 10 sub $0x10,%esp
8048377: 8b 44 24 14 mov 0x14(%esp),%eax
804837b: 89 44 24 0c mov %eax,0xc(%esp)
804837f: 83 c4 10 add $0x10,%esp
8048382: c3 ret
%esp + 10 + 4 (return ptr)
gcc omit-frame 如何找到函数的第一个参数