What does this Intel jmpq instruction do?

会有一股神秘感。 提交于 2019-12-01 14:49:18

问题


How is the address 0x600860 computed in the Intel instruction below? 0x4003b8 + 0x2004a2 = 60085a, so I don't see how the computation is carried out.

0x4003b8 <puts@plt>: jmpq *0x2004a2(%rip) # 0x600860 <puts@got.plt>


回答1:


On Intel, JMP, CALL, etc. are relative to the program counter of the next instruction.

The next instruction in your case was at 0x4003be, and 0x4003be + 0x2004a2 == 0x600860




回答2:


It's AT&T syntax for a memory-indirect JMP with a RIP-relative addressing mode.

The jump address is fetched from the memory location that is specified relative to the instruction pointer: first calculate 0x4003be + 0x2004a2 == 0x600860 then fetch the address to jump to from location 0x600860.

Other addressing modes are possible, for example a jump-table might use
jmpq *(%rdi, %rax, 8) with the table base in RDI and the index in RAX.

RIP-relative addressing for static data is common, though. In this case, it's addressing an entry in the GOT (Global Offset Table), set up by dynamic linking.



来源:https://stackoverflow.com/questions/20251097/what-does-this-intel-jmpq-instruction-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!