In a gdb
session, how are the addresses list in the comments of the assembly output computed? To give an example, I am currently on the following instruction:
0x0000555555556140 ? jmpq *0x7af5a(%rip) # 0x5555555d10a0 <strlen@got.plt>
We can confirm that the instruction pointer matches the address shown in the left column:
(gdb) p $rip
$1 = (void (*)()) 0x555555556140 <strlen@plt>
From here, we are going to jump to the address pointed at by $rip + 0x7af5a
. The address with the jump pointer
(gdb) p/z ($rip + 0x7af5a)
$2 = 0x00005555555d109a
points to
(gdb) x/g ($rip + 0x7af5a)
0x5555555d109a <getpwuid@got.plt+2>: 0xd1e0000055555555
This does not match the address in the comment for this instruction (0x5555555d10a0
), which I naively expected was meant to convey where the jump was going to go.
That address turns out to be 7af60
from the current instruction:
(gdb) p/z 0x5555555d10a0 - 0x0000555555556140 # commented address - current address
$3 = 0x000000000007af60
i.e., $rip + 0x7af60
, which is 6 bytes beyond the jump pointer ($rip + 0x7af5a
). What is the significance of commenting an address 6 bytes beyond the jump pointer?
How can the jump address be displayed in the GDB console without relying on the comments provided by GDB's disassembly? Or assigned to a GDB variable for use when scripting GDB.