CI and fixes for arm32 no_std build (#511)
* arm32 no_std fixes and clippy * moved criterion to benches crate * benches no longer live here
This commit is contained in:
parent
e307dfb16f
commit
9dfc6aa404
4
.github/workflows/build_and_test.yml
vendored
4
.github/workflows/build_and_test.yml
vendored
@ -118,7 +118,7 @@ jobs:
|
|||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- name: Add nightly rustfmt and clippy
|
- name: Add nightly rustfmt and clippy
|
||||||
run: rustup toolchain install nightly && rustup target add --toolchain nightly aarch64-unknown-none && rustup component add --toolchain nightly rust-src
|
run: rustup toolchain install nightly && rustup target add --toolchain nightly aarch64-unknown-none && rustup component add --toolchain nightly rust-src && rustup target add thumbv6m-none-eabi
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build aarch64-unknown-none
|
- name: Build aarch64-unknown-none
|
||||||
run: cd ./fuzzers/baby_no_std && cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --release && cd ../..
|
run: cd ./fuzzers/baby_no_std && cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --release && cd ../..
|
||||||
@ -126,6 +126,8 @@ jobs:
|
|||||||
run: cd ./fuzzers/baby_no_std && cargo +nightly run || test $? -ne 0 || exit 1
|
run: cd ./fuzzers/baby_no_std && cargo +nightly run || test $? -ne 0 || exit 1
|
||||||
- name: no_std tests
|
- name: no_std tests
|
||||||
run: cd ./libafl && cargo test --no-default-features
|
run: cd ./libafl && cargo test --no-default-features
|
||||||
|
- name: armv6m-none-eabi (32 bit no_std) clippy
|
||||||
|
run: cd ./libafl && cargo clippy --target thumbv6m-none-eabi --no-default-features
|
||||||
build-docker:
|
build-docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -19,6 +19,7 @@ members = [
|
|||||||
"libafl_concolic/test/runtime_test",
|
"libafl_concolic/test/runtime_test",
|
||||||
"utils/deexit",
|
"utils/deexit",
|
||||||
"utils/gramatron/construct_automata",
|
"utils/gramatron/construct_automata",
|
||||||
|
"utils/libafl_benches",
|
||||||
]
|
]
|
||||||
default-members = [
|
default-members = [
|
||||||
"libafl",
|
"libafl",
|
||||||
|
@ -29,7 +29,6 @@ COPY libafl_derive/Cargo.toml libafl_derive/Cargo.toml
|
|||||||
COPY scripts/dummy.rs libafl_derive/src/lib.rs
|
COPY scripts/dummy.rs libafl_derive/src/lib.rs
|
||||||
|
|
||||||
COPY libafl/Cargo.toml libafl/build.rs libafl/
|
COPY libafl/Cargo.toml libafl/build.rs libafl/
|
||||||
COPY libafl/benches libafl/benches
|
|
||||||
COPY libafl/examples libafl/examples
|
COPY libafl/examples libafl/examples
|
||||||
COPY scripts/dummy.rs libafl/src/lib.rs
|
COPY scripts/dummy.rs libafl/src/lib.rs
|
||||||
|
|
||||||
|
@ -38,11 +38,7 @@ llmp_small_maps = [] # reduces initial map size for llmp
|
|||||||
rustversion = "1.0"
|
rustversion = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.3" # Benchmarking
|
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||||
ahash = "0.7" # another hash
|
|
||||||
fxhash = "0.2.1" # yet another hash
|
|
||||||
xxhash-rust = { version = "0.8.2", features = ["xxh3"] } # xxh3 hashing for rust
|
|
||||||
serde_json = "1.0"
|
|
||||||
num_cpus = "1.0" # cpu count, for llmp example
|
num_cpus = "1.0" # cpu count, for llmp example
|
||||||
serial_test = "0.5"
|
serial_test = "0.5"
|
||||||
|
|
||||||
@ -100,14 +96,6 @@ windows = { version = "0.29.0", features = ["std", "Win32_Foundation", "Win32_Sy
|
|||||||
[target.'cfg(windows)'.build-dependencies]
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
windows = "0.29.0"
|
windows = "0.29.0"
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "rand_speeds"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "hash_speeds"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
#[profile.release]
|
#[profile.release]
|
||||||
#lto = true
|
#lto = true
|
||||||
#opt-level = 3
|
#opt-level = 3
|
||||||
|
@ -33,6 +33,7 @@ pub fn read_time_counter() -> u64 {
|
|||||||
/// change this implementation rather than every instead of [`read_time_counter`]
|
/// change this implementation rather than every instead of [`read_time_counter`]
|
||||||
/// On unsupported architectures, it's falling back to normal system time, in millis.
|
/// On unsupported architectures, it's falling back to normal system time, in millis.
|
||||||
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
|
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
|
||||||
|
#[must_use]
|
||||||
pub fn read_time_counter() -> u64 {
|
pub fn read_time_counter() -> u64 {
|
||||||
current_nanos()
|
current_nanos()
|
||||||
}
|
}
|
||||||
|
@ -60,13 +60,17 @@ For broker2broker communication, all messages are forwarded via network sockets.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use alloc::{string::String, vec::Vec};
|
use alloc::{string::String, vec::Vec};
|
||||||
|
#[cfg(not(target_pointer_width = "64"))]
|
||||||
|
use core::sync::atomic::AtomicU32;
|
||||||
|
#[cfg(target_pointer_width = "64")]
|
||||||
|
use core::sync::atomic::AtomicU64;
|
||||||
use core::{
|
use core::{
|
||||||
cmp::max,
|
cmp::max,
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
hint,
|
hint,
|
||||||
mem::size_of,
|
mem::size_of,
|
||||||
ptr, slice,
|
ptr, slice,
|
||||||
sync::atomic::{fence, AtomicU16, AtomicU64, Ordering},
|
sync::atomic::{fence, AtomicU16, Ordering},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -173,7 +177,11 @@ pub type BrokerId = u32;
|
|||||||
/// The flags, indicating, for example, enabled compression.
|
/// The flags, indicating, for example, enabled compression.
|
||||||
pub type Flags = u32;
|
pub type Flags = u32;
|
||||||
/// The message ID, an ever-increasing number, unique only to a sharedmap/page.
|
/// The message ID, an ever-increasing number, unique only to a sharedmap/page.
|
||||||
|
#[cfg(target_pointer_width = "64")]
|
||||||
pub type MessageId = u64;
|
pub type MessageId = u64;
|
||||||
|
/// The message ID, an ever-increasing number, unique only to a sharedmap/page.
|
||||||
|
#[cfg(not(target_pointer_width = "64"))]
|
||||||
|
pub type MessageId = u32;
|
||||||
|
|
||||||
/// This is for the server the broker will spawn.
|
/// This is for the server the broker will spawn.
|
||||||
/// If an llmp connection is local - use sharedmaps
|
/// If an llmp connection is local - use sharedmaps
|
||||||
@ -519,7 +527,7 @@ pub struct LlmpMsg {
|
|||||||
/// flags, currently only used for indicating compression
|
/// flags, currently only used for indicating compression
|
||||||
pub flags: Flags, //u32
|
pub flags: Flags, //u32
|
||||||
/// The message ID, unique per page
|
/// The message ID, unique per page
|
||||||
pub message_id: MessageId, //u64
|
pub message_id: MessageId, //u64 on 64 bit, else u32
|
||||||
/// Buffer length as specified by the user
|
/// Buffer length as specified by the user
|
||||||
pub buf_len: u64,
|
pub buf_len: u64,
|
||||||
/// (Actual) buffer length after padding
|
/// (Actual) buffer length after padding
|
||||||
@ -684,8 +692,12 @@ pub struct LlmpPage {
|
|||||||
pub safe_to_unmap: AtomicU16,
|
pub safe_to_unmap: AtomicU16,
|
||||||
/// Not used at the moment (would indicate that the sender is no longer there)
|
/// Not used at the moment (would indicate that the sender is no longer there)
|
||||||
pub sender_dead: AtomicU16,
|
pub sender_dead: AtomicU16,
|
||||||
|
#[cfg(target_pointer_width = "64")]
|
||||||
/// The current message ID
|
/// The current message ID
|
||||||
pub current_msg_id: AtomicU64,
|
pub current_msg_id: AtomicU64,
|
||||||
|
#[cfg(not(target_pointer_width = "64"))]
|
||||||
|
/// The current message ID
|
||||||
|
pub current_msg_id: AtomicU32,
|
||||||
/// How much space is available on this page in bytes
|
/// How much space is available on this page in bytes
|
||||||
pub size_total: usize,
|
pub size_total: usize,
|
||||||
/// How much space is used on this page in bytes
|
/// How much space is used on this page in bytes
|
||||||
@ -1300,7 +1312,7 @@ where
|
|||||||
/// current page. After EOP, this gets replaced with the new one
|
/// current page. After EOP, this gets replaced with the new one
|
||||||
pub current_recv_shmem: LlmpSharedMap<SP::ShMem>,
|
pub current_recv_shmem: LlmpSharedMap<SP::ShMem>,
|
||||||
/// Caches the highest msg id we've seen so far
|
/// Caches the highest msg id we've seen so far
|
||||||
highest_msg_id: u64,
|
highest_msg_id: MessageId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receiving end of an llmp channel
|
/// Receiving end of an llmp channel
|
||||||
@ -2325,7 +2337,7 @@ where
|
|||||||
msg_buf_len_padded,
|
msg_buf_len_padded,
|
||||||
size_of::<LlmpPayloadSharedMapInfo>()
|
size_of::<LlmpPayloadSharedMapInfo>()
|
||||||
)));
|
)));
|
||||||
} else {
|
}
|
||||||
let pageinfo = (*msg).buf.as_mut_ptr() as *mut LlmpPayloadSharedMapInfo;
|
let pageinfo = (*msg).buf.as_mut_ptr() as *mut LlmpPayloadSharedMapInfo;
|
||||||
|
|
||||||
match self.shmem_provider.shmem_from_id_and_size(
|
match self.shmem_provider.shmem_from_id_and_size(
|
||||||
@ -2356,7 +2368,6 @@ where
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// handle all other messages
|
// handle all other messages
|
||||||
_ => {
|
_ => {
|
||||||
// The message is not specifically for use. Let the user handle it, then forward it to the clients, if necessary.
|
// The message is not specifically for use. Let the user handle it, then forward it to the clients, if necessary.
|
||||||
|
@ -69,7 +69,7 @@ pub fn current_time() -> time::Duration {
|
|||||||
SystemTime::now().duration_since(UNIX_EPOCH).unwrap()
|
SystemTime::now().duration_since(UNIX_EPOCH).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// external defined function in case of no_std
|
/// external defined function in case of `no_std`
|
||||||
///
|
///
|
||||||
/// Define your own `external_current_millis()` function via `extern "C"`
|
/// Define your own `external_current_millis()` function via `extern "C"`
|
||||||
/// which is linked into the binary and called from here.
|
/// which is linked into the binary and called from here.
|
||||||
@ -79,9 +79,10 @@ extern "C" {
|
|||||||
fn external_current_millis() -> u64;
|
fn external_current_millis() -> u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Current time (fixed fallback for no_std)
|
/// Current time (fixed fallback for `no_std`)
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn current_time() -> time::Duration {
|
pub fn current_time() -> time::Duration {
|
||||||
let millis = unsafe { external_current_millis() };
|
let millis = unsafe { external_current_millis() };
|
||||||
time::Duration::from_millis(millis)
|
time::Duration::from_millis(millis)
|
||||||
|
@ -235,6 +235,7 @@ pub struct InProcessHandlers {
|
|||||||
|
|
||||||
impl InProcessHandlers {
|
impl InProcessHandlers {
|
||||||
/// Call before running a target.
|
/// Call before running a target.
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
pub fn pre_run_target<E, EM, I, S, Z>(
|
pub fn pre_run_target<E, EM, I, S, Z>(
|
||||||
&self,
|
&self,
|
||||||
_executor: &E,
|
_executor: &E,
|
||||||
|
@ -459,6 +459,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::cast_lossless)]
|
||||||
if mopt.pilot_time > mopt.period_pilot {
|
if mopt.pilot_time > mopt.period_pilot {
|
||||||
let new_finds = mopt.total_finds - mopt.finds_until_last_swarm;
|
let new_finds = mopt.total_finds - mopt.finds_until_last_swarm;
|
||||||
let f = (new_finds as f64) / ((mopt.pilot_time as f64) / (PERIOD_PILOT_COEF));
|
let f = (new_finds as f64) / ((mopt.pilot_time as f64) / (PERIOD_PILOT_COEF));
|
||||||
|
@ -12,3 +12,8 @@ Abort, on the other hand, raises an error LibAFL's inprocess executor will be ab
|
|||||||
## Gramatron: gramatron grammars and preprocessing utils
|
## Gramatron: gramatron grammars and preprocessing utils
|
||||||
|
|
||||||
See https://github.com/HexHive/Gramatron
|
See https://github.com/HexHive/Gramatron
|
||||||
|
|
||||||
|
## libafl_benches
|
||||||
|
|
||||||
|
This folder contains benchmarks for various things in LibAFL, like hash speeds and RNGs.
|
||||||
|
Run with `cargo bench`
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "deexit"
|
name = "deexit"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
20
utils/libafl_benches/Cargo.toml
Normal file
20
utils/libafl_benches/Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[package]
|
||||||
|
name = "libafl_benches"
|
||||||
|
version = "0.7.1"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
criterion = "0.3" # Benchmarking
|
||||||
|
ahash = { version = "0.7", default-features=false, features=["compile-time-rng"] } # The hash function already used in hashbrown
|
||||||
|
rustc-hash = { version = "1.0", default-features=false } # yet another hash
|
||||||
|
xxhash-rust = { version = "0.8.2", features = ["xxh3"] } # xxh3 hashing for rust
|
||||||
|
libafl = { path = "../../libafl", default-features=false } # libafl
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "rand_speeds"
|
||||||
|
harness = false
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "hash_speeds"
|
||||||
|
harness = false
|
||||||
|
|
@ -28,7 +28,11 @@ fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
c.bench_function("fxhash", |b| {
|
c.bench_function("fxhash", |b| {
|
||||||
b.iter(|| fxhash::hash64(black_box(&bench_vec)))
|
b.iter(|| {
|
||||||
|
let mut hasher = rustc_hash::FxHasher::default();
|
||||||
|
hasher.write(black_box(&bench_vec));
|
||||||
|
hasher.finish()
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user