RouteMapper
RouteMapper

Reputation: 2560

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]>

Upvotes: 19

Views: 27593

Answers (2)

Konrad Eisele
Konrad Eisele

Reputation: 3194

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.

Upvotes: 2

Employed Russian
Employed Russian

Reputation: 213606

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

Upvotes: 29

Related Questions