Accessing function list

This is a discussion on Accessing function list within the Linux Programming forums, part of the Platform Specific Boards category; Hello everybody is there a way to access the function list of a program from within the program itself? I ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    3

    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.
    Last edited by SnowDruid; 08-18-2005 at 07:54 AM.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    3
    thanks!

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

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

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,854
    Sounds about the same as this question.
    going to a another function

    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    .
    Join Date
    Nov 2003
    Posts
    307
    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, 11:43 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06: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, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21