fold/docs/research/vendor-library-study-2026-05-31.md

4.4 KiB

Vendor Library Decision and Reading List

Date: 2026-05-31; updated after Ghidra x86/x86-64 SLEIGH and P-Code summary work. Purpose: record Fold's vendor posture without duplicating upstream manuals.

Decision

Fold should keep a small vendor surface:

Status Library Fold role Rationale
Active Ghidra/SLEIGH Binary instruction semantics, raw/high P-Code, SSA-style def-use Already integrated; best fit for binary semantics feeding Fold/Z3.
Candidate LIEF Binary metadata for ELF/PE/Mach-O Complements Ghidra by replacing fragile r2 JSON metadata queries; not a lifter.
Candidate Souffle Datalog facts over Fold MidIR Useful after stable function/block/op/value IDs exist.
Deferred RetDec Binary-to-LLVM comparison lane Revisit only if Ghidra misses a fixture class that LLVM lifting preserves.
Deferred Remill/McSema Instruction-accurate LLVM lifting Powerful but heavy; overlaps Ghidra and adds CFG/toolchain cost.
Deferred PhASAR IFDS/IDE analyses over LLVM IR Useful only after LLVM IR is a first-class Fold input.
Deferred Crab/Clam Numeric invariants over LLVM/Fold IR Revisit only for a concrete loop/range false-positive class.
Track only LLVM CIR/MLIR Future source mid-level IR Follow through Fold's LLVM pin; do not vendor separately.

External reading

Ghidra/SLEIGH/P-Code

Use these as the source of truth for binary semantics:

Fold-specific rule: Ghidra owns binary semantics. Do not decompile to C and route binary evidence through source detectors.

LIEF

Use these for metadata parsing, not instruction semantics:

Fold-specific rule: LIEF can replace/supplement r2 metadata for sections, symbols, imports, exports, entry points, and format details. It does not replace Ghidra/P-Code.

Souffle

Use these once MidIR/fact IDs are stable:

Fold-specific rule: start standalone with TSV facts and .dl rules. Use generated C++ only after the relations prove useful and bounded.

Deferred lanes

Keep these as reading references only:

Do not add manifests, Meson flags, or fetch-script entries for deferred lanes until a reproducible fixture demonstrates need.

Revisit triggers

Trigger Candidate to revisit
r2 metadata hangs or inconsistent JSON blocks binary reporting LIEF
Cross-TU taint/reachability outgrows native graph code Souffle
Ghidra P-Code misses a required binary semantic class RetDec or Remill/McSema comparison prototype
Native range summaries cannot close a concrete OOB/division false positive Crab/Clam
Fold adopts LLVM IR as a committed source/binary input PhASAR
Installed LLVM exposes stable CIR/MLIR for C/C++ CIR/MLIR mapping study