Fix Windows build for AFL integration

This commit is contained in:
lazymio 2021-10-25 16:11:58 +02:00
parent 1fa2eb688b
commit 7ac7c23c12
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873
11 changed files with 23 additions and 2 deletions

View File

@ -61,6 +61,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
/* Reset the temp count so that we can identify leaks */
tcg_clear_temp_count();
#ifdef UNICORN_HAS_AFL
if (uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = cpu->uc->exits;
@ -81,6 +82,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
}
}
}
#endif
/* Unicorn: early check to see if the address of this block is
* the "run until" address. */

View File

@ -194,6 +194,7 @@ void resume_all_vcpus(struct uc_struct* uc)
tb_flush_jmp_cache(cpu, uc->addr_end);
}
#ifdef UNICORN_HAS_AFL
if (uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = uc->exits;
@ -209,6 +210,7 @@ void resume_all_vcpus(struct uc_struct* uc)
}
}
}
#endif
cpu->created = false;
}

View File

@ -14641,6 +14641,7 @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
DisasContext *dc = container_of(dcbase, DisasContext, base);
CPUARMState *env = cpu->env_ptr;
#ifdef UNICORN_HAS_AFL
if (dc->uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = dc->uc->exits;
@ -14655,6 +14656,7 @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
}
}
}
#endif
// Unicorn: end address tells us to stop emulation
if (dcbase->pc_next == dc->uc->addr_end) {

View File

@ -11420,6 +11420,7 @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
return;
}
#ifdef UNICORN_HAS_AFL
if (dc->uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = dc->uc->exits;
@ -11434,6 +11435,7 @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
}
}
}
#endif
// Unicorn: end address tells us to stop emulation
if (dcbase->pc_next == dc->uc->addr_end) {

View File

@ -4764,6 +4764,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
s->uc = env->uc;
#ifdef UNICORN_HAS_AFL
if (s->uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = s->uc->exits;
@ -4782,6 +4783,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
}
}
}
#endif
// Unicorn: end address tells us to stop emulation
if (s->pc == s->uc->addr_end) {

View File

@ -6325,6 +6325,7 @@ static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
CPUM68KState *env = cpu->env_ptr;
uint16_t insn;
#ifdef UNICORN_HAS_AFL
if (uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = uc->exits;
@ -6339,6 +6340,7 @@ static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
}
}
}
#endif
// Unicorn: end address tells us to stop emulation
if (dc->pc == uc->addr_end) {

View File

@ -30930,7 +30930,8 @@ static void mips_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
bool hook_insn = false;
is_slot = ctx->hflags & MIPS_HFLAG_BMASK;
#ifdef UNICORN_HAS_AFL
if (uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = uc->exits;
@ -30946,6 +30947,7 @@ static void mips_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
}
}
}
#endif
// Unicorn: end address tells us to stop emulation
if (ctx->base.pc_next == uc->addr_end) {

View File

@ -7625,6 +7625,7 @@ static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx->base.pc_next, ctx->mem_idx, (int)msr_ir);
#ifdef UNICORN_HAS_AFL
if (uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = uc->exits;
@ -7639,6 +7640,7 @@ static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
}
}
}
#endif
// Unicorn: end address tells us to stop emulation
if (ctx->base.pc_next == uc->addr_end) {

View File

@ -849,6 +849,7 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
TCGOp *tcg_op, *prev_op = NULL;
bool insn_hook = false;
#ifdef UNICORN_HAS_AFL
if (uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = ctx->uc->exits;
@ -864,6 +865,7 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
}
}
}
#endif
// Unicorn: end address tells us to stop emulation
if (ctx->base.pc_next == ctx->uc->addr_end) {

View File

@ -5950,6 +5950,7 @@ static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
CPUSPARCState *env = cs->env_ptr;
unsigned int insn;
#ifdef UNICORN_HAS_AFL
if (uc->afl) {
// UNICORN-AFL supports (and needs) multiple exits.
uint64_t *exits = uc->exits;
@ -5967,6 +5968,7 @@ static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
}
}
}
#endif
// Unicorn: end address tells us to stop emulation
if (dc->pc == uc->addr_end) {

3
uc.c
View File

@ -771,7 +771,7 @@ uc_err uc_emu_start(uc_engine* uc, uint64_t begin, uint64_t until, uint64_t time
return uc->invalid_error;
}
#ifdef UNICORN_HAS_AFL
static inline uc_afl_ret uc_afl_forkserver_start(uc_engine *uc, uint64_t *exits, size_t exit_count)
{
/*
@ -922,6 +922,7 @@ static inline uc_afl_ret uc_afl_next(uc_engine *uc, bool crash_found)
return UC_AFL_RET_NO_AFL;
}
#endif
UNICORN_EXPORT
uc_err uc_afl_fuzz(