Skip to content
Deep ghidra decompiler integration for radare2
C++ CMake C
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets Add Logo Aug 23, 2019
cmake More Windows Fixes Sep 2, 2019
cutter-plugin Emit Errors in JSON and show in Cutter (Fix #29) Sep 8, 2019
dist Add Debian packaging scripts Sep 20, 2019
ghidra Update Ghidra for #39 Sep 20, 2019
src Fix pdgo Sep 9, 2019
third-party Basic XML Output Parsing Aug 26, 2019
.gitignore Initial Commit Jul 12, 2019
.gitmodules Basic XML Output Parsing Aug 26, 2019
.travis.yml Update radare2 URLs Sep 18, 2019
CMakeLists.txt Some Fixes for Windows Sep 2, 2019
COPYING Add Basic Core Plugin Jul 12, 2019
README.md Fix LGPL Note Sep 18, 2019

README.md

r2ghidra-dec logo

r2ghidra-dec

Build Status

This is an integration of the Ghidra decompiler for radare2. It is solely based on the decompiler part of Ghidra, which is written entirely in C++, so Ghidra itself is not required at all and the plugin can be built self-contained.

Installing

An r2pm package is available that can easily be installed like:

r2pm -i r2ghidra-dec

This package only installs the radare2 part. To use r2ghidra from cutter, either use a provided pre-built release starting with Cutter 1.9, which bundles r2ghidra, or follow the build instructions below.

Usage

Usage: pdg   # Native Ghidra decompiler plugin
| pdg           # Decompile current function with the Ghidra decompiler
| pdgd          # Dump the debug XML Dump
| pdgx          # Dump the XML of the current decompiled function
| pdgj          # Dump the current decompiled function as JSON
| pdgo          # Decompile current function side by side with offsets
| pdgs          # Display loaded Sleigh Languages
| pdg*          # Decompiled code is returned to r2 as comment

The following config vars (for the e command) can be used to adjust r2ghidra's behavior:

    r2ghidra.cmt.cpp: C++ comment style
 r2ghidra.cmt.indent: Comment indent
     r2ghidra.indent: Indent increment
       r2ghidra.lang: Custom Sleigh ID to override auto-detection (e.g. x86:LE:32:default)
    r2ghidra.linelen: Max line length
   r2ghidra.nl.brace: Newline before opening '{'
    r2ghidra.nl.else: Newline before else
 r2ghidra.sleighhome: SLEIGHHOME

Here, r2ghidra.sleighhome must point to a directory containing the *.sla, *.lspec, ... files for the architectures that should supported by the decompiler. This is however set up automatically when using the r2pm package or installing as shown below.

Building

First, make sure the submodule contained within this repository is fetched and up to date:

git submodule init
git submodule update

Then, the radare2 plugin can be built and installed as follows:

mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
make
make install

Here, set the CMAKE_INSTALL_PREFIX to a location where radare2 can load the plugin from. The install step is necessary for the plugin to work because it includes installing the necessary Sleigh files.

To also build the Cutter plugin, pass -DBUILD_CUTTER_PLUGIN=ON -DCUTTER_SOURCE_DIR=/path/to/cutter/source to cmake.

License

Please note that this plugin is available under the LGPLv3, which is more strict than Ghidra's license!

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.

You can’t perform that action at this time.