2
votes

Is there a way by which I can get the address of a global symbol in my binary if I know its name with the GDB Python API ?

Is python print(gdb.parse_and_eval('symbol').address) the correct method t o obtain this value ?

1
I guess that there could be a simpler way. I am sadly not familiar enough with Python bindings to gdb internals. - Basile Starynkevitch

1 Answers

1
votes

Well, you answered yourself already correctly. Easy enough to verify:

(gdb) p &t
$2 = (time_t *) 0x562076476018 <t>
(gdb) python print(gdb.parse_and_eval('t').address)
0x562076476018 <t>
(gdb)