【问题标题】:objdump, displaying without offsetsobjdump,无偏移显示
【发布时间】:2011-12-17 01:21:50
【问题描述】:

当转储可执行文件时,我只希望将代码段打印在标准输出上,而不是代码的偏移量和二进制形式。我无法实现它

man objdump

有办法吗?

【问题讨论】:

    标签: objdump


    【解决方案1】:

    您可以使用抑制目标代码十六进制转储

    --no-show-raw-insn
    

    如果您在代码中有跳转,那么您需要偏移量才能理解它们,但如果您真的想去除它们,请使用以下内容过滤代码:

    objdump -d --no-show-raw-insn myfile.o | perl -p -e 's/^\s+(\S+):\t//;'
    

    示例输出:

    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
    

    【讨论】:

      【解决方案2】:

      如果您想获得与 Peeter Joot 所示相同的输出,但不使用 Perl 命令行。然后您可以使用 GrepCut 工具代替,如下所示。

      objdump -d --no-show-raw-insn my_binary_file.o | grep "^ " | cut -f2,3
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-01-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多