diff --git a/include/libafl/syx-snapshot/syx-snapshot.h b/include/libafl/syx-snapshot/syx-snapshot.h index fe18e30d5f..29b8de71bf 100644 --- a/include/libafl/syx-snapshot/syx-snapshot.h +++ b/include/libafl/syx-snapshot/syx-snapshot.h @@ -59,6 +59,10 @@ typedef struct SyxSnapshotState { // Root } SyxSnapshotState; +typedef struct SyxSnapshotCheckResult { + uint64_t nb_inconsistencies; +} SyxSnapshotCheckResult; + void syx_snapshot_init(bool cached_bdrvs); // @@ -71,7 +75,7 @@ void syx_snapshot_free(SyxSnapshot *snapshot); void syx_snapshot_root_restore(SyxSnapshot *snapshot); -uint64_t syx_snapshot_check_memory_consistency(SyxSnapshot *snapshot); +SyxSnapshotCheckResult syx_snapshot_check(SyxSnapshot* ref_snapshot); // Push the current RAM state and saves it void syx_snapshot_increment_push(SyxSnapshot *snapshot, DeviceSnapshotKind kind, char **devices); diff --git a/libafl/syx-snapshot/syx-snapshot.c b/libafl/syx-snapshot/syx-snapshot.c index e9392c6b70..507e8e1eae 100644 --- a/libafl/syx-snapshot/syx-snapshot.c +++ b/libafl/syx-snapshot/syx-snapshot.c @@ -577,7 +577,6 @@ static void root_restore_check_memory_rb(gpointer rb_idstr_hash, gpointer rb_dir SyxSnapshot *snapshot = args->snapshot; RAMBlock *rb = ramblock_lookup(rb_idstr_hash); - args->nb_inconsistent_pages = 0; if (rb) { SYX_PRINTF("Checking memory consistency of %s... ", rb->idstr); SyxSnapshotRAMBlock *rb_snapshot = g_hash_table_lookup(snapshot->root_snapshot->rbs_snapshot, rb_idstr_hash); @@ -610,12 +609,19 @@ static void root_restore_check_memory_rb(gpointer rb_idstr_hash, gpointer rb_dir } } -uint64_t syx_snapshot_check_memory_consistency(SyxSnapshot *snapshot) { +SyxSnapshotCheckResult syx_snapshot_check(SyxSnapshot* ref_snapshot) { struct rb_check_memory_args args = { - .snapshot = snapshot + .snapshot = ref_snapshot, + .nb_inconsistent_pages = 0, }; - g_hash_table_foreach(snapshot->rbs_dirty_list, root_restore_check_memory_rb, &args); - return args.nb_inconsistent_pages; + + g_hash_table_foreach(ref_snapshot->rbs_dirty_list, root_restore_check_memory_rb, &args); + + struct SyxSnapshotCheckResult res = { + .nb_inconsistencies = args.nb_inconsistent_pages + }; + + return res; } void syx_snapshot_root_restore(SyxSnapshot *snapshot) { diff --git a/linker_interceptor.py b/linker_interceptor.py index df1c17e7da..69c57f97d6 100755 --- a/linker_interceptor.py +++ b/linker_interceptor.py @@ -27,6 +27,19 @@ rpath_pattern = r"^'.*,-rpath,(.*)'$" rpath_link_pattern = r"^.*,-rpath-link,(.*)$" +linker_interceptor_pattern = r"(\": \")(.*linker_interceptor.py)( )" +linker_interceptorpp_pattern = r"(\": \")(.*linker_interceptor\+\+.py)( )" + +def fix_compile_commands(): + with open("compile_commands.json", 'r') as f: + compile_commands = f.read() + + res = re.sub(linker_interceptor_pattern, rf"\g<1>{CC}\g<3>", compile_commands) + res = re.sub(linker_interceptorpp_pattern, rf"\g<1>{CXX}\g<3>", res) + + with open("compile_commands.json", 'w') as f: + f.write(res) + def process_args(args): global out_args, shareds, search, is_linking_qemu prev_o = False @@ -75,6 +88,8 @@ def process_args(args): for entry in compile_commands: sources.append(entry["file"]) + fix_compile_commands() + with open(OUT, 'w') as f: json.dump({ 'cmd': out_args,