jon.recoil.org

Module For_jit.Relocation

type t = Relocation.t
val offset_from_section_beginning : t -> int
val target_symbol : t -> Binary_emitter_intf.target
val target_symbols : t -> Binary_emitter_intf.target list

For paired relocations (e.g., SUBTRACTOR + UNSIGNED), returns all symbols. For single relocations, returns a singleton list. Used for saving relocations to files for verification.

val target_symbols_with_addends : t -> (Binary_emitter_intf.target * int) list

For paired relocations, returns all symbols with their addends. On RELA platforms (Linux ELF), addends are stored in relocations. On REL platforms (macOS), addends are encoded in instructions.

val is_got_reloc : t -> bool

Is this a GOT relocation? (JIT needs to know for GOT table building)

val is_plt_reloc : t -> bool

Is this a PLT relocation? (JIT needs to know for PLT table building)

val compute_value : t -> place_address:int64 -> lookup_target:(Binary_emitter_intf.target -> int64 option) -> read_instruction:(unit -> int32) -> (int64, string) result

Compute the value to patch given:

  • place_address: where the relocation site is in memory
  • lookup_target: resolve symbol/label -> address
  • read_instruction: read the 32-bit instruction at the relocation site (used by ARM64 to read-modify-write instruction bit fields) Returns the value to write at the relocation site, or an error.