I was told to use a disassembler. Does gcc
have anything built in? What is the easiest way to do this?
|
|||||
|
I don't think
The disassembly looks like this:
|
|||||||||
|
An interesting alternative to objdump is gdb. You don't have to run the binary or have debuginfo.
With full debugging info it's even better.
objdump has a similar option (-S) |
||||
|
Agner Fog's disassembler,
(It doesn't recognize It also adds branch targets to the code. Other disassemblers usually disassemble jump instructions with just a numeric destination, and don't put any marker at a branch target to help you find the top of loops and so on. It also indicates NOPs more clearly than other disassemblers (making it clear when there's padding, rather than disassembling it as just another instruction.) It's open source, and easy to compile for Linux. It can disassemble into NASM, YASM, MASM, or GNU (AT&T) syntax. Sample output:
Note that this output is ready to be assembled back into an object file, so you can tweak the code at the asm source level, rather than with a hex-editor on the machine code. (So you aren't limited to keeping things the same size.) With no changes, the result should be near-identical. It might not be, though, since disassembly of stuff like
doesn't have anything in the source to make sure it assembles to the longer encoding that leaves room for relocations to rewrite it with a 32bit offset. If you don't want to install it objconv, GNU binutils |
||||
|
Use IDA Pro and the Decompiler. |
|||||||||||||||||
|
there's also ndisasm, which has some quirks, but can be more useful if you use nasm. I agree with Michael Mrozek that objdump is probably best. [later] you might also want to check out Albert van der Horst's ciasdis: http://home.hccnet.nl/a.w.m.van.der.horst/forthassembler.html. it can be hard to understand, but has some interesting features you won't likely find anywhere else. |
||||
|
You might find ODA useful. It's a web-based disassembler that supports tons of architectures. |
|||
|
ht editor can disassemble binaries in many formats. It is similar to Hiew, but open source. To disassemble, open a binary, then press F6 and then select elf/image. |
||||
|