gdb - 使用额外的数据,为什么? [英] gdb - nop with extra data, why?
问题描述
我正在编写简单的测试,以了解gdb如何使用 externC
和选项 -O0 $ c从C ++编译为asm $ c>,我的asm对象是用
nasm -g -f elf64
编译的。这里是我的反汇编堆栈frame:
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]该指令
0x000000000040058b< + 27>:nop DWORD PTR [rax + rax * 1 + 0x0];和这一个
最后两条指令用 现在我的问题是为什么 nop $ c
和
nop
正在沿着 DWORD PTR [rax + rax * 1 + 0x0]
?
这些是多字节nop指令,用作对齐目的的填充。在这种情况下,它们不会被执行,所以编译器可以使用任何东西,但在其他情况下可能需要执行。当然,请参见intel优化手册的 3.5.1.9使用NOP 以及 NOP
的指令集引用条目。 p>
I am currently writing simple tests to understand how gdb compiles from C++ to asm using extern "C"
and option -O0
and my asm object is compiled with nasm -g -f elf64
Here is my disassembled concerned stack frame:
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 two last instructions are padded with nop
, I can get this because of alignment.
Now my question is why nop
are being along WORD PTR cs:[rax+rax*1+0x0]
and DWORD PTR [rax+rax*1+0x0]
?
Those are multi-byte nop instructions, used as padding for alignment purposes. In this case they won't ever be executed, so the compiler could have used anything but under other circumstances it may need to be executable. See also the intel optimization manual, section 3.5.1.9 Using NOPs, as well as the instruction set reference entry for NOP
, of course.
这篇关于gdb - 使用额外的数据,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!