Linux内核分析学习_Week1_反汇编一个简单的C程序

时间:2023-02-11 23:36:39
反汇编一个简单的C程序#include int g(int x){ return x + 3;}int f(int x){ return g(x);}int main(void){ return f(8) + 1;}使用命令gcc -S -o main.s main.o -m32查看main.s文件,即汇编代码 .file "main.c" .text.globl g .type g, @functiong: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax addl $3, %eax popl %ebp ret .size g, .-g.globl f .type f, @functionf: pushl %ebp movl %esp, %ebp subl $4, %esp movl 8(%ebp), %eax movl %eax, (%esp) call g leave ret .size f, .-f.globl main .type main, @functionmain: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) pushl %ebp movl %esp, %ebp pushl %ecx subl $4, %esp movl $8, (%esp) call f addl $1, %eax addl $4, %esp popl %ecx popl %ebp leal -4(%ecx), %esp ret .size main, .-main .ident "GCC: (GNU) 4.1.2 20080704 (Red Hat 4.1.2-50)" .section .note.GNU-stack,"",@progbits