Search code examples
assemblyx86x86-64machine-code

Why aren't instructions' adresses consecutive in machine code?


I just compiled a CPP source code into an object .o file, and the first couple of lines are like the following:

Disassembly of section .text:

0000000000000000 <_Z8mainLoopv>:
   0:   f3 0f 1e fa             endbr64 
   4:   55                      push   %rbp
   5:   48 89 e5                mov    %rsp,%rbp
   8:   41 55                   push   %r13
   a:   41 54                   push   %r12
   c:   53                      push   %rbx
   d:   48 81 ec 88 00 00 00    sub    $0x88,%rsp
  14:   64 48 8b 04 25 28 00    mov    %fs:0x28,%rax

I am assuming the first column is the adress of the instructions, am I right? If so, why aren't they consecutive? Something like this:

   0:   f3 0f 1e fa             endbr64 
   1:   55                      push   %rbp
   2:   48 89 e5                mov    %rsp,%rbp
   3:   41 55                   push   %r13
   4:   41 54                   push   %r12
   5:   53                      push   %rbx
   6:   48 81 ec 88 00 00 00    sub    $0x88,%rsp
   7:   64 48 8b 04 25 28 00    mov    %fs:0x28,%rax

Solution

  • The first column is the address of the instruction.

    Because x86_64 instructions aren't the same length (like ARM64 for example), the value difference varies. The second column show the bytes of each instructions. Notice that they have different lengths.