libafl_frida: Allow compilation for iOS (#1023)
iOS does not have any TLS, so we don't need to keep track of it. This allows compiling for the aarch64-apple-ios target.
This commit is contained in:
parent
33ddce2cea
commit
afa506c0c8
@ -1,7 +1,10 @@
|
|||||||
// build.rs
|
// build.rs
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
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");
|
cc::Build::new().file("src/gettls.c").compile("libgettls.a");
|
||||||
|
}
|
||||||
|
|
||||||
// Force linking against libc++
|
// Force linking against libc++
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -61,6 +61,7 @@ extern "C" {
|
|||||||
fn __register_frame(begin: *mut c_void);
|
fn __register_frame(begin: *mut c_void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "ios"))]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn tls_ptr() -> *const c_void;
|
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
|
/// Register the current thread with the runtime, implementing shadow memory for its stack and
|
||||||
/// tls mappings.
|
/// tls mappings.
|
||||||
#[allow(clippy::unused_self)]
|
#[allow(clippy::unused_self)]
|
||||||
|
#[cfg(not(target_os = "ios"))]
|
||||||
pub fn register_thread(&mut self) {
|
pub fn register_thread(&mut self) {
|
||||||
let (stack_start, stack_end) = Self::current_stack();
|
let (stack_start, stack_end) = Self::current_stack();
|
||||||
self.allocator
|
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
|
/// Get the maximum stack size for the current stack
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[cfg(target_vendor = "apple")]
|
#[cfg(target_vendor = "apple")]
|
||||||
@ -470,6 +483,7 @@ impl AsanRuntime {
|
|||||||
|
|
||||||
/// Determine the tls start, end for the currently running thread
|
/// Determine the tls start, end for the currently running thread
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[cfg(not(target_os = "ios"))]
|
||||||
fn current_tls() -> (usize, usize) {
|
fn current_tls() -> (usize, usize) {
|
||||||
let tls_address = unsafe { tls_ptr() } as usize;
|
let tls_address = unsafe { tls_ptr() } as usize;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user