logoalt Hacker News

voidUpdatetoday at 7:18 AM1 replyview on HN

I'm reminded of the tools in programs like Ghidra or IDA which can take assembly code and convert it into a C-like language. If you could create one of those tools that also takes in the source file so that it names things somewhat reasonably, could you create an anything to C translator? As long as the original file compiles to assembly, that is


Replies

circuit10today at 8:47 AM

I once used Ghidra to decompile a hand-written ARM assembly floating point library and compile the result to a different architecture, and it was significantly faster than GCC’s built in methods…

But in general this kind of thing is very unreliable for any non-trivial code without a lot of manual work, so a better approach could be to compile to WebAssembly which can be translated into C

show 1 reply