/* Amount of corpus->data[] consumed thus far. */
size_t data_index;
+
+ /* Emulation ops, some of which are disabled based on corpus->options. */
+ struct x86_emulate_ops ops;
};
/*
}
#define SET(h) .h = fuzz_##h
-static struct x86_emulate_ops fuzz_emulops = {
+static const struct x86_emulate_ops all_fuzzer_ops = {
SET(read),
SET(insn_fetch),
SET(write),
#define MAYBE_DISABLE_HOOK(h) \
if ( bitmap & (1 << HOOK_##h) ) \
{ \
- fuzz_emulops.h = NULL; \
+ s->ops.h = NULL; \
printf("Disabling hook "#h"\n"); \
}
int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)
{
struct cpu_user_regs regs = {};
- struct fuzz_state state = {};
+ struct fuzz_state state = {
+ .ops = all_fuzzer_ops,
+ };
struct x86_emulate_ctxt ctxt = {
.data = &state,
.regs = ®s,
set_sizes(&ctxt);
dump_state(&ctxt);
- rc = x86_emulate(&ctxt, &fuzz_emulops);
+ rc = x86_emulate(&ctxt, &state.ops);
printf("Emulation result: %d\n", rc);
} while ( rc == X86EMUL_OKAY );