3 ms·
I've wondered whether it would be possible to design a language with the explicit intent of being a decompilation target, such that you could guarantee that any
by HALtheWise 3y ago
I've wondered whether it would be possible to design a language with the explicit intent of being a decompilation target, such that you could guarantee that any program could be decompiled into it and then subsequently re-compiled with the original behavior preserved. Having such a language (perhaps a superset of C?) would make it way easier to perform binary patching.
- ltfish 3y agoDARPA’s Enhanced SBOM for Optimized Software Sustainment (E-BOSS) program may achieve this goal (via a slightly different approach).
- rgovostes 3y agoIn a way disassembler output is exactly this. It’s a low level programming language, but one nonetheless. There are tools like Remill (https://www.trailofbits.com/opensource/#binary https://www.trailofbits.com/opensource/#binary) that disassemble to LLVM IR that can be fed back to the compiler to produce a new binary. You can actually target a different architecture, so it works for binary translation too.
- JonChesterfield 3y agoI don't think you'd need to change the language, only the implementation. The easy way to go is to emit metadata along with the machine code to aid reconstruction, roughly a variant on dwarf format debug information.
- turol 3y agoThis is not possible. Both disassembly and decompilation are equivalent to the halting problem. At least Mike Van Emmerik's PhD thesis ("Static Single Assignment for Decompilation") mentions this though I'm not sure if that's the original source.
- deleted 3y ago[deleted]
- konstante 3y agoYes, static disassembling is well known undecidable, data and code are indistinguishable in general. The reason is very simple (it's actually just an exercice), consider an assembly code: jmp rax ...some binary data... Where the value of "rax" depends on some input, so the disassembler can never be sure that "some binary data" is actually "data" or "code".