Search code examples
cassemblydecompiling

Compile extracted ASM code so it can be decompiled?


I have a section of ASM code, a subroutine from a older executable that I need to either turn into a shared library, or C code so that I can incorporate it into a newer, rewritten version of the software. I no longer have access to the original source code, so unfortunately, it's attempt this, or rewrite the entire massive function from scratch.

I have access to software like IDA/Hex Rays, but my problem there is those will not turn ASM into pseudocode unless it can first decompile a binary. I don't have a binary - I have the ASM code. I can't (or rather, do not know how to) compile the ASM into a binary, as it's just a section of the code.

Is there a simple way to turn a section of ASM code into a compiled binary, or an ASM to C converter that does not require a binary to be decompiled first?


Solution

  • You didn't mention what platform you are on, but assuming you have access to Linux, you can compile ASM using as(1) (https://linux.die.net/man/1/as).

    BTW: You might want to look at the Bomerang project which is an open source decompiler http://boomerang.sourceforge.net/