Gdb - nop with additional data, why?

Currently I am writing simple tests to understand how gdb compiled from C ++ in asm using extern "C" and options -O0 , and my asm object is compiled with nasm -g -f elf64

Here is my parsed frame package:

  0x0000000000400570 <+0>: push rbp 0x0000000000400571 <+1>: mov rbp,rsp 0x0000000000400574 <+4>: push r10 => 0x0000000000400576 <+6>: mov r10,QWORD PTR [rbp-0x8] 0x000000000040057a <+10>: pop r10 0x000000000040057c <+12>: mov rsp,rbp 0x000000000040057f <+15>: pop rbp 0x0000000000400580 <+16>: ret 0x0000000000400581 <+17>: nop WORD PTR cs:[rax+rax*1+0x0] ; this instruction 0x000000000040058b <+27>: nop DWORD PTR [rax+rax*1+0x0] ; and this one rsp  0x0000000000400570 <+0>: push rbp 0x0000000000400571 <+1>: mov rbp,rsp 0x0000000000400574 <+4>: push r10 => 0x0000000000400576 <+6>: mov r10,QWORD PTR [rbp-0x8] 0x000000000040057a <+10>: pop r10 0x000000000040057c <+12>: mov rsp,rbp 0x000000000040057f <+15>: pop rbp 0x0000000000400580 <+16>: ret 0x0000000000400581 <+17>: nop WORD PTR cs:[rax+rax*1+0x0] ; this instruction 0x000000000040058b <+27>: nop DWORD PTR [rax+rax*1+0x0] ; and this one rbp  0x0000000000400570 <+0>: push rbp 0x0000000000400571 <+1>: mov rbp,rsp 0x0000000000400574 <+4>: push r10 => 0x0000000000400576 <+6>: mov r10,QWORD PTR [rbp-0x8] 0x000000000040057a <+10>: pop r10 0x000000000040057c <+12>: mov rsp,rbp 0x000000000040057f <+15>: pop rbp 0x0000000000400580 <+16>: ret 0x0000000000400581 <+17>: nop WORD PTR cs:[rax+rax*1+0x0] ; this instruction 0x000000000040058b <+27>: nop DWORD PTR [rax+rax*1+0x0] ; and this one 

The last two teams are complemented by nop , I can get it out of alignment.

Now my question is: why nop located along WORD PTR cs:[rax+rax*1+0x0] * DWORD PTR [rax+rax*1+0x0] WORD PTR cs:[rax+rax*1+0x0] and DWORD PTR [rax+rax*1+0x0] ?

+6
source share
1 answer

These are multibyte instructions, used as a complement to alignment. In this case, they will never be satisfied, so the compiler can use anything, but in other circumstances it may be required to perform. See Also Intel Optimization Guide, Section 3.5.1.9. Using the NOP, as well as background record set of commands to NOP , of course.

+7
source

All Articles