From 09f8df9f7e1166be48cdd6b1caba0f6771dd753e Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 4 Aug 2023 21:16:34 +0300 Subject: add simple patching mechanism --- src/copyjit.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/copyjit.h') diff --git a/src/copyjit.h b/src/copyjit.h index d752144..8170204 100644 --- a/src/copyjit.h +++ b/src/copyjit.h @@ -3,12 +3,21 @@ #ifndef HMMJIT_H #define HMMJIT_H +#include + typedef struct { char *pc; char *buf; size_t size; } ctx_t; +typedef struct { + void *addr; + uintptr_t *imm; +} reloc_t; + +typedef void *(*compile_callback_t)(ctx_t *, unsigned long); + #include "../lib/op_decls.h" #include "../lib/imm_decls.h" @@ -30,6 +39,9 @@ void *compile_sly(ctx_t *ctx, unsigned long i); /** @todo add in placeholders (for example for load immediate but we don't know * what the immediate is yet) */ +reloc_t compile_placeholder(ctx_t *ctx, compile_callback_t call); +void compile_patch(reloc_t reloc, void *addr); + void compile_start(ctx_t *ctx); void compile_finish(ctx_t *ctx); unsigned long run(ctx_t *ctx); -- cgit v1.3