diff --git a/libafl_bolts/src/math.rs b/libafl_bolts/src/math.rs index a794a0e1bf..947a317b61 100644 --- a/libafl_bolts/src/math.rs +++ b/libafl_bolts/src/math.rs @@ -59,23 +59,6 @@ pub const fn integer_sqrt(val: u64) -> u64 { ret } -/// Given a u64 number, return a hashed number using this mixing function -/// This function is used to hash an address into a more random number (used in `libafl_frida`). -/// Mixing function: -#[inline] -#[must_use] -pub const fn xxh3_rrmxmx_mixer(v: u64) -> u64 { - let tmp = (v >> 32) + ((v & 0xffffffff) << 32); - let bitflip = 0x1cad21f72c81017c ^ 0xdb979082e96dd4de; - let mut h64 = tmp ^ bitflip; - h64 = h64.rotate_left(49) & h64.rotate_left(24); - h64 = h64.wrapping_mul(0x9FB21C651E98DF25); - h64 ^= (h64 >> 35) + 8; - h64 = h64.wrapping_mul(0x9FB21C651E98DF25); - h64 ^= h64 >> 28; - h64 -} - /// Calculates the cumulative sum for a slice, in-place. /// The values are useful for example for cumulative probabilities. /// diff --git a/libafl_frida/src/coverage_rt.rs b/libafl_frida/src/coverage_rt.rs index a5215f750d..a4a5008a8c 100644 --- a/libafl_frida/src/coverage_rt.rs +++ b/libafl_frida/src/coverage_rt.rs @@ -6,7 +6,7 @@ use std::{cell::RefCell, marker::PhantomPinned, pin::Pin, rc::Rc}; use dynasmrt::DynasmLabelApi; use dynasmrt::{dynasm, DynasmApi}; use frida_gum::{instruction_writer::InstructionWriter, stalker::StalkerOutput, ModuleMap}; -use libafl_bolts::math::xxh3_rrmxmx_mixer; +use libafl_bolts::hash_std; use rangemap::RangeMap; use crate::helper::FridaRuntime; @@ -186,7 +186,7 @@ impl CoverageRuntime { /// Emits coverage mapping into the current basic block. #[inline] pub fn emit_coverage_mapping(&mut self, address: u64, output: &StalkerOutput) { - let h64 = xxh3_rrmxmx_mixer(address); + let h64 = hash_std(&address.to_le_bytes()); let writer = output.writer(); // Since the AARCH64 instruction set requires that a register be used if