Reputation:
I'm trying to get the function name of C function that was hidden, aka not exposed in the symbol table of an image.
I'm doing this on OS X and using dladdr and when dladdr returns success I check the dli_sname
field, but its NULL.
Is there no way to get back the C function name? As I understand it, the C functions that are unexported end up being inlined?
Upvotes: 2
Views: 145
Reputation: 40305
There is no way.
Inline or not, if it isnt in the symbol table, there isn't anywhere else names are stored short of if it was built with debug info, and even then if it were optimized it is still sometimes difficult or impossible to recover.
You can dump the symbol table with e.g. objdump if you are curious, anything that isn't there isn't available to you through dladdr.
Upvotes: 3
Reputation: 1686
Unexported functions are not necessarily inlined (otherwise you wouldn't have a function address in the first place), but they're not in the symbol table, so they have no name associated with them.
There is no way to get the name, unless you export all symbols (e.g. GCC's -export-dynamic
), but I guess you wouldn't be asking in the first place if you could do that. If it had debug info, it'd probably be possible to parse it to get the name though.
Upvotes: 2