jon.recoil.org

Module Asm_directives.Directive

module Constant : sig ... end
module Constant_with_width : sig ... end
type thing_after_label = private
  1. | Code
  2. | Machine_width_data
type label_or_symbol = private
  1. | Label of Asm_label.t
  2. | Symbol of Asm_symbol.t
type comment = private string
type reloc_type =
  1. | R_X86_64_PLT32
type t =
  1. | Align of {
    1. bytes : int;
      (*

      The number of bytes to align to. This will be taken log2 by the emitter on Arm and macOS platforms.

      *)
    2. fill : align_padding;
      (*

      The fill flag controls whether the binary emitter emits NOP instructions or null bytes.

      *)
    }
  2. | Bytes of {
    1. str : string;
    2. comment : string option;
    }
  3. | Cfi_adjust_cfa_offset of int
  4. | Cfi_def_cfa_offset of int
  5. | Cfi_endproc
  6. | Cfi_offset of {
    1. reg : int;
    2. offset : int;
    }
  7. | Cfi_startproc
  8. | Cfi_remember_state
  9. | Cfi_restore_state
  10. | Cfi_def_cfa_register of string
  11. | Comment of comment
  12. | Const of {
    1. constant : Constant_with_width.t;
    2. comment : string option;
    }
  13. | Direct_assignment of string * Constant.t
  14. | File of {
    1. file_num : int option;
    2. filename : string;
    }
  15. | Global of Asm_symbol.t
  16. | Indirect_symbol of Asm_symbol.t
  17. | Loc of {
    1. file_num : int;
    2. line : int;
    3. col : int;
    4. discriminator : int option;
    }
  18. | New_label of label_or_symbol * thing_after_label
  19. | New_line
  20. | Private_extern of Asm_symbol.t
  21. | Section of Asm_section.t * [ `First_occurrence | `Not_first_occurrence ]
  22. | Size of Asm_symbol.t * Constant.t
  23. | Sleb128 of {
    1. constant : Constant.t;
    2. comment : string option;
    }
  24. | Space of {
    1. bytes : int;
    }
  25. | Type of label_or_symbol * symbol_type
  26. | Uleb128 of {
    1. constant : Constant.t;
    2. comment : string option;
    }
  27. | Protected of Asm_symbol.t
  28. | Hidden of Asm_symbol.t
  29. | Weak of Asm_symbol.t
  30. | External of Asm_symbol.t
  31. | Reloc of {
    1. offset : Constant.t;
    2. name : reloc_type;
    3. target_symbol : Asm_symbol.t;
    4. addend : int64;
    }

Internal representation of directives. Only needed if writing a custom assembler or printer instead of using print, below. Symbols that occur in values of type t are encoded as strings and have had all necessary prefixing, mangling, escaping and suffixing applied.

val print : Buffer.t -> t -> unit

Translate the given directive to textual form. This produces output suitable for either gas or MASM as appropriate.

Binary emission helpers

val increment_offset_in_bytes : t -> offset_in_bytes:int -> int

Given a directive and a current offset in bytes into some section, compute the new offset after the directive is emitted. This accounts for the size of data directives (Bytes, Const, Space, Sleb128, Uleb128) and alignment padding (Align). Directives that don't emit data return the offset unchanged.

val emit_uleb128 : Buffer.t -> int64 -> unit

Emit an unsigned LEB128 encoded value to a buffer.

val emit_sleb128 : Buffer.t -> int64 -> unit

Emit a signed LEB128 encoded value to a buffer.

val emit_int_le : Buffer.t -> width_bytes:int -> int64 -> unit

Emit a little-endian integer value of the given width to a buffer.

val map_new_label : (Asm_label.t -> Asm_label.t) -> t -> t

Replace the Asm_label.t inside a New_label (Label _, _) directive using the given function. Other directives are returned unchanged.