how can I write just a simple disassembler for linux from scratches? Are there any libs to use? I need something that "just works".
-
What architecture(s) are you targeting, as this is significantly more relevent than the OS.DaveR– DaveR2009-07-08 23:03:02 +00:00Commented Jul 8, 2009 at 23:03
-
Sorry I've omitted which architecture, I'm tryng disassembling under x86Lopoc– Lopoc2009-07-09 15:59:25 +00:00Commented Jul 9, 2009 at 15:59
4 Answers
Instead of writing one, try Objdump.
Based on your comment, and your desire to implement from scratch, I take it this is a school project. You could get the source for objdump and see what libraries and techniques it uses. The BFD library might be of use.
1 Comment
you have to understand the ELF file format first. Then, you can start processing the various sections of code according to the opcodes of your architecture.
Comments
You can use libbfd and libopcodes, which are libraries distributed as part of binutils.
http://www.gnu.org/software/binutils/
As an example of the power of these libraries, check out the Online Disassembler (ODA).
http://www.onlinedisassembler.com
ODA supports a myriad of architectures and provides a basic feature set. You can enter binary data in the Live View and watch the disassembly appear as you type, or you can upload a file to disassemble. A nice feature of this site is that you can share the link to the disassembly with others.
Comments
You can take a look at the code of ERESI
The ERESI Reverse Engineering Software Interface is a multi-architecture binary analysis framework with a tailored domain specific language for reverse engineering and program manipulation.