From 0cda19cbcf58e30f35a270d0e26b9ef097b3abe2 Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Tue, 16 Jan 2024 15:53:38 +0100 Subject: [PATCH] fix jmp instrumentation --- accel/tcg/translate-all.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 9511daa1b7..a622c6cb23 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -77,8 +77,8 @@ static TCGHelperInfo libafl_exec_jmp_hook_info = { }; struct libafl_jmp_hook { - uint64_t (*gen)(target_ulong src, target_ulong dst, uint64_t data); - void (*exec)(target_ulong src, target_ulong dst, uint64_t id, uint64_t data); + uint64_t (*gen)(uint64_t data, target_ulong src, target_ulong dst); + void (*exec)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id); uint64_t data; TCGHelperInfo helper_info; struct libafl_jmp_hook* next; @@ -86,11 +86,11 @@ struct libafl_jmp_hook { struct libafl_jmp_hook* libafl_jmp_hooks; -void libafl_add_jmp_hook(uint64_t (*gen)(target_ulong src, target_ulong dst, uint64_t data), - void (*exec)(target_ulong src, target_ulong dst, uint64_t id, uint64_t data), +void libafl_add_jmp_hook(uint64_t (*gen)(uint64_t data, target_ulong src, target_ulong dst), + void (*exec)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id), uint64_t data); -void libafl_add_jmp_hook(uint64_t (*gen)(target_ulong src, target_ulong dst, uint64_t data), - void (*exec)(target_ulong src, target_ulong dst, uint64_t id, uint64_t data), +void libafl_add_jmp_hook(uint64_t (*gen)(uint64_t data, target_ulong src, target_ulong dst), + void (*exec)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id), uint64_t data) { struct libafl_jmp_hook* hook = calloc(sizeof(struct libafl_jmp_hook), 1); @@ -112,12 +112,12 @@ void libafl_gen_jmp(target_ulong src, target_ulong dst) while (hook) { uint64_t cur_id = 0; if (hook->gen) - cur_id = hook->gen(src, dst, hook->data); + cur_id = hook->gen(hook->data, src, dst); if (cur_id != (uint64_t)-1 && hook->exec) { - TCGv_i64 tmp0 = tcg_constant_i64(src); - TCGv_i64 tmp1 = tcg_constant_i64(dst); - TCGv_i64 tmp2 = tcg_constant_i64(cur_id); - TCGv_i64 tmp3 = tcg_constant_i64(hook->data); + TCGv_i64 tmp0 = tcg_constant_i64(hook->data); + TCGv_i64 tmp1 = tcg_constant_i64(src); + TCGv_i64 tmp2 = tcg_constant_i64(dst); + TCGv_i64 tmp3 = tcg_constant_i64(cur_id); TCGTemp *tmp4[4] = { tcgv_i64_temp(tmp0), tcgv_i64_temp(tmp1), tcgv_i64_temp(tmp2), tcgv_i64_temp(tmp3) }; tcg_gen_callN(&hook->helper_info, NULL, tmp4); tcg_temp_free_i64(tmp0);