问题描述
我尝试读取x86_64寄存器 rip
的值。这是 objdump
显示的内容。
I try to read the value of x86_64 register rip
. Here is what objdump
shows.
4017ec: 48 8d 35 00 00 00 00 lea 0x0(%rip),%rsi
4017f3: 41 89 d4 mov %edx,%r12d
我希望在执行指令 0x4017ec
之后, rsi
的值应为 0x4017ec
。但是它是 0x4017f3
,这是下一条指令的地址。
I expect that after instruction 0x4017ec
is executed, the value of rsi
should be 0x4017ec
. However it is 0x4017f3
, which is the address of the next instruction.
我使用gdb在<$处停止c $ c> 0x4017ec ,那时 rip
的值是 0x4017ec
。为什么当时 rip
的值未加载 rsi
?处理器是否应该从 0x4017ec
中读取指令?
I use gdb to stop at 0x4017ec
and at that time the value of rip
is 0x4017ec
. Why is rsi
not loaded by the value of rip
at that time? Should the processor read instruction from 0x4017ec
?
推荐答案
取决于体系结构,%rip保留当前执行的指令或下一条要执行的指令。在这里,您在0x4017ec之前添加了一个断点,这意味着下一条要执行的指令是0x4017ec。但是%rsi仅在执行第一条指令后才会加载。届时%rip将已经更新为指向下一条指令。
Depends on the architecture %rip holds either the current executing instruction or the next instruction to be executed. Here you added a breakpoint before 0x4017ec which means the next instruction to be executed is 0x4017ec. But %rsi will be loaded only after executing the first instruction. By then %rip would have already updated to point to the next instruction.
这篇关于读RIP寄存器给出下一条指令的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!