I'm trying to get the symbol name by it's address in memory.
What for?
I use int dladdr() ...
The first thing you need to understand is that dladdr
only looks at dynamic symbol table of the ELF image, which often is much smaller than the static symbol table. You can see the contents of dynamic symbol table with nm -D
.
For example, if you link a.out
executable without -Wl,-E
or -rdynamic
flag, then main
will not appear appear in the dynamic symbol table, and thus will be "invisible" to dladdr
.
The second thing you need to know is that when you link a shared library, you can control exactly what symbols do and do not get exported from it (exported symbols are the ones that have dynamic symbol table entries). There are various methods for doing this: linker version scripts, -fvisibility
flags, attribute((visibility(...)))
.
All this is to say that finding a symbol that dladdr
can't tell you anything about should not at all be surprising.