package ocaml-base-compiler

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Name : sig ... end

Recording sections written to a bytecode executable file

type toc_writer
val init_record : out_channel -> toc_writer

Start recording sections from the current position in out_channel

val record : toc_writer -> Name.t -> unit

Record the current position in the out_channel as the end of the section with the given name.

val write_toc_and_trailer : toc_writer -> unit

Write the table of contents and the standard trailer for bytecode executable files

Reading sections from a bytecode executable file

type section_entry = {
  1. name : Name.t;
    (*

    name of the section.

    *)
  2. pos : int;
    (*

    byte offset at which the section starts.

    *)
  3. len : int;
    (*

    length of the section.

    *)
}
type section_table
exception Bad_magic_number
val read_toc : in_channel -> section_table

Read the table of sections from a bytecode executable. Raise Bad_magic_number if magic number doesn't match

val seek_section : section_table -> in_channel -> Name.t -> int

Position the input channel at the beginning of the section named "name", and return the length of that section. Raise Not_found if no such section exists.

val read_section_string : section_table -> in_channel -> Name.t -> string

Return the contents of a section, as a string.

val read_section_struct : section_table -> in_channel -> Name.t -> 'a

Return the contents of a section, as marshalled data.

val all : section_table -> section_entry list

Returns all section_entry from a section_table in increasing position order.

val pos_first_section : section_table -> int

Return the position of the beginning of the first section