Replies: 3 comments 4 replies
-
|
Connected #2991 |
Beta Was this translation helpful? Give feedback.
-
|
Hi! Nice idea. I'm the author of the linked blog post :) I'm happy to see someone is working on this.
I'm just guessing here, but the current implementation of RULECOMPILE is not really production quality - it's very easy to crash the decompiler process with relatively small mistakes (like by referencing an undefined node). Perhaps it was developed as an experiment but never reached a production maturity? The second reason is that (looking from outside) Ghidra decompiler is undermaintained/underfunded/undermanned. Take a look at any PR aimed at improving the decompiler, for example those two recent PRs. Or the whole contribution history of @LukeSerne. Notice two patterns:
My point being, decompiler PRs take forever to review. Having said that,
Yes, the ability to extend and improve the decompiler output dynamically is one of my most wanted Ghidra features :). I work with obfuscated code a lot and being able to leverage Ghidra core instead of one-shot scripts would be great. Right now Ghidra is a bit limited here, because we can control the decompiler output only via annotations, attributes, variable types etc, but never directly.
Having it merged is one. Do I understand correctly that you plan to implement this feature as a large PR to Ghidra? CONTRIBUTING.md manages the expectations here, and mentions that large changes may take a while to review (paraphrasing). I think the chances of upstreaming your feature will raise significantly if you manage to minimize your changes to the core, and implement most of your project as a Ghidra plugin. But you need at least some hook API in the decompiler, so I'm not sure how realistic is that. Good luck! |
Beta Was this translation helpful? Give feedback.
-
|
I think quite a few decompiler issues can be resolved / mitigated if the interface of the decompiler binary is changed to operate purely on PCODE. In that model, unoptimised ("low") pcode, goes into the decompiler, and optimised ("high") pcode comes out. Then, the translation of that high pcode into C-like pseudocode can be done in Java (or leave it in the decompiler and have the Java make two calls to the decompiler - one to optimise the pcode, and one to transform pcode into C). This has several major benefits:
The only major drawback is that it seems like this requires quite a lot of changes, which will stay in PR review forever unless the Ghidra team indicates that they also want to change the interface of the decompiler. It might be hard to maintain such a PR for a long time, since it will probably easily lead to merge conflicts if the upstream files are changed. What do other people think about this idea? Do you think it's a good idea? Do you have a suggestion to improve it? Am I missing something that makes this harder? Please let me know! On a positive note, we got 3 decompiler commits this week, which is more than we've had in a long time 🙂 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Duplicate of #8742 (didn't know about gh "discussions" feature)
I am working on a project to implement P-Code graph rewriting in Ghidra, specifically to support "macro folding" (collapsing P-Code patterns into simplified forms).
My current design concept is similar to the existing
RULECOMPILEfeature (https://msm.lt/re/ghidra/rulecompile/#rulecompile), but with two major extensions:I would like to gather some community feedback and have a few specific questions for the maintainers:
RULECOMPILEfunctionality disabled/unmaintained? Were there fundamental performance or architectural issues discovered during its development?I would appreciate any opinions, architectural advice, or warnings about potential "blind spots" in this approach.
Any thoughts, war stories, or pointers are very welcome!
Beta Was this translation helpful? Give feedback.
All reactions