renamed target_os macos to target_vendor apple (#273)
* renamed target_os macos to target_vendor apple * fix yaml
This commit is contained in:
parent
d1021c7a9a
commit
5caeb46b67
17
.github/workflows/build_and_test.yml
vendored
17
.github/workflows/build_and_test.yml
vendored
@ -165,6 +165,23 @@ jobs:
|
||||
run: ./scripts/shmem_limits_macos.sh
|
||||
- name: Build and run example fuzzers
|
||||
run: ./scripts/test_all_fuzzers.sh
|
||||
other_targets:
|
||||
runs-on: macOS-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: install ios
|
||||
run: rustup target add aarch64-apple-ios
|
||||
#- name: install android
|
||||
# run: rustup target add aarch64-linux-android
|
||||
- name: Build iOS
|
||||
run: cargo build --target aarch64-apple-ios
|
||||
#- name: Build Android
|
||||
# run: cargo build --target aarch64-linux-android
|
||||
# TODO: Figure out how to properly build stuff with clang
|
||||
#- name: Add clang path to $PATH env
|
||||
# if: runner.os == 'Windows'
|
||||
|
@ -23,7 +23,7 @@ use std::{
|
||||
thread::JoinHandle,
|
||||
};
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
use std::fs;
|
||||
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
@ -42,10 +42,10 @@ use std::{
|
||||
use uds::{UnixListenerExt, UnixSocketAddr, UnixStreamExt};
|
||||
|
||||
/// The default server name for our abstract shmem server
|
||||
#[cfg(all(unix, not(any(target_os = "ios", target_os = "macos"))))]
|
||||
#[cfg(all(unix, not(target_vendor = "apple")))]
|
||||
const UNIX_SERVER_NAME: &str = "@libafl_unix_shmem_server";
|
||||
/// `MacOS` server name is on disk, since `MacOS` doesn't support abtract domain sockets.
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
const UNIX_SERVER_NAME: &str = "./libafl_unix_shmem_server";
|
||||
|
||||
/// Env variable. If set, we won't try to spawn the service
|
||||
@ -331,7 +331,7 @@ impl Drop for ShMemServiceThread {
|
||||
.expect("Failed to join ShMemService thread!")
|
||||
.expect("Error in ShMemService background thread!");
|
||||
// try to remove the file from fs, and ignore errors.
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
fs::remove_file(&UNIX_SERVER_NAME).unwrap();
|
||||
|
||||
env::remove_var(AFL_SHMEM_SERVICE_STARTED);
|
||||
|
@ -32,30 +32,30 @@ pub type StdShMem = RcShMem<ServedShMemProvider<AshmemShMemProvider>>;
|
||||
#[cfg(all(target_os = "android", feature = "std"))]
|
||||
pub type StdShMemService = ShMemService<AshmemShMemProvider>;
|
||||
|
||||
#[cfg(all(feature = "std", any(target_os = "ios", target_os = "macos")))]
|
||||
#[cfg(all(feature = "std", target_vendor = "apple"))]
|
||||
pub type StdShMemProvider = RcShMemProvider<ServedShMemProvider<MmapShMemProvider>>;
|
||||
#[cfg(all(feature = "std", any(target_os = "ios", target_os = "macos")))]
|
||||
#[cfg(all(feature = "std", target_vendor = "apple"))]
|
||||
pub type StdShMem = RcShMem<ServedShMemProvider<MmapShMemProvider>>;
|
||||
#[cfg(all(feature = "std", any(target_os = "ios", target_os = "macos")))]
|
||||
#[cfg(all(feature = "std", target_vendor = "apple"))]
|
||||
pub type StdShMemService = ShMemService<MmapShMemProvider>;
|
||||
|
||||
/// The default [`ShMemProvider`] for this os.
|
||||
#[cfg(all(
|
||||
feature = "std",
|
||||
unix,
|
||||
not(any(target_os = "android", target_os = "ios", target_os = "macos"))
|
||||
not(any(target_os = "android", target_vendor = "apple"))
|
||||
))]
|
||||
pub type StdShMemProvider = UnixShMemProvider;
|
||||
/// The default [`ShMemProvider`] for this os.
|
||||
#[cfg(all(
|
||||
feature = "std",
|
||||
unix,
|
||||
not(any(target_os = "android", target_os = "ios", target_os = "macos"))
|
||||
not(any(target_os = "android", target_vendor = "apple"))
|
||||
))]
|
||||
pub type StdShMem = UnixShMem;
|
||||
|
||||
#[cfg(any(
|
||||
not(any(target_os = "android", target_os = "macos", target_os = "ios")),
|
||||
not(any(target_os = "android", target_vendor = "apple")),
|
||||
not(feature = "std")
|
||||
))]
|
||||
pub type StdShMemService = DummyShMemService;
|
||||
@ -67,12 +67,6 @@ use std::{
|
||||
env,
|
||||
};
|
||||
|
||||
#[cfg(all(
|
||||
unix,
|
||||
feature = "std",
|
||||
any(target_os = "ios", target_os = "macos", target_os = "android")
|
||||
))]
|
||||
use super::os::unix_shmem_server::ServedShMem;
|
||||
#[cfg(all(unix, feature = "std"))]
|
||||
use crate::bolts::os::pipes::Pipe;
|
||||
#[cfg(all(unix, feature = "std"))]
|
||||
|
@ -524,11 +524,7 @@ mod unix_signal_handler {
|
||||
}
|
||||
|
||||
#[allow(clippy::non_ascii_literal)]
|
||||
#[cfg(all(
|
||||
feature = "std",
|
||||
any(target_os = "macos", target_os = "ios"),
|
||||
target_arch = "aarch64"
|
||||
))]
|
||||
#[cfg(all(feature = "std", target_vendor = "apple", target_arch = "aarch64"))]
|
||||
{
|
||||
let mcontext = *_context.uc_mcontext;
|
||||
println!("{:━^100}", " CRASH ");
|
||||
|
@ -15,7 +15,7 @@ edition = "2018"
|
||||
[build-dependencies]
|
||||
cc = { version = "1.0", features = ["parallel"] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.build-dependencies]
|
||||
[target.'cfg(target_vendor = "apple")'.build-dependencies]
|
||||
glob = "0.3"
|
||||
|
||||
[dependencies]
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::{env, fs::File, io::Write, path::Path, process::Command, str};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
use glob::glob;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn dll_extension<'a>() -> &'a str {
|
||||
@ -16,7 +16,7 @@ fn dll_extension<'a>() -> &'a str {
|
||||
|
||||
/// Github Actions for `MacOS` seems to have troubles finding `llvm-config`.
|
||||
/// Hence, we go look for it ourselves.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
fn find_llvm_config_brew() -> Result<PathBuf, String> {
|
||||
match Command::new("brew").arg("--cellar").output() {
|
||||
Ok(output) => {
|
||||
@ -43,7 +43,7 @@ fn find_llvm_config_brew() -> Result<PathBuf, String> {
|
||||
fn find_llvm_config() -> String {
|
||||
env::var("LLVM_CONFIG").unwrap_or_else(|_| {
|
||||
// for Ghithub Actions, we check if we find llvm-config in brew.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
match find_llvm_config_brew() {
|
||||
Ok(llvm_dir) => llvm_dir.to_str().unwrap().to_string(),
|
||||
Err(err) => {
|
||||
@ -52,7 +52,7 @@ fn find_llvm_config() -> String {
|
||||
"llvm-config".to_string()
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
"llvm-config".to_string()
|
||||
})
|
||||
}
|
||||
@ -103,10 +103,10 @@ fn main() {
|
||||
let cxxflags: Vec<&str> = cxxflags.trim().split_whitespace().collect();
|
||||
let mut ldflags: Vec<&str> = ldflags.trim().split_whitespace().collect();
|
||||
|
||||
match env::var("CARGO_CFG_TARGET_OS").unwrap().as_str() {
|
||||
match env::var("CARGO_CFG_TARGET_VENDOR").unwrap().as_str() {
|
||||
// Needed on macos.
|
||||
// Explanation at https://github.com/banach-space/llvm-tutor/blob/787b09ed31ff7f0e7bdd42ae20547d27e2991512/lib/CMakeLists.txt#L59
|
||||
"macos" | "ios" => {
|
||||
"apple" => {
|
||||
ldflags.push("-undefined");
|
||||
ldflags.push("dynamic_lookup");
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use crate::{CompilerWrapper, Error, LIB_EXT, LIB_PREFIX};
|
||||
fn dll_extension<'a>() -> &'a str {
|
||||
if cfg!(target_os = "windows") {
|
||||
"dll"
|
||||
} else if cfg!(any(target_os = "ios", target_os = "macos")) {
|
||||
} else if cfg!(target_vendor = "apple") {
|
||||
"dylib"
|
||||
} else {
|
||||
"so"
|
||||
@ -130,7 +130,7 @@ impl CompilerWrapper for ClangWrapper {
|
||||
new_args.push("-lAdvapi32".into());
|
||||
}
|
||||
// MacOS has odd linker behavior sometimes
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
if linking {
|
||||
new_args.push("-undefined".into());
|
||||
new_args.push("dynamic_lookup".into());
|
||||
@ -168,7 +168,7 @@ impl CompilerWrapper for ClangWrapper {
|
||||
where
|
||||
S: AsRef<str>,
|
||||
{
|
||||
if cfg!(any(target_os = "macos", target_os = "ios")) {
|
||||
if cfg!(target_vendor = "apple") {
|
||||
//self.add_link_arg("-force_load".into())?;
|
||||
} else {
|
||||
self.add_link_arg("-Wl,--whole-archive");
|
||||
@ -179,7 +179,7 @@ impl CompilerWrapper for ClangWrapper {
|
||||
.into_string()
|
||||
.unwrap(),
|
||||
);
|
||||
if cfg!(any(target_os = "macos", target_os = "ios")) {
|
||||
if cfg!(target_vendor = "apple") {
|
||||
self
|
||||
} else {
|
||||
self.add_link_arg("-Wl,-no-whole-archive")
|
||||
|
@ -35,9 +35,9 @@ pub(crate) struct Allocator {
|
||||
current_mapping_addr: usize,
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANON;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANONYMOUS;
|
||||
|
||||
macro_rules! map_to_shadow {
|
||||
|
@ -29,9 +29,9 @@ use frida_gum::{Gum, ModuleMap};
|
||||
use libc::RLIMIT_STACK;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use libc::{c_char, wchar_t};
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
use libc::{getrlimit, rlimit};
|
||||
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
|
||||
#[cfg(all(unix, not(target_vendor = "apple")))]
|
||||
use libc::{getrlimit64, rlimit64};
|
||||
use std::{ffi::c_void, ptr::write_volatile};
|
||||
|
||||
@ -50,9 +50,9 @@ extern "C" {
|
||||
fn tls_ptr() -> *const c_void;
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANON;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANONYMOUS;
|
||||
|
||||
/// The frida address sanitizer runtime, providing address sanitization.
|
||||
@ -210,7 +210,7 @@ impl AsanRuntime {
|
||||
|
||||
/// Get the maximum stack size for the current stack
|
||||
#[must_use]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
fn max_stack_size() -> usize {
|
||||
let mut stack_rlimit = rlimit {
|
||||
rlim_cur: 0,
|
||||
@ -223,7 +223,7 @@ impl AsanRuntime {
|
||||
|
||||
/// Get the maximum stack size for the current stack
|
||||
#[must_use]
|
||||
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
|
||||
#[cfg(all(unix, not(target_vendor = "apple")))]
|
||||
fn max_stack_size() -> usize {
|
||||
let mut stack_rlimit = rlimit64 {
|
||||
rlim_cur: 0,
|
||||
@ -254,7 +254,7 @@ impl AsanRuntime {
|
||||
let max_start = end - Self::max_stack_size();
|
||||
|
||||
let flags = ANONYMOUS_FLAG | MapFlags::MAP_FIXED | MapFlags::MAP_PRIVATE;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
let flags = flags | MapFlags::MAP_STACK;
|
||||
|
||||
if start != max_start {
|
||||
@ -399,7 +399,7 @@ impl AsanRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "aarch64", not(target_os = "macos")))]
|
||||
#[cfg(all(target_arch = "aarch64", not(target_vendor = "apple")))]
|
||||
#[inline]
|
||||
fn hook_memalign(&mut self, alignment: usize, size: usize) -> *mut c_void {
|
||||
unsafe { self.allocator.alloc(size, alignment) }
|
||||
@ -420,7 +420,7 @@ impl AsanRuntime {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(all(target_arch = "aarch64", not(target_os = "macos")))]
|
||||
#[cfg(all(target_arch = "aarch64", not(target_vendor = "apple")))]
|
||||
fn hook_malloc_usable_size(&mut self, ptr: *mut c_void) -> usize {
|
||||
self.allocator.get_usable_size(ptr)
|
||||
}
|
||||
@ -708,7 +708,7 @@ impl AsanRuntime {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(all(target_arch = "aarch64", not(target_os = "macos")))]
|
||||
#[cfg(all(target_arch = "aarch64", not(target_vendor = "apple")))]
|
||||
fn hook_mempcpy(&mut self, dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void {
|
||||
extern "C" {
|
||||
fn mempcpy(dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void;
|
||||
@ -810,7 +810,7 @@ impl AsanRuntime {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(all(target_arch = "aarch64", not(target_os = "macos")))]
|
||||
#[cfg(all(target_arch = "aarch64", not(target_vendor = "apple")))]
|
||||
fn hook_memrchr(&mut self, s: *mut c_void, c: i32, n: usize) -> *mut c_void {
|
||||
extern "C" {
|
||||
fn memrchr(s: *mut c_void, c: i32, n: usize) -> *mut c_void;
|
||||
@ -894,7 +894,7 @@ impl AsanRuntime {
|
||||
#[cfg(all(
|
||||
not(target_os = "android"),
|
||||
target_arch = "aarch64",
|
||||
not(target_os = "macos")
|
||||
not(target_vendor = "apple")
|
||||
))]
|
||||
#[inline]
|
||||
fn hook_explicit_bzero(&mut self, s: *mut c_void, n: usize) {
|
||||
@ -1594,7 +1594,7 @@ impl AsanRuntime {
|
||||
hook_func!(None, calloc, (nmemb: usize, size: usize), *mut c_void);
|
||||
hook_func!(None, realloc, (ptr: *mut c_void, size: usize), *mut c_void);
|
||||
hook_func_with_check!(None, free, (ptr: *mut c_void), ());
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
hook_func!(None, memalign, (size: usize, alignment: usize), *mut c_void);
|
||||
hook_func!(
|
||||
None,
|
||||
@ -1602,7 +1602,7 @@ impl AsanRuntime {
|
||||
(pptr: *mut *mut c_void, size: usize, alignment: usize),
|
||||
i32
|
||||
);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
hook_func!(None, malloc_usable_size, (ptr: *mut c_void), usize);
|
||||
hook_func!(None, _Znam, (size: usize), *mut c_void);
|
||||
hook_func!(
|
||||
@ -1736,7 +1736,7 @@ impl AsanRuntime {
|
||||
(dest: *mut c_void, src: *const c_void, n: usize),
|
||||
*mut c_void
|
||||
);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
hook_func!(
|
||||
None,
|
||||
mempcpy,
|
||||
@ -1761,7 +1761,7 @@ impl AsanRuntime {
|
||||
(s: *mut c_void, c: i32, n: usize),
|
||||
*mut c_void
|
||||
);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
hook_func!(
|
||||
None,
|
||||
memrchr,
|
||||
@ -1781,7 +1781,7 @@ impl AsanRuntime {
|
||||
);
|
||||
#[cfg(not(target_os = "android"))]
|
||||
hook_func!(None, bzero, (s: *mut c_void, n: usize), ());
|
||||
#[cfg(not(any(target_os = "macos", target_os = "android")))]
|
||||
#[cfg(not(any(target_os = "android", target_vendor = "apple")))]
|
||||
hook_func!(None, explicit_bzero, (s: *mut c_void, n: usize), ());
|
||||
#[cfg(not(target_os = "android"))]
|
||||
hook_func!(
|
||||
|
@ -46,9 +46,9 @@ enum CmplogOperandType {
|
||||
Mem(capstone::RegId, capstone::RegId, i32, u32),
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANON;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANONYMOUS;
|
||||
|
||||
/// An helper that feeds [`FridaInProcessExecutor`] with user-supplied instrumentation
|
||||
|
Loading…
x
Reference in New Issue
Block a user