views:

57

answers:

2

Hi everyone!

Out of curiosity about reverse engineering, I am thinking of writing a simple program (in C++) that takes an executable as input and produces the names of all the functions that were a part of source program of that executable.

Any pointers on how should I go about it?

Step-by-step approach would be much appreciated!

EDIT:
Platform linux and i am concerned about a.out format executable files.

+2  A: 

Depends heavily on your platform and the origin of the code you're examining. You need a symbol table for the binary you're reversing if you want to get function names out of it. Sometimes that table is embedded in the binary (such as the export lookup table in a DLL), but many times the information simply doesn't exist.

There's no generalized solution for this. You'll need to narrow your question down to a specific platform at least, and preferably a specific target binary type.

Edit: Okay, with the specifications you've given, I'm guessing that you're probably actually concerned with ELF binaries rather than the older a.out format, which is fairly uncommon. "a.out" is still the default output name for the GCC linker, but the actual a.out binary format hasn't been commonly used in Linux for a long time.

There are a number of good walkthroughs of the ELF structure available online, and some quick searching turned up a ready-made example of reading the ELF .symtab as well.

Hope this helps.

Dan Story
edited as required!
Neeraj
+1  A: 

Pretty much impossible. This sort of data is not contained within the vast, vast majority of executables. DLLs, maybe.

DeadMG
Depends if they have been stripped or not - I guess the vast majority of them will have been, as you say.
anon
Turns out the OP's not interested here anyway.
DeadMG