如何解释 objdump 反汇编输出列? [英] How to interpret objdump disassembly output columns?

查看:30
本文介绍了如何解释 objdump 反汇编输出列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 c 编写了一个简单的程序,它调用一个名为 while_loop 的函数,参数为 4,3,2.该函数基本上只是一个 while 循环,我认为它与我的问题并不真正相关,因为它更像是一个通用问题.有人告诉我运行 objdump -d,所以我做了.

I wrote a simple program in c which calls a function called while_loop with arguments 4,3,2. The function is just basically a while loop, I don't think it's really that relevant to my question since it's more of a generic question. I was told to run objdump -d, so I did.

我有多个问题,所以这里是:

I have multiple questions so here it goes:

  1. 我知道在最左边的列中有地址,它们根据前面的字节数递增.我不太明白的是第二列.它是正在执行的指令,但是是十六进制的吗?这是否意味着 push %ebp 相当于 55 ?我不太明白.
  2. 由于这是 IA-32 并且它是小端,我知道最低有效字节存储在最低地址.但是,我不明白这些字节的显示顺序是否根据它们在内存中的位置.看第 3 行,8b 55 10"这是否意味着最低地址中有 8b,我会反过来读取它,或者这是否意味着 10 位于最低地址,我会反过来读取它?
  3. 左边的这些地址是绝对内存地址还是相对地址?

推荐答案

在这种情况下,您的地址是绝对地址,因为您有一个位置依赖可执行文件(不是 PIE).ELF 元数据(由链接器设置)中有一个字段指定映射可执行文件的虚拟地址.您可以使用 readelf -a 来查看更多内容.

In this case your addresses are absolute because you have a position-dependent executable (not a PIE). There's a field in the ELF metadata (set by the linker) that specifies what virtual address to map the executable. You can use readelf -a to see that and much more.

在 PIE 可执行文件中,十六进制地址将相对于图像库",这通常意味着相对于文件的开头.(类似于 .o,其中地址从 .text 部分开头的 0 开始计数).您可以使用 --adjust-vma=offset 设置打印这些地址的基地址.

In a PIE executable the hex addresses would be relative to the "image base", which normally means relative to the start of the file. (Similar to a .o, where the addresses count from 0 at the start of the .text section). You can use --adjust-vma=offset to set a base address for printing those addresses.

是的,第 2 列是机器代码的十六进制转储,作为内存顺序中的单个字节.Objdump 不会将它们解释为 little-endian-words 或类似的东西,只是每字节一对十六进制数字,按地址递增的顺序.

Yes, column 2 is a hexdump of the machine code, as single bytes in memory order. Objdump isn't interpreting them as little-endian-words or anything like that, just a pair of hex digits per byte, in order of increasing address.

x86 机器码基本上是一个字节流.指令由

[prefixes] opcode [modrm [SIB] displacement0/8/32] [immediate8/32]

操作码可以是单个字节,也可以是 Intel/AMD 文档中按内存顺序指定的字节序列,例如0F AF/r for imul reg, reg/mem

The opcode is either a single byte, or a sequence of bytes specified in memory order in Intel / AMD's documentation, e.g. 0F AF /r for imul reg, reg/mem

有些指令有 16 位立即数,但通常它是 1 或 4 个字节(如果有的话).

Some instructions have 16-bit immediates, but normally it's 1 or 4 bytes if present at all.

字节序仅与寻址模式中的多字节位移或多字节立即数相关.

例如mov $0x12345678, %eaxfoo.s 中,与 gcc -c foo.s 组合成 .o> 反汇编为:

e.g. mov $0x12345678, %eax in foo.s, assembles with gcc -c foo.s to a .o that disassembles as:

  0:   b8 78 56 34 12          mov    $0x12345678,%eax

<小时>

还可以在 SO 的 x86 标签维基中查看更多指向 x86 文档/手册的链接,包括英特尔的 PDF 手册


See also more links to x86 docs / manuals in SO's x86 tag wiki, including Intel's PDF manuals

这篇关于如何解释 objdump 反汇编输出列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆