The debugger can tell you that (for example, the name of the function, given its address).
The ELF executable symbol table can also help. See nm (1) , objdump (1) , readelf (1)
Another Linux GNU / libc approach might be to use the dladdr (3) function at run time. Assuming that your program is beautifully and dynamically connected (for example, with -rdynamic ), it can find the name of the symbol and the path to the general object, taking into account some address (a function named globally).
Of course, if you have only five functions of this signature, you can compare your address (with five addresses from them).
Note that some functions do not have ((globally visible) names, such as static functions.
And some functions can be dlopen -ed and dlsym -ed (for example, inside plugins). Or their code is synthesized at runtime by some JIT-ing structure ( libjit , gccjit , LLVM , asmjit ). And the optimizing compiler can (and does!) Inline functions, clone them, tail-call them, etc., so your question may not make any sense at all ...
See also backtrace (3) and Ian Taylor libbacktrace inside GCC.
But in general, your quest is impossible. If you really need such reflective information in a reliable way, manage it yourself (look at the Pitrat CAIA system as an example, or somehow my MELT ), possibly generating some code at build time.
Basile Starynkevitch Oct 19 '15 at 13:41 2015-10-19 13:41
source share