Wednesday, January 7, 2009

Re-creating source code, Part 6

So, what toys do I have?

Well, I have the source to a later version of the compiler I use daily.

I have the compiler I use daily in binary form.

I have a disassembler.

I know how to decompile.

The magic trick is realize that the later version of the compiler is (almost always) a superset of the earlier compiler. It has the functionality of the earlier compiler, plus additional features and improvements.

So, I can compile the later version of the compiler, the disassemble it. This gives me source, binary, disassembly, and labels.

I can disassemble the binary of the earlier compiler. This gives binary and disassembly.

I can now compare the disassemblies. This will let me generate labels for the disassembly of the earlier compiler. It will also let me (thinking about decompiling) see what source statements were / were not in the source to the earlier compiler.

So, as I compare the disassemblies, I can edit the later compiler source to backtrack it to the earlier compiler source.

Good, right? Well, it turns out that there is one more thing that must be considered in doing this. I'll talk about it next time.

No comments: