parent
0dc52ed6f3
commit
6ae8b5bfb0
@ -133,6 +133,7 @@ static TCGHelperInfo libafl_exec_block_hook_info = {
|
|||||||
|
|
||||||
struct libafl_block_hook {
|
struct libafl_block_hook {
|
||||||
uint64_t (*gen)(target_ulong pc, uint64_t data);
|
uint64_t (*gen)(target_ulong pc, uint64_t data);
|
||||||
|
void (*post_gen)(target_ulong pc, target_ulong block_length, uint64_t data);
|
||||||
void (*exec)(uint64_t id, uint64_t data);
|
void (*exec)(uint64_t id, uint64_t data);
|
||||||
uint64_t data;
|
uint64_t data;
|
||||||
TCGHelperInfo helper_info;
|
TCGHelperInfo helper_info;
|
||||||
@ -142,11 +143,11 @@ struct libafl_block_hook {
|
|||||||
struct libafl_block_hook* libafl_block_hooks;
|
struct libafl_block_hook* libafl_block_hooks;
|
||||||
|
|
||||||
void libafl_add_block_hook(uint64_t (*gen)(target_ulong pc, uint64_t data),
|
void libafl_add_block_hook(uint64_t (*gen)(target_ulong pc, uint64_t data),
|
||||||
void (*exec)(uint64_t id, uint64_t data),
|
void (*post_gen)(target_ulong pc, target_ulong block_length, uint64_t data),
|
||||||
uint64_t data);
|
void (*exec)(uint64_t id, uint64_t data), uint64_t data);
|
||||||
void libafl_add_block_hook(uint64_t (*gen)(target_ulong pc, uint64_t data),
|
void libafl_add_block_hook(uint64_t (*gen)(target_ulong pc, uint64_t data),
|
||||||
void (*exec)(uint64_t id, uint64_t data),
|
void (*post_gen)(target_ulong pc, target_ulong block_length, uint64_t data),
|
||||||
uint64_t data)
|
void (*exec)(uint64_t id, uint64_t data), uint64_t data)
|
||||||
{
|
{
|
||||||
CPUState *cpu;
|
CPUState *cpu;
|
||||||
CPU_FOREACH(cpu) {
|
CPU_FOREACH(cpu) {
|
||||||
@ -155,6 +156,7 @@ void libafl_add_block_hook(uint64_t (*gen)(target_ulong pc, uint64_t data),
|
|||||||
|
|
||||||
struct libafl_block_hook* hook = malloc(sizeof(struct libafl_block_hook));
|
struct libafl_block_hook* hook = malloc(sizeof(struct libafl_block_hook));
|
||||||
hook->gen = gen;
|
hook->gen = gen;
|
||||||
|
hook->post_gen = post_gen;
|
||||||
hook->exec = exec;
|
hook->exec = exec;
|
||||||
hook->data = data;
|
hook->data = data;
|
||||||
hook->next = libafl_block_hooks;
|
hook->next = libafl_block_hooks;
|
||||||
@ -1186,6 +1188,14 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||||||
}
|
}
|
||||||
tb->tc.size = gen_code_size;
|
tb->tc.size = gen_code_size;
|
||||||
|
|
||||||
|
struct libafl_block_hook *hook = libafl_block_hooks;
|
||||||
|
while (hook)
|
||||||
|
{
|
||||||
|
if (hook->post_gen)
|
||||||
|
hook->post_gen(pc, tb->size, hook->data);
|
||||||
|
hook = hook->next;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For TARGET_TB_PCREL, attribute all executions of the generated
|
* For TARGET_TB_PCREL, attribute all executions of the generated
|
||||||
* code to its first mapping.
|
* code to its first mapping.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user