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]>
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
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 usejmpq *(%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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With