views:

73

answers:

2

The executable file of c++ will contain linkers, modules and others, i would like to look into its contents, i'm using linux, how can i view contents of a.out? which command should use to browse a.out, text editors wont show the contents......

A: 

Using the nm command you can inspect a binary and see what symbols are defined. If you want to see the actual code that was used to create a binary you will need a decompiler, which will only be able to partially reconstruct the original code as parts are inherently lost during compilation.

Pieter
+3  A: 

You can use nm to see the internal symbols and objdump to get the disassemble. By example:

objdump -D a.out | less

Note however that during the final linking of the object files into the executable a lot of symbols and internal data get eliminated, therefore you won't be able to understand the structure as you would be with object files.

If you want to edit and modify the executable, I suggest you to use the hte editor, which can act as disassembler for x86 executables. If you are a debian/ubuntu user the package name is "ht" (not "hte").

Also I wrote a little elf disassembly library which is still incomplete but pretty funny. You can find other (more complete and probably better) implementations however!

Dacav