ptrauth_sys/
lib.rs

1use std::os::raw::c_void;
2
3#[cfg(feature = "arm64e")]
4#[link(name = "ptrauth", kind = "static")]
5extern "C" {
6    /// Strips pointer authentication from a C pointer on arm64e (ARMv8.3+)
7    /// Does nothing on arm64 (ARMv8)
8    /// `void* ptr_strip(void* address)`
9    fn ptr_strip(address: *mut c_void) -> *mut c_void;
10}
11
12/// Strips the Pointer Authentication signature from a pointer. Only useful on arm64e (ARMv8.3+).
13#[cfg(not(feature = "arm64e"))]
14pub fn strip_pac(pointer: *mut c_void) -> *mut c_void {
15    pointer
16}
17
18/// Strips the Pointer Authentication signature from a pointer. Only useful on arm64e (ARMv8.3+).
19#[cfg(feature = "arm64e")]
20pub fn strip_pac(pointer: *mut c_void) -> *mut c_void {
21    unsafe { ptr_strip(pointer) }
22}