coronium: a hypothetical chemical element thought to have been detected in the solar corona whose spectrum showed a number of lines later identified as belonging to iron, nickel, and other elements highly ionized at the extreme solar temperatures.
Coronium is the ghidra disassembler + decompiler in library form. Made suitable
for use in c++ projects. Usage is as easy as g++ <your-code>.cpp $(pkg-config
--cflags --libs coronium) -o output>
. None of the Ghidra source code for the
decompiler has been modified. The purpose of this project is to enable
installation of the ghidra c++ source for use as a c++ library. To that end, a
convenience header coronium.hpp
is provided which holds helper function(s) to
simplify interacting with the ghidra library code.
mkdir build
cd build
cmake .. # (alt.) cmake .. -DSLA_LOCATION=<your-directory>
make -j$(nproc)
sudo make cpus # build and install .sla files. Optional if you plan to use SLA_DIR.
sudo make install # install headers + lib.
sudo ldconfig # make linker recognize lib on path.
coronium installs: slgh-compile
(i.e., the sleigh compiler), coronium
header files,
libcoronium.so
, and optionally a build of all the cpu spec files. The cpu specification
files (.sla
files) will be installed in /var/coronium
(default location –can change
this during install).
However, if you decide to change/move the cpu directory, just be sure to set the
environment variable SLA_DIR
to this new location. That way coronium will still be able
to find the sla cpu definitions. The environment variable SLA_DIR
is given precedence
over whatever path was decided during the initial install.
.sla files are searched for recursively inside whatever folder SLA_DIR points to (or wherever you specified SLA_LOCATION to point to at compile time). The subfolder hierarchy does not matter. You could point SLA_DIR to your top level ghidra folder and coronium will search recursively to find the correct .sla file.
After installation compile and run the file test/example_one/example_one.cpp
to make
sure everything is working. If you face a problem create an issue. One issue you may face
is if you direct SLA_DIR
to an older ghidra installation that uses a different sleigh
version. To find out, open one of the compiled .sla files inside your ghidra install and
note the field <sleigh version
at the top and compare that with an .sla file compiled
using this project. If there is a mismatch, you will need to recompile the ghidra
installed .slaspec files using the sleigh compiler but by this project slgh-compile
.
After install you can link to targets with headers such as
/* main.cpp */
#include <coronium/coronium.hpp>
#include <coronium/types.h>
#include <coronium/loadimage.hh>
#include <coronium/sleigh.hh>
#include <coronium/emulate.hh>
/* ... */
via the cmdline – g++ main.cpp -lcoronium -o main
For the bfd related headers to be installed you will need libbfd
, which you can get with
apt install binutils-dev
This dependency is optional.
The convenience script update_ghidra_src.py
can be used to ensure that
coronium uses the latest and greatest source code directly from the official
ghidra github repo. Just run ./update_ghidra_src.py
. If this is desirable,
you will need to run the script prior the install instructions given above.
However, by updating you do risk the chance of being unable to build coronium. There is no guarantee that the cutting edge ghidra source will always compile. So far this has yet to be an issue. Regardless, only the ghidra source present in this repo is guaranteed to compile.