如何做到这一点呢?
如果我想分析某些东西是如何编译的,我该如何获得发出的程序集代码?
如何做到这一点呢?
如果我想分析某些东西是如何编译的,我该如何获得发出的程序集代码?
当前回答
使用-S开关:
g++ -S main.cpp
或者也可以用gcc:
gcc -S main.c
还有这个。
其他回答
使用-S选项:
gcc -S program.c
最近我想知道a中每个函数的组装,我是这样做的:
gcc main.c // 'main.c' source file
gdb a.exe // 'gdb a.out' in Linux
广东发展银行:
disass main // Note here 'main' is a function
// Similarly, it can be done for other functions.
我在答案中没有看到这种可能性,可能是因为这个问题来自2008年,但在2018年,你可以使用马特·戈德博尔特的在线网站https://godbolt.org
你也可以在本地克隆git并运行他的项目https://github.com/mattgodbolt/compiler-explorer
使用-S开关:
g++ -S main.cpp
或者也可以用gcc:
gcc -S main.c
还有这个。
从FAQ如何让GCC生成汇编代码:
gcc -c -g -Wa,-a,-ad[其他gcc选项]foo.c > foo.lst
作为philrephly的答案的替代方案。
或者像大家说的,用-S。