gdb反汇编

比如我们有个.c,编译时并没有用-g生成调试信息:

#include <stdio.h>
int add(int a, int b) { return a + b; }
int main() { printf("%d\n", add(3, 5)); }

只要没有strip掉symbol,也可以用gdb看到函数的汇编代码:

(gdb) disass add
Dump of assembler code for function add:
   0x00401360 <+0>:     push   %ebp
   0x00401361 <+1>:     mov    %esp,%ebp
   0x00401363 <+3>:     mov    0x8(%ebp),%edx
   0x00401366 <+6>:     mov    0xc(%ebp),%eax
   0x00401369 <+9>:     add    %edx,%eax
   0x0040136b <+11>:    pop    %ebp
   0x0040136c <+12>:    ret
End of assembler dump.

[GDB disassemble - 枪侠 - 博客园

哦,土了,还有objdump.

disassembly - How to disassemble a memory range with GDB? - Stack Overflow

debugging - gdb - how to disassemble whole function including loops - Stack Overflow

Machine Code (Debugging with GDB) (sourceware.org)

Tutorial: Debugging with Intel® Distribution for GDB* on Linux

posted @ 2022-02-15 13:41  华容道专家  阅读(202)  评论(0)    收藏  举报