0

I am currently disassembling RUST binaries, and I often come across this block of instruction:

.text:000055F4BFB943F2 db      2Eh
.text:000055F4BFB943F2 nop     word ptr [rax+rax+00000000h]
.text:000055F4BFB943FC nop     dword ptr [rax+00h]

Which probably does nothing. I can see the rogue byte at the beginning, but trying to disassemble from it gives no result. Thus, I am wondering why rust compiler create those instructions as they appear to be useless.

Ted Klein Bergman
  • 9,146
  • 4
  • 29
  • 50
Qwark
  • 95
  • 6
  • 2
    It's for alignment, the next instruction is at ...94400 – harold Jul 23 '20 at 14:05
  • 3
    Weird that your disassembler didn't decode that `2e` prefix as part of the first long-NOP. In 32-bit mode it's a CS segment override (http://ref.x86asm.net/coder32.html#x2E), in 64-bit mode it has no effect but is still valid. So this is a fully valid sequence that could actually execute, e.g. inside a function to align the top of a loop, not just as padding between functions. – Peter Cordes Jul 23 '20 at 14:12
  • Could you post an answer so I can validate it? @harold – Qwark Jul 23 '20 at 14:26
  • A more similar question is [Why did the compiler put a 15-byte nop in the middle of this function?](https://stackoverflow.com/q/41094514), but it's already closed as a duplicate of [Performance optimisations of x86-64 assembly - Alignment and branch prediction](https://stackoverflow.com/q/18113995) – Peter Cordes Jul 23 '20 at 15:54

0 Answers0