jon.recoil.org

Module Arm64_binary_emitter.Section_state

module Asm_label = Asm_targets.Asm_label
module Asm_section = Asm_targets.Asm_section
module Asm_symbol = Asm_targets.Asm_symbol
module Symbol = Arm64_ast.Ast.Symbol
type patch_size =
  1. | P8
  2. | P16
  3. | P32
  4. | P64
type t
val create : unit -> t
val buffer : t -> Buffer.t
val offset_in_bytes : t -> int
val set_offset_in_bytes : t -> int -> unit
val add_relocation_at_current_offset : t -> reloc_kind:Relocation.Kind.t -> unit
val add_relocation : t -> Relocation.t -> unit
val define_symbol : t -> Asm_symbol.t -> unit

Define a symbol at the current offset.

val define_label : t -> Asm_label.t -> unit

Define a label at the current offset.

val mark_global : t -> Asm_symbol.t -> unit

Mark a symbol as global (called for Global and Weak directives). Global symbols get symbol table entries in ELF.

val is_global : t -> Asm_symbol.t -> bool

Check if a symbol is explicitly global (has Global or Weak directive). File-scope symbols defined only via New_label return false.

val find_symbol_offset_in_bytes : t -> Asm_symbol.t -> int option

Find the offset of a symbol.

val find_label_offset_in_bytes : t -> Asm_label.t -> int option

Find the offset of a label.

val find_global_symbol_at : t -> int -> (Asm_symbol.t * int) option

Find a global symbol at the exact offset, if one exists.

val find_nearest_symbol_before : t -> int -> (Asm_symbol.t * int) option

Find the nearest global symbol strictly before a given offset. Returns the symbol and its offset.

val find_global_symbol_at_or_before : t -> int -> (Asm_symbol.t * int) option

Find a global symbol at the exact offset if one exists, otherwise find the nearest global symbol before the offset.

val find_target_offset_in_bytes : t -> Symbol.target -> int option

Look up a target (symbol or label).

val relocations : t -> Relocation.t list
val iter_symbols : t -> f:(Asm_symbol.t -> int -> unit) -> unit

Iterate over all defined symbols with their offsets.

val iter_labels : t -> f:(Asm_label.t -> int -> unit) -> unit

Iterate over all defined labels with their offsets.

val add_patch : t -> offset:int -> size:patch_size -> data:int64 -> unit
val contents_mut : t -> bytes
val contents : t -> string