From 1458c3efffa30210074e73509c696287ab7b7c82 Mon Sep 17 00:00:00 2001 From: Sharad Khanna Date: Tue, 23 Jan 2024 19:18:31 -0500 Subject: [PATCH] Fix build issues in frida cmplog for aarch64 (#1813) * Fix build issues for aarch64 * cargo fmt --- libafl_frida/src/cmplog_rt.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libafl_frida/src/cmplog_rt.rs b/libafl_frida/src/cmplog_rt.rs index 1be78974b0..a9e91505bc 100644 --- a/libafl_frida/src/cmplog_rt.rs +++ b/libafl_frida/src/cmplog_rt.rs @@ -8,6 +8,8 @@ use std::collections::HashMap; use dynasmrt::dynasm; +#[cfg(target_arch = "aarch64")] +use dynasmrt::{DynasmApi, DynasmLabelApi}; use libafl::{ inputs::{HasTargetBytes, Input}, Error, @@ -21,6 +23,8 @@ extern "C" { pub fn __libafl_targets_cmplog_instructions(k: u64, shape: u8, arg1: u64, arg2: u64); } +#[cfg(target_arch = "aarch64")] +use core::ffi::c_void; use std::rc::Rc; use frida_gum::ModuleMap; @@ -105,9 +109,9 @@ pub enum CmplogOperandType { #[derive(Debug)] #[cfg(target_arch = "aarch64")] pub struct CmpLogRuntime { - save_register_and_blr_to_populate: Option>, - handle_tbz_masking: Option>, - handle_tbnz_masking: Option>, + ops_save_register_and_blr_to_populate: Option>, + ops_handle_tbz_masking: Option>, + ops_handle_tbnz_masking: Option>, } /// `Frida`-based binary-only innstrumentation that logs compares to the fuzzer @@ -384,7 +388,7 @@ impl CmpLogRuntime { /// Get the blob which saves the context, jumps to the populate function and restores the context #[inline] #[must_use] - #[cfg(target_arch = "aaarch64")] + #[cfg(target_arch = "aarch64")] pub fn ops_save_register_and_blr_to_populate(&self) -> &[u8] { self.ops_save_register_and_blr_to_populate.as_ref().unwrap() } @@ -392,7 +396,7 @@ impl CmpLogRuntime { /// Get the blob which handles the tbz opcode masking #[inline] #[must_use] - #[cfg(target_arch = "aaarch64")] + #[cfg(target_arch = "aarch64")] pub fn ops_handle_tbz_masking(&self) -> &[u8] { self.ops_handle_tbz_masking.as_ref().unwrap() } @@ -400,7 +404,7 @@ impl CmpLogRuntime { /// Get the blob which handles the tbnz opcode masking #[inline] #[must_use] - #[cfg(target_arch = "aaarch64")] + #[cfg(target_arch = "aarch64")] pub fn ops_handle_tbnz_masking(&self) -> &[u8] { self.ops_handle_tbnz_masking.as_ref().unwrap() } @@ -557,6 +561,7 @@ impl CmpLogRuntime { writer.put_bytes(&self.restore_registers.clone().unwrap()); } + /// Emit the instrumentation code which is responsible for operands value extraction and cmplog map population #[cfg(all(feature = "cmplog", target_arch = "aarch64"))] #[allow(clippy::too_many_lines)] #[inline]