我有以下测试汇编程序:
.section .rodata
a: .byte 17
.section .text
.globl _start
_start:
mov $1, %eax
mov a(%rip), %ebx
int $0x80
我已经编译成一个名为file
. 当我使用objdump
反汇编时,我得到以下预期输出:
$ objdump --disassemble --section=.text file
file: file format elf64-x86-64
Disassembly of section .text:
0000000000400078 <_start>:
400078: b8 01 00 00 00 mov $0x1,%eax
40007d: 8b 1d 02 00 00 00 mov 0x2(%rip),%ebx # 400085 <a>
400083: cd 80 int $0x80
但是,当我只打印带有$ xxd file
内存的二进制文件时,甚至不会达到400078
:
00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............
00000010: 0200 3e00 0100 0000 b000 4000 0000 0000 ..>.......@.....
00000020: 4000 0000 0000 0000 e001 0000 0000 0000 @...............
...
00000340: 2700 0000 0000 0000 0000 0000 0000 0000 '...............
00000350: 0100 0000 0000 0000 0000 0000 0000 0000 ................
造成这种差异的原因是什么?似乎xxd
只是从 0 开始偏移所有内容,但是如果您可以称它为确实objdump
使用的“偏移”,那又是什么?我怎样才能调和 where400078
会在xxd
哪里?还是我需要为此使用另一个程序?