reloc_apply.h (1154B)
1 #ifndef KIT_OBJ_RELOC_APPLY_H 2 #define KIT_OBJ_RELOC_APPLY_H 3 4 #include "core/core.h" 5 #include "obj/obj.h" 6 7 /* The single public byte-patcher entry: patch the relocation site at P_bytes 8 * given the resolved addresses (S, P) and addend (A). Shared verbatim by the 9 * static linker, JIT linker, assembler, and emulator guest loader ("one 10 * encoder, three loaders", doc/OBJ.md). Defined in src/link/link_reloc_apply.c 11 * — it dispatches arch-neutral kinds to reloc_apply_neutral() (below) and 12 * instruction-immediate kinds to the per-arch LinkArchDesc.reloc_apply_insn, 13 * the latter needing the link layer's link_arch_desc_for(). See 14 * doc/plan/RELOC.md (WS-C). */ 15 void link_reloc_apply(Compiler*, RelocKind, u8* P_bytes, u64 S, i64 A, u64 P); 16 17 /* Apply an arch-neutral (data-word / ULEB128) relocation kind. Returns 1 if 18 * `k` is a neutral kind it patched, 0 otherwise (the dispatcher then consults 19 * the per-arch instruction encoders). Pure obj-core: no link/arch dependency, 20 * so it never touches `c` except to panic on the dynamic-only R_X64_COPY. */ 21 int reloc_apply_neutral(Compiler*, RelocKind, u8* P_bytes, u64 S, i64 A, u64 P); 22 23 #endif