转储可执行文件时,我只希望将代码段打印在标准输出上,而不是代码的偏移量和二进制形式。我无法从
man objdump
Run Code Online (Sandbox Code Playgroud)
有办法吗?
您可以使用以下命令抑制目标代码十六进制转储
--no-show-raw-insn
Run Code Online (Sandbox Code Playgroud)
如果您在代码中有跳转,那么您需要偏移量来理解它们,但如果您真的想剥离它们,请使用以下内容过滤代码:
objdump -d --no-show-raw-insn myfile.o | perl -p -e 's/^\s+(\S+):\t//;'
Run Code Online (Sandbox Code Playgroud)
示例输出:
0000000000000000 <foo>:
retq
lea 0x0(%rsi),%rsi
lea 0x0(%rdi),%rdi
Disassembly of section .gnu.linkonce.t.goo:
0000000000000000 <goo>:
retq
lea 0x0(%rsi),%rsi
lea 0x0(%rdi),%rdi
Run Code Online (Sandbox Code Playgroud)