diff --git a/libafl_frida/build.rs b/libafl_frida/build.rs index 90705df25d..12a7fe2853 100644 --- a/libafl_frida/build.rs +++ b/libafl_frida/build.rs @@ -1,7 +1,10 @@ // build.rs fn main() { - cc::Build::new().file("src/gettls.c").compile("libgettls.a"); + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); + if target_os != "ios" { + cc::Build::new().file("src/gettls.c").compile("libgettls.a"); + } // Force linking against libc++ #[cfg(unix)] diff --git a/libafl_frida/src/asan/asan_rt.rs b/libafl_frida/src/asan/asan_rt.rs index 353563983f..3a8ffa9ca9 100644 --- a/libafl_frida/src/asan/asan_rt.rs +++ b/libafl_frida/src/asan/asan_rt.rs @@ -61,6 +61,7 @@ extern "C" { fn __register_frame(begin: *mut c_void); } +#[cfg(not(target_os = "ios"))] extern "C" { fn tls_ptr() -> *const c_void; } @@ -390,6 +391,7 @@ impl AsanRuntime { /// Register the current thread with the runtime, implementing shadow memory for its stack and /// tls mappings. #[allow(clippy::unused_self)] + #[cfg(not(target_os = "ios"))] pub fn register_thread(&mut self) { let (stack_start, stack_end) = Self::current_stack(); self.allocator @@ -403,6 +405,17 @@ impl AsanRuntime { ); } + /// Register the current thread with the runtime, implementing shadow memory for its stack mapping. + #[allow(clippy::unused_self)] + #[cfg(target_os = "ios")] + pub fn register_thread(&mut self) { + let (stack_start, stack_end) = Self::current_stack(); + self.allocator + .map_shadow_for_region(stack_start, stack_end, true); + + println!("registering thread with stack {stack_start:x}:{stack_end:x}"); + } + /// Get the maximum stack size for the current stack #[must_use] #[cfg(target_vendor = "apple")] @@ -470,6 +483,7 @@ impl AsanRuntime { /// Determine the tls start, end for the currently running thread #[must_use] + #[cfg(not(target_os = "ios"))] fn current_tls() -> (usize, usize) { let tls_address = unsafe { tls_ptr() } as usize;