gdb - nop 有额外数据,为什么? [英] gdb - nop with extra data, why?

查看:25
本文介绍了gdb - nop 有额外数据,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写简单的测试以了解 gdb 如何使用 extern "C" 和选项 -O0 从 C++ 编译为 asm,并且我的 asm 对象是用 nasm -g -f elf64

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

最后两条指令用nop填充,因为对齐我可以得到这个.

The two last instructions are padded with nop, I can get this because of alignment.

现在我的问题是为什么 nop 沿着 WORD PTR cs:[rax+rax*1+0x0]DWORD PTR [rax+rax*1+0x0] ?

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

推荐答案

那些是多字节 nop 指令,用作对齐目的的填充.在这种情况下,它们永远不会被执行,所以编译器可以使用任何东西,但在其他情况下它可能需要是可执行的.另请参阅英特尔优化手册,3.5.1.9 Using NOPs 部分,当然还有 NOP 的指令集参考条目.

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 - nop 有额外数据,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆