Thread: Accessing function list

  1. #1
    Registered User
    Join Date
    Aug 2005

    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!

    Last edited by SnowDruid; 08-18-2005 at 06:54 AM.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003

  3. #3
    Registered User
    Join Date
    Aug 2005

  4. #4
    Registered User
    Join Date
    Aug 2005
    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:

    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

  5. #5
    Registered User
    Join Date
    Aug 2005
    have u tried strace? It works for system calls ...

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Sounds about the same as this question.

    Some things you can consider
    - Read the manual page for dlsym
    - study the output of the 'nm' command.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Join Date
    Nov 2003
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  4. List class
    By SilasP in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2002, 05:20 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM