I'm trying to get the symbol name by its address in memory. I use int dladdr(void *addr, Dl_info *info)
function from dlfcn.h
to get the information:
typedef struct { const char *dli_fname; /* Pathname of shared object that contains address */ void *dli_fbase; /* Address at which shared object is loaded */ const char *dli_sname; /* Name of nearest symbol with address lower than addr */ void *dli_saddr; /* Exact address of symbol named in dli_sname */ } Dl_info;
But this function can't find symbol matching the address and sets dli_sname and saddr to NULL.
How can I get the name of symbol or any other information (kind, attributes, etc.) about the symbol in this case?
NOTE: The name of the symbol I'm trying to find is _ZTv0_n24_N4QGst13PropertyProbeD0Ev
. It's listed in the vtable of class QGst::PropertyProbe
by g++ -fdump-class-hierarchy
:
Vtable for QGst::PropertyProbe QGst::PropertyProbe::_ZTVN4QGst13PropertyProbeE: 14u entries ... 80 (int (*)(...))QGst::PropertyProbe::_ZTv0_n24_N4QGst13PropertyProbeD1Ev ...
But it's not found by dladdr
by its address that I've got when looking into the shared object by dlopen
and dlsym
of symbol _ZTVN4QGst13PropertyProbeE
and iterating through the list of virtual function pointers. All other functions in the v-table are found by dladdr
.