renamed target_os macos to target_vendor apple (#273)

* renamed target_os macos to target_vendor apple

* fix yaml
This commit is contained in:
Dominik Maier 2021-08-23 09:45:25 +02:00 committed by GitHub
parent d1021c7a9a
commit 5caeb46b67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 54 deletions

View File

@ -165,6 +165,23 @@ jobs:
run: ./scripts/shmem_limits_macos.sh run: ./scripts/shmem_limits_macos.sh
- name: Build and run example fuzzers - name: Build and run example fuzzers
run: ./scripts/test_all_fuzzers.sh 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 # TODO: Figure out how to properly build stuff with clang
#- name: Add clang path to $PATH env #- name: Add clang path to $PATH env
# if: runner.os == 'Windows' # if: runner.os == 'Windows'

View File

@ -23,7 +23,7 @@ use std::{
thread::JoinHandle, thread::JoinHandle,
}; };
#[cfg(any(target_os = "macos", target_os = "ios"))] #[cfg(target_vendor = "apple")]
use std::fs; use std::fs;
#[cfg(all(feature = "std", unix))] #[cfg(all(feature = "std", unix))]
@ -42,10 +42,10 @@ use std::{
use uds::{UnixListenerExt, UnixSocketAddr, UnixStreamExt}; use uds::{UnixListenerExt, UnixSocketAddr, UnixStreamExt};
/// The default server name for our abstract shmem server /// 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"; const UNIX_SERVER_NAME: &str = "@libafl_unix_shmem_server";
/// `MacOS` server name is on disk, since `MacOS` doesn't support abtract domain sockets. /// `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"; const UNIX_SERVER_NAME: &str = "./libafl_unix_shmem_server";
/// Env variable. If set, we won't try to spawn the service /// 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("Failed to join ShMemService thread!")
.expect("Error in ShMemService background thread!"); .expect("Error in ShMemService background thread!");
// try to remove the file from fs, and ignore errors. // 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(); fs::remove_file(&UNIX_SERVER_NAME).unwrap();
env::remove_var(AFL_SHMEM_SERVICE_STARTED); env::remove_var(AFL_SHMEM_SERVICE_STARTED);

View File

@ -32,30 +32,30 @@ pub type StdShMem = RcShMem<ServedShMemProvider<AshmemShMemProvider>>;
#[cfg(all(target_os = "android", feature = "std"))] #[cfg(all(target_os = "android", feature = "std"))]
pub type StdShMemService = ShMemService<AshmemShMemProvider>; 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>>; 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>>; 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>; pub type StdShMemService = ShMemService<MmapShMemProvider>;
/// The default [`ShMemProvider`] for this os. /// The default [`ShMemProvider`] for this os.
#[cfg(all( #[cfg(all(
feature = "std", feature = "std",
unix, unix,
not(any(target_os = "android", target_os = "ios", target_os = "macos")) not(any(target_os = "android", target_vendor = "apple"))
))] ))]
pub type StdShMemProvider = UnixShMemProvider; pub type StdShMemProvider = UnixShMemProvider;
/// The default [`ShMemProvider`] for this os. /// The default [`ShMemProvider`] for this os.
#[cfg(all( #[cfg(all(
feature = "std", feature = "std",
unix, unix,
not(any(target_os = "android", target_os = "ios", target_os = "macos")) not(any(target_os = "android", target_vendor = "apple"))
))] ))]
pub type StdShMem = UnixShMem; pub type StdShMem = UnixShMem;
#[cfg(any( #[cfg(any(
not(any(target_os = "android", target_os = "macos", target_os = "ios")), not(any(target_os = "android", target_vendor = "apple")),
not(feature = "std") not(feature = "std")
))] ))]
pub type StdShMemService = DummyShMemService; pub type StdShMemService = DummyShMemService;
@ -67,12 +67,6 @@ use std::{
env, 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"))] #[cfg(all(unix, feature = "std"))]
use crate::bolts::os::pipes::Pipe; use crate::bolts::os::pipes::Pipe;
#[cfg(all(unix, feature = "std"))] #[cfg(all(unix, feature = "std"))]

View File

@ -524,11 +524,7 @@ mod unix_signal_handler {
} }
#[allow(clippy::non_ascii_literal)] #[allow(clippy::non_ascii_literal)]
#[cfg(all( #[cfg(all(feature = "std", target_vendor = "apple", target_arch = "aarch64"))]
feature = "std",
any(target_os = "macos", target_os = "ios"),
target_arch = "aarch64"
))]
{ {
let mcontext = *_context.uc_mcontext; let mcontext = *_context.uc_mcontext;
println!("{:━^100}", " CRASH "); println!("{:━^100}", " CRASH ");

View File

@ -15,7 +15,7 @@ edition = "2018"
[build-dependencies] [build-dependencies]
cc = { version = "1.0", features = ["parallel"] } cc = { version = "1.0", features = ["parallel"] }
[target.'cfg(target_os = "macos")'.build-dependencies] [target.'cfg(target_vendor = "apple")'.build-dependencies]
glob = "0.3" glob = "0.3"
[dependencies] [dependencies]

View File

@ -1,9 +1,9 @@
use std::{env, fs::File, io::Write, path::Path, process::Command, str}; use std::{env, fs::File, io::Write, path::Path, process::Command, str};
#[cfg(target_os = "macos")] #[cfg(target_vendor = "apple")]
use glob::glob; use glob::glob;
#[cfg(target_os = "macos")] #[cfg(target_vendor = "apple")]
use std::path::PathBuf; use std::path::PathBuf;
fn dll_extension<'a>() -> &'a str { 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`. /// Github Actions for `MacOS` seems to have troubles finding `llvm-config`.
/// Hence, we go look for it ourselves. /// Hence, we go look for it ourselves.
#[cfg(target_os = "macos")] #[cfg(target_vendor = "apple")]
fn find_llvm_config_brew() -> Result<PathBuf, String> { fn find_llvm_config_brew() -> Result<PathBuf, String> {
match Command::new("brew").arg("--cellar").output() { match Command::new("brew").arg("--cellar").output() {
Ok(output) => { Ok(output) => {
@ -43,7 +43,7 @@ fn find_llvm_config_brew() -> Result<PathBuf, String> {
fn find_llvm_config() -> String { fn find_llvm_config() -> String {
env::var("LLVM_CONFIG").unwrap_or_else(|_| { env::var("LLVM_CONFIG").unwrap_or_else(|_| {
// for Ghithub Actions, we check if we find llvm-config in brew. // 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() { match find_llvm_config_brew() {
Ok(llvm_dir) => llvm_dir.to_str().unwrap().to_string(), Ok(llvm_dir) => llvm_dir.to_str().unwrap().to_string(),
Err(err) => { Err(err) => {
@ -52,7 +52,7 @@ fn find_llvm_config() -> String {
"llvm-config".to_string() "llvm-config".to_string()
} }
} }
#[cfg(not(target_os = "macos"))] #[cfg(not(target_vendor = "apple"))]
"llvm-config".to_string() "llvm-config".to_string()
}) })
} }
@ -103,10 +103,10 @@ fn main() {
let cxxflags: Vec<&str> = cxxflags.trim().split_whitespace().collect(); let cxxflags: Vec<&str> = cxxflags.trim().split_whitespace().collect();
let mut ldflags: Vec<&str> = ldflags.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. // Needed on macos.
// Explanation at https://github.com/banach-space/llvm-tutor/blob/787b09ed31ff7f0e7bdd42ae20547d27e2991512/lib/CMakeLists.txt#L59 // Explanation at https://github.com/banach-space/llvm-tutor/blob/787b09ed31ff7f0e7bdd42ae20547d27e2991512/lib/CMakeLists.txt#L59
"macos" | "ios" => { "apple" => {
ldflags.push("-undefined"); ldflags.push("-undefined");
ldflags.push("dynamic_lookup"); ldflags.push("dynamic_lookup");
} }

View File

@ -13,7 +13,7 @@ use crate::{CompilerWrapper, Error, LIB_EXT, LIB_PREFIX};
fn dll_extension<'a>() -> &'a str { fn dll_extension<'a>() -> &'a str {
if cfg!(target_os = "windows") { if cfg!(target_os = "windows") {
"dll" "dll"
} else if cfg!(any(target_os = "ios", target_os = "macos")) { } else if cfg!(target_vendor = "apple") {
"dylib" "dylib"
} else { } else {
"so" "so"
@ -130,7 +130,7 @@ impl CompilerWrapper for ClangWrapper {
new_args.push("-lAdvapi32".into()); new_args.push("-lAdvapi32".into());
} }
// MacOS has odd linker behavior sometimes // MacOS has odd linker behavior sometimes
#[cfg(any(target_os = "macos", target_os = "ios"))] #[cfg(target_vendor = "apple")]
if linking { if linking {
new_args.push("-undefined".into()); new_args.push("-undefined".into());
new_args.push("dynamic_lookup".into()); new_args.push("dynamic_lookup".into());
@ -168,7 +168,7 @@ impl CompilerWrapper for ClangWrapper {
where where
S: AsRef<str>, S: AsRef<str>,
{ {
if cfg!(any(target_os = "macos", target_os = "ios")) { if cfg!(target_vendor = "apple") {
//self.add_link_arg("-force_load".into())?; //self.add_link_arg("-force_load".into())?;
} else { } else {
self.add_link_arg("-Wl,--whole-archive"); self.add_link_arg("-Wl,--whole-archive");
@ -179,7 +179,7 @@ impl CompilerWrapper for ClangWrapper {
.into_string() .into_string()
.unwrap(), .unwrap(),
); );
if cfg!(any(target_os = "macos", target_os = "ios")) { if cfg!(target_vendor = "apple") {
self self
} else { } else {
self.add_link_arg("-Wl,-no-whole-archive") self.add_link_arg("-Wl,-no-whole-archive")

View File

@ -35,9 +35,9 @@ pub(crate) struct Allocator {
current_mapping_addr: usize, current_mapping_addr: usize,
} }
#[cfg(any(target_os = "macos", target_os = "ios"))] #[cfg(target_vendor = "apple")]
const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANON; 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; const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANONYMOUS;
macro_rules! map_to_shadow { macro_rules! map_to_shadow {

View File

@ -29,9 +29,9 @@ use frida_gum::{Gum, ModuleMap};
use libc::RLIMIT_STACK; use libc::RLIMIT_STACK;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use libc::{c_char, wchar_t}; use libc::{c_char, wchar_t};
#[cfg(any(target_os = "macos", target_os = "ios"))] #[cfg(target_vendor = "apple")]
use libc::{getrlimit, rlimit}; 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 libc::{getrlimit64, rlimit64};
use std::{ffi::c_void, ptr::write_volatile}; use std::{ffi::c_void, ptr::write_volatile};
@ -50,9 +50,9 @@ extern "C" {
fn tls_ptr() -> *const c_void; 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; 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; const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANONYMOUS;
/// The frida address sanitizer runtime, providing address sanitization. /// The frida address sanitizer runtime, providing address sanitization.
@ -210,7 +210,7 @@ impl AsanRuntime {
/// Get the maximum stack size for the current stack /// Get the maximum stack size for the current stack
#[must_use] #[must_use]
#[cfg(any(target_os = "macos", target_os = "ios"))] #[cfg(target_vendor = "apple")]
fn max_stack_size() -> usize { fn max_stack_size() -> usize {
let mut stack_rlimit = rlimit { let mut stack_rlimit = rlimit {
rlim_cur: 0, rlim_cur: 0,
@ -223,7 +223,7 @@ impl AsanRuntime {
/// Get the maximum stack size for the current stack /// Get the maximum stack size for the current stack
#[must_use] #[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 { fn max_stack_size() -> usize {
let mut stack_rlimit = rlimit64 { let mut stack_rlimit = rlimit64 {
rlim_cur: 0, rlim_cur: 0,
@ -254,7 +254,7 @@ impl AsanRuntime {
let max_start = end - Self::max_stack_size(); let max_start = end - Self::max_stack_size();
let flags = ANONYMOUS_FLAG | MapFlags::MAP_FIXED | MapFlags::MAP_PRIVATE; 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; let flags = flags | MapFlags::MAP_STACK;
if start != max_start { 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] #[inline]
fn hook_memalign(&mut self, alignment: usize, size: usize) -> *mut c_void { fn hook_memalign(&mut self, alignment: usize, size: usize) -> *mut c_void {
unsafe { self.allocator.alloc(size, alignment) } unsafe { self.allocator.alloc(size, alignment) }
@ -420,7 +420,7 @@ impl AsanRuntime {
} }
#[inline] #[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 { fn hook_malloc_usable_size(&mut self, ptr: *mut c_void) -> usize {
self.allocator.get_usable_size(ptr) self.allocator.get_usable_size(ptr)
} }
@ -708,7 +708,7 @@ impl AsanRuntime {
} }
#[inline] #[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 { fn hook_mempcpy(&mut self, dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void {
extern "C" { extern "C" {
fn mempcpy(dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void; fn mempcpy(dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void;
@ -810,7 +810,7 @@ impl AsanRuntime {
} }
#[inline] #[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 { fn hook_memrchr(&mut self, s: *mut c_void, c: i32, n: usize) -> *mut c_void {
extern "C" { extern "C" {
fn memrchr(s: *mut c_void, c: i32, n: usize) -> *mut c_void; fn memrchr(s: *mut c_void, c: i32, n: usize) -> *mut c_void;
@ -894,7 +894,7 @@ impl AsanRuntime {
#[cfg(all( #[cfg(all(
not(target_os = "android"), not(target_os = "android"),
target_arch = "aarch64", target_arch = "aarch64",
not(target_os = "macos") not(target_vendor = "apple")
))] ))]
#[inline] #[inline]
fn hook_explicit_bzero(&mut self, s: *mut c_void, n: usize) { 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, calloc, (nmemb: usize, size: usize), *mut c_void);
hook_func!(None, realloc, (ptr: *mut c_void, 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), ()); 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, memalign, (size: usize, alignment: usize), *mut c_void);
hook_func!( hook_func!(
None, None,
@ -1602,7 +1602,7 @@ impl AsanRuntime {
(pptr: *mut *mut c_void, size: usize, alignment: usize), (pptr: *mut *mut c_void, size: usize, alignment: usize),
i32 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, malloc_usable_size, (ptr: *mut c_void), usize);
hook_func!(None, _Znam, (size: usize), *mut c_void); hook_func!(None, _Znam, (size: usize), *mut c_void);
hook_func!( hook_func!(
@ -1736,7 +1736,7 @@ impl AsanRuntime {
(dest: *mut c_void, src: *const c_void, n: usize), (dest: *mut c_void, src: *const c_void, n: usize),
*mut c_void *mut c_void
); );
#[cfg(not(target_os = "macos"))] #[cfg(not(target_vendor = "apple"))]
hook_func!( hook_func!(
None, None,
mempcpy, mempcpy,
@ -1761,7 +1761,7 @@ impl AsanRuntime {
(s: *mut c_void, c: i32, n: usize), (s: *mut c_void, c: i32, n: usize),
*mut c_void *mut c_void
); );
#[cfg(not(target_os = "macos"))] #[cfg(not(target_vendor = "apple"))]
hook_func!( hook_func!(
None, None,
memrchr, memrchr,
@ -1781,7 +1781,7 @@ impl AsanRuntime {
); );
#[cfg(not(target_os = "android"))] #[cfg(not(target_os = "android"))]
hook_func!(None, bzero, (s: *mut c_void, n: usize), ()); 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), ()); hook_func!(None, explicit_bzero, (s: *mut c_void, n: usize), ());
#[cfg(not(target_os = "android"))] #[cfg(not(target_os = "android"))]
hook_func!( hook_func!(

View File

@ -46,9 +46,9 @@ enum CmplogOperandType {
Mem(capstone::RegId, capstone::RegId, i32, u32), 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; 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; const ANONYMOUS_FLAG: MapFlags = MapFlags::MAP_ANONYMOUS;
/// An helper that feeds [`FridaInProcessExecutor`] with user-supplied instrumentation /// An helper that feeds [`FridaInProcessExecutor`] with user-supplied instrumentation