In an application built with debug symbols I need a function that given an address returns name of the symbol (if exists) at that address.
I'm aware of dladdr()
but it only works for symbols in shared libraries, not for symbols in the executable or static libraries.
As an example of how it should work, in gdb I can do info symbol 0x...
and it gives me a name. For the same address I should be able to do symbolName(0x...)
and I should get back the same name.
I'm guessing that there isn't an readily available solution for this so I'm happy to implement this myself, but I'm not sure where to start. I can parse DWARF info of the executable, but then I'm not sure where to look at in the DWARF.
Thanks