为什么 objdump 显示此汇编语言指令的空操作码?

Why does objdump show a null opcode for this assembly language instruction?

我有以下汇编代码:

global _start
section .text
_start:

add byte [eax], al

编译链接后,我尝试查看操作码:

$ objdump -d eax.o

eax.o:     file format elf32-i386


Disassembly of section .text:

00000000 <_start>:
        ...
$

为什么我得到一个空操作码?

这条指令:

add byte [eax], al

被编码为两个字节ADD指令0x00 0x00:

Opcode    Instruction     Op/En   64-bit Mode Compat/Leg Mode Description
00 /r     ADD r/m8, r8    MR      Valid       Valid           Add r8 to r/m8.

OBJDUMP 默认情况下会将重复零的块打印为 ...。要更改此行为,请尝试使用 -z 选项,如 manual:

中所述

-z --disassemble-zeroes

Normally the disassembly output will skip blocks of zeroes. This option directs the disassembler to disassemble those blocks, just like any other data.

您的命令可能如下所示:

objdump -z -d eax.o 

输出应该类似于:

Disassembly of section .text:

00000000 <_start>:
   0:   00 00                   add    %al,(%eax)