写了一个简单的C语言代码:
#include<stdio.h> int main() { int a,b,c; a=1; b=2; c=a+b; printf("%d",c); }
使用arm-linux-objdump -d 反汇编
00000000 <main>: 0: e92d4800 push {fp, lr} 4: e28db004 add fp, sp, #4 8: e24dd010 sub sp, sp, #16 c: e3a03001 mov r3, #1 10: e50b3010 str r3, [fp, #-16] 14: e3a03002 mov r3, #2 18: e50b300c str r3, [fp, #-12] 1c: e51b2010 ldr r2, [fp, #-16] 20: e51b300c ldr r3, [fp, #-12] 24: e0823003 add r3, r2, r3 28: e50b3008 str r3, [fp, #-8] 2c: e59f3014 ldr r3, [pc, #20] ; 48 <main+0x48> 30: e1a00003 mov r0, r3 34: e51b1008 ldr r1, [fp, #-8] 38: ebfffffe bl 0 <printf> 3c: e24bd004 sub sp, fp, #4 40: e8bd4800 pop {fp, lr} 44: e12fff1e bx lr 48: 00000000 .word 0x00000000
地址对应指令内容,可以读懂。
配合arm-linux-gdb单步调试和查看寄存器内容。反汇编利器。