Fix build issues in frida cmplog for aarch64 (#1813)

* Fix build issues for aarch64

* cargo fmt
This commit is contained in:
Sharad Khanna 2024-01-23 19:18:31 -05:00 committed by GitHub
parent a0e30d01d3
commit 1458c3efff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<Box<[u8]>>,
handle_tbz_masking: Option<Box<[u8]>>,
handle_tbnz_masking: Option<Box<[u8]>>,
ops_save_register_and_blr_to_populate: Option<Box<[u8]>>,
ops_handle_tbz_masking: Option<Box<[u8]>>,
ops_handle_tbnz_masking: Option<Box<[u8]>>,
}
/// `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]