Skip to content

How it works

Basilisk is a workspace of focused Rust crates. Dependencies point one way: format parsers know nothing about programs, the SLEIGH crates know nothing about programs, and nothing below the interface depends on it. It ships as a single binary.

Binary file

Import
loaders, formats

Language
decode, lift

Analysis
auto-analysis

Decompile
in parallel

Program
database

Binary file

Import
loaders, formats

Language
decode, lift

Analysis
auto-analysis

Decompile
in parallel

Program
database

From a binary file to decompiled C (docs/PLAN.md, Data flow)
  1. Import picks a loader and a language through Ghidra’s .opinion files, maps sections into program memory, applies relocations and creates symbols and entry points.
  2. Language loads the compiled SLEIGH (.sla) for the processor, compiling the .slaspec when needed, then decodes instructions and lifts them to p-code on demand. This step exists today.
  3. Analysis schedules analyzers by priority over the addresses that changed: disassembly follows flow, and functions and references are created.
  4. Decompile runs per function, in parallel; the result is C text plus tokens tied back to addresses.
  5. Store: everything above writes to the program database through transactions.

Crates with a solid green border exist today; dashed ones are planned; the decompiler’s crates, marked in ember, are being written now (four of them exist). Dependencies point down only.

APPLICATION

Basilisk

bk-ui

bk-plugin

bk-headless

ANALYSIS

bk-analysis

bk-analyzers-*

bk-disasm

DECOMPILER

bk-decomp

bk-decomp-*

bk-cspec

PROGRAM

bk-program

bk-datatypes

bk-store

IMPORT

bk-loader

bk-elf

bk-pe, bk-macho

bk-bin

LANGUAGE

bk-sleigh

bk-sleigh-compiler

bk-sla

bk-sleigh-syntax

bk-lang

FOUNDATION

bk-pcode

bk-marshal

bk-core

APPLICATION

Basilisk

bk-ui

bk-plugin

bk-headless

ANALYSIS

bk-analysis

bk-analyzers-*

bk-disasm

DECOMPILER

bk-decomp

bk-decomp-*

bk-cspec

PROGRAM

bk-program

bk-datatypes

bk-store

IMPORT

bk-loader

bk-elf

bk-pe, bk-macho

bk-bin

LANGUAGE

bk-sleigh

bk-sleigh-compiler

bk-sla

bk-sleigh-syntax

bk-lang

FOUNDATION

bk-pcode

bk-marshal

bk-core

Basilisk's crates by layer; each layer depends only on the layers below it (docs/PLAN.md, Architecture)

SLEIGH is Ghidra’s language for describing instruction sets: how bytes decode into instructions, how they print, and what each one does as p-code. Basilisk reads Ghidra’s SLEIGH specifications unchanged. Both the compiler and the runtime exist today and equal Ghidra’s for all 150 specifications. More: SLEIGH.

P-code is a small, processor-independent set of operations — copy, load, store, arithmetic, branches, calls — over varnodes (an address space, an offset and a size). Every instruction lifts to a short p-code sequence, and everything after the language layer, the emulator and the decompiler included, works on p-code alone. More: P-code.

See The decompiler: p-code is built into a control-flow graph, put into SSA form, simplified by rules, given types and variables, and structured into C. It is being ported now (milestone M3).

Everything Basilisk learns about a binary — memory, code units, symbols, references, functions, types, comments — lives in a program database written through transactions with undo. Its storage engine is being chosen by experiment (ADR-003); the program model is milestone M4.

Each part is run against Ghidra on the same input and the outputs are compared. More: How results are checked.