-
Accessing function list
Hello everybody
is there a way to access the function list of a program from within the program itself? I have a list of function pointers (in a C program) to assign dinamically on rutime. Can this be done? Where I can look for further info on the matter?
Thanks in advance!
Fabio.
-
-
-
errr... that was essay on function pointers. Nothing (even in the links section). Maybe I didn't made myswlf clear: I want to know which functions my executable incorporates, (I imagine) doing a little memory tinkering on the memory space of the program.
I want something like:
./a.out
This program has a function called main() at 0x4214141
This program has a function called add_this() at 0x421405A
This program has a function called sub_this() at 0x42146FB
...
Is this possible? is there any help libraries to do something like this?
Thanks again :)
Fabio.
-
have u tried strace? It works for system calls ...
-
Sounds about the same as this question.
http://cboard.cprogramming.com/showthread.php?t=68866
Some things you can consider
- Read the manual page for dlsym
- study the output of the 'nm' command.
-
I think he wants to list the addresses of functions declared in the executable.
There is no way to do that inside ciode without knowing the names of all of the function entry points. But you get this from "outside" the executable using nm.
You will have to maintain an internal table (array) of function pointers that is specific to your code.
Or download a copy of the linux nm source for your architecture, and see how nm indentifies function entry points. You would then have to scan the executable at runtime to build an internal table, because every time you re-link it is possible for entrypoint addresses to change.