题目要求
1.通过输入gcc -S -o main.s main.c 将下面c程序”week0603学号.c“编译成汇编代码
int g(int x){ return x+3; } int f(int x){ int i = 学号后两位; return g(x)+i; } int main(void){ return f(8)+1; }2.参考(),使用gdb跟踪汇编代码,在纸上画出f中每一条语句引起的eip(rip),ebp(rbp),esp(rsp),eax(rax)的值和栈的变化情况。提交照片,要有学号信息。
做题过程
查看rax寄存器变化
- rax 0x40050a 4195594
- rax 0x40050a 419559
- rax 0x2c 44
rax 0x2c 44
查看rbp寄存器变化
rbp 0x7fffffffde80 0x7fffffffde80
rbp 0x7fffffffde80 0x7fffffffde80
rbp 0x7fffffffde80 0x7fffffffde80
rbp 0x400520 0x400520 <__libc_csu_init>
查看rsp寄存器变化
- rsp 0x7fffffffde80 0x7fffffffde80
- rsp 0x7fffffffde80 0x7fffffffde80
- rsp 0x7fffffffde80 0x7fffffffde80
rsp 0x7fffffffde90 0x7fffffffde90
查看rip寄存器变化
- rip 0x40050e 0x40050e <main+4>
- rip 0x40050e 0x40050e <main+4>
- rip 0x40051b 0x40051b <main+17>
rip 0x7ffff7a2d830 0x7ffff7a2d830 <__libc_start_main+240>