How to make REA use Kuna as decompiler when Ghidra runs headless
REA 3.1.0 uses a Ghidra provider, but Kuna's OSGi extension does not load in headless Ghidra (bundle resolution fails outside the CodeBrowser), so
rea decompilestill uses stock Ghidra. How can I get REA to decompile with Kuna instead, and what is the officially supported integration path?Originally asked on GitHub: https://github.com/morluto/rea/issues/1957
3 answers
Status: fixed. Kuna support shipped in REA through #3832, #3854 and #3855: readiness/
rea doctorchecks, a project cache, and function, pseudocode, and assembly retrieval via the Kuna CLI (kuna decompile-project). The merged provider takes ELF and Mach-O files; Windows PE is refused for now. The Kuna author stated in the thread that the intended integration path is the CLI, not a Ghidra provider swap.Until the native provider existed, one headless prototype worked with Ghidra 12.1.2, Kuna v1.818 and REA 3.1.0: swap Kuna's
kuna_ghidrabinary into the headless Ghidra decompiler directory so REA's existing Ghidra provider calls Kuna underneath.bashD=$GHIDRA_INSTALL_DIR/Ghidra/Features/Decompiler/os/linux_x86_64 cp $D/decompile $D/decompile.ghidra.orig # back up cp <KunaDecompiler>/os/linux_x86_64/kuna_ghidra $D/decompile chmod +x $D/decompile export KUNA_SPECS=/path/to/kuna-specs/specsThen
rea decompile /bin/ls 0x104740returned Kuna output throughprocedure_pseudo_code, with a/* Kuna v1.818 */marker. Rollback is copyingdecompile.ghidra.origback overdecompile. Limitations confirmed in the thread: the swap is install-wide, REA still reportsprovider: ghidra, version: 12.1.2, and only one function on one binary was verified. The Kuna author recommended the CLI workflowkuna decompile-project ./my_binary --jobs 10(also spelleddecompiler-project) as the intended path. General advice: replacing a binary inside a tool install runs third-party code on everything that install decompiles, so keep the backup; now that the native provider is merged, prefer it over the swap.Did this work for you?What @thotganesh tried on GitHub (Worked)
Replaced Ghidra 12.1.2's headless
decompilebinary with Kuna'skuna_ghidrabinary and setKUNA_SPECS, so REA's Ghidra provider ran Kuna.rea decompilereturned Kuna pseudocode, but the swap was install-wide and REA still reported the Ghidra provider identity.Source: https://github.com/morluto/rea/issues/1957#issuecomment-6148514202 (opens external site)
Did this work for you?What @CassieFox23 tried on GitHub (Outcome unclear)
Benchmarked
kuna decompile-projectanddecompile-all --jobs 8against Ghidra on two Windows binaries. Kuna was faster on a 3.2 MB file (23.68 s vs 99.93 s for all functions), but Ghidra hit the memory/time cap on a 10 MB file, function counts differed, and C output quality was not read. First results only.Source: https://github.com/morluto/rea/issues/1957#issuecomment-6185035952 (opens external site)
Did this work for you?