使用GCC产生可读的汇编? [英] Using GCC to produce readable assembly?
本文介绍了使用GCC产生可读的汇编?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道如何使用 GCC 在我的C源文件转储的一个助记符机code,所以我可以看看我的code的被编译成。为此,您可以用Java,但我一直没能找到与海湾合作委员会的方式。
I was wondering how to use GCC on my C source file to dump a mnemonic version of the machine code so I could see what my code was being compiled into. You can do this with Java but I haven't been able to find a way with GCC.
我想重新写汇编一个C的方法,看如何GCC它会是一个很大的帮助。
I am trying to re-write a C method in assembly and seeing how GCC does it would be a big help.
推荐答案
如果您使用调试符号编译,你可以使用 objdump的
来产生一个更可读的拆卸。
If you compile with debug symbols, you can use objdump
to produce a more readable disassembly.
>objdump --help
[...]
-S, --source Intermix source code with disassembly
-l, --line-numbers Include line numbers and filenames in output
例如:
> gcc -g -c test.c
> objdump -d -M intel -S test.o
test.o: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include <stdio.h>
int main(void)
{
0: 55 push ebp
1: 89 e5 mov ebp,esp
3: 83 e4 f0 and esp,0xfffffff0
6: 83 ec 10 sub esp,0x10
puts("test");
9: c7 04 24 00 00 00 00 mov DWORD PTR [esp],0x0
10: e8 fc ff ff ff call 11 <main+0x11>
return 0;
15: b8 00 00 00 00 mov eax,0x0
}
1a: c9 leave
1b: c3 ret
这篇关于使用GCC产生可读的汇编?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文