Module Bap_c_data

C Data model.

This module defines abstractions for C values.

A value is backed by a datum - a sequence of bits that represents the value. This module also defines models for integer representation.

type model32 = [
  1. | `LP32
  2. | `ILP32
]

models for 32 bit systems

type model64 = [
  1. | `ILP64
  2. | `LLP64
  3. | `LP64
]

models for 64 bit systems

type model = [
  1. | model32
  2. | model64
]

The following table summarize all models of integer representation.

       LP32	 ILP32	 ILP64	 LLP64	 LP64
 char	  8	    8	     8	     8	    8
 short	 16	   16	    16	    16	   16
 int	 16	   32	    64	    32	   32
 long	 32	   32	    64	    32	   64
 addr    32	   32	    64	    64	   64
type value =
  1. | Top
    (*

    any possible value

    *)
  2. | Set of Bap.Std.word list
    (*

    one of the specified, Set [] is bot

    *)

A value lattice.

val bin_shape_value : Core_kernel.Bin_prot.Shape.t
val bin_size_value : value Core_kernel.Bin_prot.Size.sizer
val bin_write_value : value Core_kernel.Bin_prot.Write.writer
val bin_writer_value : value Core_kernel.Bin_prot.Type_class.writer
val bin_read_value : value Core_kernel.Bin_prot.Read.reader
val __bin_read_value__ : (int -> value) Core_kernel.Bin_prot.Read.reader
val bin_reader_value : value Core_kernel.Bin_prot.Type_class.reader
val bin_value : value Core_kernel.Bin_prot.Type_class.t
val compare_value : value -> value -> int
val sexp_of_value : value -> Ppx_sexp_conv_lib.Sexp.t
val value_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> value
type 'd obj =
  1. | Basic of Bap_c_type.basic
    (*

    A value of a basic type

    *)
  2. | Field of string * 'd
    (*

    A struct or union field

    *)
  3. | Undef
    (*

    Undefined data (padding or code)

    *)
  4. | Union of 'd list
    (*

    Union of values

    *)

A C Object representation.

The type is parameterized with the object layout representation to enable the recursive definition of the generalized layout type.

  • since 2.5.0
val bin_shape_obj : Core_kernel.Bin_prot.Shape.t -> Core_kernel.Bin_prot.Shape.t
val bin_size_obj : 'd Core_kernel.Bin_prot.Size.sizer -> 'd obj Core_kernel.Bin_prot.Size.sizer
val bin_write_obj : 'd Core_kernel.Bin_prot.Write.writer -> 'd obj Core_kernel.Bin_prot.Write.writer
val bin_writer_obj : 'd Core_kernel.Bin_prot.Type_class.writer -> 'd obj Core_kernel.Bin_prot.Type_class.writer
val bin_read_obj : 'd Core_kernel.Bin_prot.Read.reader -> 'd obj Core_kernel.Bin_prot.Read.reader
val __bin_read_obj__ : 'd Core_kernel.Bin_prot.Read.reader -> (int -> 'd obj) Core_kernel.Bin_prot.Read.reader
val bin_reader_obj : 'd Core_kernel.Bin_prot.Type_class.reader -> 'd obj Core_kernel.Bin_prot.Type_class.reader
val bin_obj : 'd Core_kernel.Bin_prot.Type_class.t -> 'd obj Core_kernel.Bin_prot.Type_class.t
val compare_obj : ('d -> 'd -> int) -> 'd obj -> 'd obj -> int
val sexp_of_obj : ('d -> Ppx_sexp_conv_lib.Sexp.t) -> 'd obj -> Ppx_sexp_conv_lib.Sexp.t
val obj_of_sexp : (Ppx_sexp_conv_lib.Sexp.t -> 'd) -> Ppx_sexp_conv_lib.Sexp.t -> 'd obj
type ('d, 's) datum =
  1. | Imm of 's * 'd
    (*

    Imm (size, value)

    *)
  2. | Seq of ('d, 's) datum list
    (*

    Seq [t1; ... ;tN]

    *)
  3. | Ptr of ('d, 's) datum
    (*

    Ptr datum

    *)

abstraction of a С datum.

The datum is a sequence of bits that represents a C object. We abstract datum as either an immediate value of the given size, or a sequence of data, or a pointer to a datum.

  • since 2.5.0
val bin_shape_datum : Core_kernel.Bin_prot.Shape.t -> Core_kernel.Bin_prot.Shape.t -> Core_kernel.Bin_prot.Shape.t
val bin_size_datum : 'd Core_kernel.Bin_prot.Size.sizer -> 's Core_kernel.Bin_prot.Size.sizer -> ('d, 's) datum Core_kernel.Bin_prot.Size.sizer
val bin_write_datum : 'd Core_kernel.Bin_prot.Write.writer -> 's Core_kernel.Bin_prot.Write.writer -> ('d, 's) datum Core_kernel.Bin_prot.Write.writer
val bin_writer_datum : 'd Core_kernel.Bin_prot.Type_class.writer -> 's Core_kernel.Bin_prot.Type_class.writer -> ('d, 's) datum Core_kernel.Bin_prot.Type_class.writer
val bin_read_datum : 'd Core_kernel.Bin_prot.Read.reader -> 's Core_kernel.Bin_prot.Read.reader -> ('d, 's) datum Core_kernel.Bin_prot.Read.reader
val __bin_read_datum__ : 'd Core_kernel.Bin_prot.Read.reader -> 's Core_kernel.Bin_prot.Read.reader -> (int -> ('d, 's) datum) Core_kernel.Bin_prot.Read.reader
val bin_reader_datum : 'd Core_kernel.Bin_prot.Type_class.reader -> 's Core_kernel.Bin_prot.Type_class.reader -> ('d, 's) datum Core_kernel.Bin_prot.Type_class.reader
val bin_datum : 'd Core_kernel.Bin_prot.Type_class.t -> 's Core_kernel.Bin_prot.Type_class.t -> ('d, 's) datum Core_kernel.Bin_prot.Type_class.t
val compare_datum : ('d -> 'd -> int) -> ('s -> 's -> int) -> ('d, 's) datum -> ('d, 's) datum -> int
val sexp_of_datum : ('d -> Ppx_sexp_conv_lib.Sexp.t) -> ('s -> Ppx_sexp_conv_lib.Sexp.t) -> ('d, 's) datum -> Ppx_sexp_conv_lib.Sexp.t
val datum_of_sexp : (Ppx_sexp_conv_lib.Sexp.t -> 'd) -> (Ppx_sexp_conv_lib.Sexp.t -> 's) -> Ppx_sexp_conv_lib.Sexp.t -> ('d, 's) datum
type layout = {
  1. layout : (layout obj, int) datum;
}

Describes C object's layout.

val bin_shape_layout : Core_kernel.Bin_prot.Shape.t
val bin_size_layout : layout Core_kernel.Bin_prot.Size.sizer
val bin_write_layout : layout Core_kernel.Bin_prot.Write.writer
val bin_writer_layout : layout Core_kernel.Bin_prot.Type_class.writer
val bin_read_layout : layout Core_kernel.Bin_prot.Read.reader
val __bin_read_layout__ : (int -> layout) Core_kernel.Bin_prot.Read.reader
val bin_reader_layout : layout Core_kernel.Bin_prot.Type_class.reader
val bin_layout : layout Core_kernel.Bin_prot.Type_class.t
val compare_layout : layout -> layout -> int
val sexp_of_layout : layout -> Ppx_sexp_conv_lib.Sexp.t
val layout_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> layout

The datum that uses value lattice for object representation.

include Core_kernel.Bin_prot.Binable.S with type t := t
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot.Read.reader
val bin_shape_t : Bin_prot.Shape.t
val bin_writer_t : t Bin_prot.Type_class.writer
val bin_reader_t : t Bin_prot.Type_class.reader
val bin_t : t Bin_prot.Type_class.t
val compare : t -> t -> int
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
val t_of_sexp : Sexplib0__.Sexp.t -> t
val sexp_of_t : t -> Sexplib0__.Sexp.t
val pp : Stdlib.Format.formatter -> t -> unit

pp ppf datum prints the datum in a human-readable form.

  • since 2.5.0
val pp_layout : Stdlib.Format.formatter -> layout -> unit

pp_layout ppf layout outputs layout in a human-readable form.

  • since 2.5.0