package bap-std

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The interface for custom backends.

This is an OCaml interface for defining custom disassembling backends in pure OCaml. An alternative interface in C++ can be found at disasm.hpp and disasm.h.

The interface is pretty low-level and mimics one-to-one the existing C interface between OCaml and the C/C++ disassemblers backends, which, in turn, are optimized for performance.

The Basic.custom function wraps the backend interface and enables seamless integration with the existing Basic.t interface. To make the custom backend available for your encoding, use Basic.register encoding function to register a constructor that uses Basic.custom, e.g.,

let () = Basic.register encoding @@ fun target ->
  let dis = create_custom target in
  Ok (Basic.custom ?target encoding backend)

where create_custom is a user function that creates the custom backend and target contains the detailed information about the target system.

The Basic.lookup function could be used then to lazily create the disassembler for the given encoding, target pair. The constructor will be called only once for each pair.

  • since 2.2.0
type predicate =
  1. | Is_true
  2. | Is_invalid
  3. | Is_return
  4. | Is_call
  5. | Is_barrier
  6. | Is_terminator
  7. | Is_branch
  8. | Is_indirect_branch
  9. | Is_conditional_branch
  10. | Is_unconditional_branch
  11. | May_affect_control_flow
  12. | May_store
  13. | May_load

possible semantic predicates for instructions

val compare_predicate : predicate -> predicate -> int
val sexp_of_predicate : predicate -> Sexplib0.Sexp.t
val predicate_of_sexp : Sexplib0.Sexp.t -> predicate
type op =
  1. | Reg
    (*

    a register

    *)
  2. | Imm
    (*

    an integer immediate

    *)
  3. | Fmm
    (*

    a floating-point immediate

    *)
  4. | Insn
    (*

    a sub-instruction

    *)

operand types

val compare_op : op -> op -> int
val sexp_of_op : op -> Sexplib0.Sexp.t
val op_of_sexp : Sexplib0.Sexp.t -> op
module type S = sig ... end

The backend interface.

OCaml

Innovation. Community. Security.