Skip to main content

build_plan

Function build_plan 

Source
pub fn build_plan(
    findings: &[Finding],
    min_confidence: Confidence,
    arch: Arch,
    patcher: &mut dyn BytePatcher,
) -> Result<PatchPlan>
Expand description

Construct a PatchPlan from a slice of findings.

Each finding is gated by:

  1. is_actionable() — only opaque / dead / constant kinds.
  2. confidence <= min_confidence (using the Ord semantics in r2smt-core, which place High lowest).
  3. The presence of an instruction-size measurement (the patcher needs to know how many bytes to preserve).

arch selects the rewrite ISA: x86 / x86_64 use the legacy jcc / setcc / cmovcc strategies; AArch64 / AArch32 use the ARM b.<cond> / b<cond> / cbz / cbnz / tbz / tbnz strategies (NOP-out for always-false, replace with b <target> for always-true). ARM setcc / cmovcc analogs (cset / csel) are deferred and surface as “no rewrite strategy” skips.

The function never writes to the binary. Callers use apply_plan to commit operations.

§Errors

Returns the first failure produced by the BytePatcher while measuring instruction size or assembling replacement bytes.