Live data from Hacker News

Snowman native code to C/C++ decompiler for x86/x86_64/ARM

github.com

21–30 of 40 posts

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#21
post #2

If we would write some code in rust, compile it to, for example, x86_64. And then de-compile it to C. It would be perfectly memory-safe C code, right?

Nothing is perfectly memory-safe. Also, not sure I would see the point of this translation?

> Nothing is perfectly memory-safe.

How about formally verified SPARK code?

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#22
post #2

If we would write some code in rust, compile it to, for example, x86_64. And then de-compile it to C. It would be perfectly memory-safe C code, right?

As Rust is llvm based, you don't need to compile it to C. Just write a backend that translates LLVM IR to C instead of x86_64. The IR is very C looking, it's probably overly complex.

Compiling down to asm, lot of information is lost regarding memory layout etc, so it's not the best source for generating code.

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#23
post #22
post #2

If we would write some code in rust, compile it to, for example, x86_64. And then de-compile it to C. It would be perfectly memory-safe C code, right?

As Rust is llvm based, you don't need to compile it to C. Just write a backend that translates LLVM IR to C instead of x86_64. The IR is very C looking, it's probably overly complex. Compiling down to asm, lot of information is lost regarding memory layout etc, so it's not the best source for generating code.

https://github.com/JuliaComputingOSS/llvm-cbe

edit: you also have mrustc as a Rust to C compiler outright.

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#24
post #7

How about this for an idea: a decompiler that uses Machine Learning to name the decompiled variables and functions. Would be nice even if it worked only sometimes.

Something very similar: a "decompiler" that decompiles minified javascript and guesses variables and functions: http://www.jsnice.org/

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#25
post #10
post #7

How about this for an idea: a decompiler that uses Machine Learning to name the decompiled variables and functions. Would be nice even if it worked only sometimes.

It's also something that could be somewhat easy to get a lot of learning material for.

Yes, but the problem is learning through the graph data. I.e., it is not a well-structured problem like an image which will always have a certain size in pixels. Coming from a compiler background I am genuinely excited about the research on learning how to label nodes and edges in graphs, but I know little about the challenges in the ML side to bring this kind of technology into reality.

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#27
post #12

The main website seems to be dead, and there are no examples of its output.

A shame. My understanding is this was state of the art, for a free and open source decompiler. Of course, times change and AFAICT Ghidra has taken up that mantle.

I'm surprised to hear that, I thought retdec was pretty well regarded.

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#28
post #22
post #2

If we would write some code in rust, compile it to, for example, x86_64. And then de-compile it to C. It would be perfectly memory-safe C code, right?

As Rust is llvm based, you don't need to compile it to C. Just write a backend that translates LLVM IR to C instead of x86_64. The IR is very C looking, it's probably overly complex. Compiling down to asm, lot of information is lost regarding memory layout etc, so it's not the best source for generating code.

Hey, LLVM to C is what Rellic does! https://github.com/lifting-bits/rellic

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#29
post #27
post #12

Earlier quoted context omitted.

A shame. My understanding is this was state of the art, for a free and open source decompiler. Of course, times change and AFAICT Ghidra has taken up that mantle.

I'm surprised to hear that, I thought retdec was pretty well regarded.

Good point. I don't mean this as a slight against retdec. Simply, retdec was proprietary for quite a while, and it escaped my mind.

retdec haven't tagged (or built) a release in a couple years, unfortunately, but there is recent activity on their repo.

Re: Snowman native code to C/C++ decompiler for x86/x86_64/ARM

#30
post #7

How about this for an idea: a decompiler that uses Machine Learning to name the decompiled variables and functions. Would be nice even if it worked only sometimes.

It's certainly possible - Compile all the C projects on github with `gcc -O0`. Map statements, blocks, or functions to ASM output. Put everything in a giant SQL. Repeat for all of gcc's compiler flags.

Wait, did I say it was possible? I'm curious what a neural netted compiler would produce. Probably your average CRUD software.

Post reply on HN