Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this Intel jmpq instruction do?

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 <[email protected]>

like image 820
RouteMapper Avatar asked Nov 27 '13 19:11

RouteMapper


Video Answer


2 Answers

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

like image 96
Employed Russian Avatar answered Dec 02 '22 22:12

Employed Russian


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.

like image 43
Konrad Eisele Avatar answered Dec 02 '22 22:12

Konrad Eisele