Skip to main content

Crate binbun

Crate binbun 

Source
Expand description

The binbun engine: one loaded executable as a program database (Database), what joins the loader, the type library, control-flow recovery, lifting and decompilation.

  • analysis: an image’s seeds, what is known about its imports, the decoder for its machine, and recovery itself, computed jumps and calls resolved through the pointer slots they load or their tables (analysis::resolve); corrections: the user’s corrections of what recovery finds (code, data, functions’ bounds), as its seeds.
  • target: the image’s architecture and calling convention, as L1, lowering and the differential check need them.
  • lift: recovered functions in SSA form (L1); summary: what they do to registers and the stack, callees first; funclets: the funclets of Microsoft x64 exception handlers built into their functions’ L1.
  • decompile: the pipeline from L1 to L2 and C, with the image’s data (data, memory) and its imports’ prototypes (prototypes), and its debug information where given (debug).
  • classes: the C++ classes an image’s run-time type information shows (virtual tables, type_info objects), which name the structs that are them.
  • eval: how well recovery found the functions the file states, and how much of the code lifts.
  • references: every reference to an address, from code (calls, jumps, reads, writes, addresses taken, from L1’s constants) and from data (relocated or scanned pointers), indexed by target and by function; strings: the string literals of the image’s data, those referred to and those found by scanning.
  • calls: the call graph, paths through it (by calls, or along which a parameter’s value goes on), and call sites’ known argument values.
  • run: one function run from a named example state, the values of each C statement and machine instruction recorded.
  • profile: processor profiles, what one microarchitecture does where the architecture leaves a value undefined, for runs and verification.
  • queries: what the reading view shows beside a function’s C: its verification against L1 on demand, why its variables have their types and names, where a value comes from and goes.
  • stages: one function through every stage of decompilation (machine code, L1 after each pass, L2 after each pass, the C), each line’s instructions and change, for an IR viewer.
  • signatures: library signatures: packs made from static libraries, objects and linked files with symbols, and a binary’s functions named by matching them.
  • user: the user’s types (prototypes, globals, frame and register variables), read from C, over every other declaration.
  • [cfg]: architecture-neutral control-flow recovery: basic blocks, functions and which calls return, over any memory.
  • listing: the continuous listing of an image in the usual disassembler layout: every mapped byte as lines of role-tagged tokens over a 64-bit line space.
  • graph: graphs of a binary as disassemblers draw them: a function’s blocks and edges with their listing lines, and a layered layout with orthogonal edges for any graph of sized nodes.

Re-exports§

pub use database::Database;
pub use database::Error;
pub use database::GlobalField;

Modules§

analysis
What joins the loader, the type library and the control-flow recovery: an image’s seeds, what is known about its imports, the decoder for its machine, and the names of its addresses; computed jumps and calls resolved through the pointer slots they load or their tables (resolve).
calls
The call graph (CallGraph): which function calls which, from recovery’s control flow, and the questions asked of it (a function’s neighbourhood, the paths from one function to another), answered as lists rather than drawings of everything.
cfg
Control-flow recovery for any instruction set: basic blocks, functions, and which calls return, from a Memory and a few starting points.
classes
C++ classes from an image’s run-time type information, under the Itanium C++ ABI (§2.5 virtual tables, §2.9.5 type_info objects), ELF images of 64-bit machines (x86-64, AArch64): the program’s Classes.
corrections
The user’s corrections of what recovery found (Corrections), as the usual disassembler commands make them: code at an address (C), bytes undefined (U), data of a width or type (D, A, *), a function at an address (P), a function’s end (Edit Function) and a function deleted.
data
The image’s data for lowering and printing (globals): the objects its symbols and import slots name, the memory it maps as data and which of it the program cannot change, and its strings (ImageData).
database
One loaded executable as a program database (Database): its recovered functions, their names, the type library for its target and its imports’ prototypes, and its debug information if given; each function decompiled on demand, or every function as a stream; its cross-references and strings, built once for the whole program when first asked for; the user’s types over every other declaration (Database::set_user).
debug
Debug information as input: where a binary has DWARF or PDB (binbun_debuginfo::info), its names and types are the strongest evidence there is, asserted over the solver.
decompile
Recovered functions as C: each function’s L1 lowered to L2, structured, typed and printed, the passes on L1 and on L2 run by a pass manager per function (binbun_semantics::core::pass), with the structure check (L2’s control flow against L1’s CFG, validate::structure). Every function reads the one interface of each function of the program, found once for the whole program (callers, Callers::interfaces), so one function decompiled alone and the whole program agree; the whole program is decompiled callees first as stream hands the functions over, on worker threads as the stream goes on (stream_parallel, threads).
eval
How well recovery found an image’s functions against what the file states, the sanity of the graph it built (evaluate), and how much of the recovered code lifts (lifting).
funclets
Funclets built into their functions (Microsoft x64): the code a function’s exception handler calls with the function’s frame (__finally blocks, C++ catch blocks and unwind funclets) becomes L1 code of the function (Funclets), reached from the calls an exception unwinds through as landing pads are, so lowering gives it the function’s frame and variables. Filters are not: the runtime runs them before anything unwinds, and their expressions join the __except in L2 (crate::decompile).
graph
Graphs of a binary drawn in the usual disassembler layout, without any drawing framework:
lift
L1 for recovered functions: each block of a function decoded and lifted to L0, and what calls do from the image’s calling convention, built in SSA form (binbun_ssa). x86-64 and AArch64 images (the architecture is the image’s). An instruction without semantics that continues with the next one is lifted as its architecture’s over-approximation (lift_opaque); a control transfer without semantics fails its function.
listing
The continuous listing of an image: every mapped byte, code and data, as lines, in the usual disassembler layout, from what a [binbun::Database] knows.
manglings
Prototypes from mangled names, below every database declaration: only where the mangling fixes where each argument is.
memory
The memory of an image that the program cannot change once it is loaded (ImageMemory), which constant propagation, recovery’s pointer slots and the image’s data read; and the differential check’s memory of the image (ImageOracle).
profile
Processor profiles for runs, verification and the views: what one microarchitecture does where the architecture leaves a value undefined. A run or a verification under a profile takes its rules’ values at the sites (run::Options::profile, verify::Options::profile); without one, those values stay unknown, as the architecture says. The C never changes with a profile.
progress
How far a whole-program pass has got, for a front end to show while it runs (Progress): the functions done of those the pass works through. A Database has one (Database::progress) that its passes (the references, each pass finding what callers read) start and step.
prototypes
Declared prototypes from the type library: the Prototypes lowering and the type passes ask, answered for the functions an image imports and those it defines in their place.
queries
What the reading view shows beside a decompiled function’s C, each a query on the Database for one function: synchronous, framework free and cancel-safe (each returns owned data and keeps nothing but what the database caches), so a session can run them on its worker.
references
Cross-references: every place the program refers to an address, from code and from data, as one index built for the whole program (References).
run
Running one function from a named example state, recording the values it produces: per C statement and per machine instruction, for the C and the listing to show at their lines’ ends.
signatures
Library signatures over images: packs made from static libraries, objects and linked ELF files with symbols (make), and a binary’s functions matched against packs (match_image).
stages
One function through every stage of decompilation, for an IR viewer and as a debugging tool: stages.
strings
String literals: NUL-terminated text in the program’s data (program_data: read-only and writable sections that are not code nor what the loader or unwinder read), from two sources joined (strings):
summary
What functions do to registers and the stack (summarize), each computed after the functions it calls (callees_first) so that its calls take their callees’ effects.
target
An image’s architecture and calling convention, as each stage needs them: what calls and system calls do in L1 (x86-64 System V for ELF, Microsoft x64 for PE, AArch64 AAPCS64; through ImageEnvironment), how lowering passes arguments (convention), the setup the differential check runs a function under (setup), and how C spells the platform’s thread pointer (thread_pointer; its register is the convention’s Convention::thread_pointer).
user
The user’s types (retypes): a function’s prototype (its parameters and return value, for it and its callers), a global’s type, a frame variable’s (by function and offset) and a register variable’s (by the L1 values it is made of), and the user’s version of a synthesised struct (by its identity: it replaces the table’s layout and name), each read from C by binbun_typedb::c into one table (UserTypes) and given to decompilation as the strongest evidence there is (the user ranks above debug information): UserPrototypes answers before the type library, the manglings and debug information, and the solver takes a variable’s type as a declared bound (Reason::User).