no_std builds again

This commit is contained in:
Dominik Maier 2020-12-17 15:18:27 +01:00
parent 91a672c5ea
commit 2a86c89119
5 changed files with 23 additions and 14 deletions

View File

@ -55,6 +55,8 @@ use core::{
sync::atomic::{compiler_fence, Ordering}, sync::atomic::{compiler_fence, Ordering},
time::Duration, time::Duration,
}; };
#[cfg(feature = "std")]
use std::{ use std::{
io::{Read, Write}, io::{Read, Write},
net::{TcpListener, TcpStream}, net::{TcpListener, TcpStream},
@ -64,6 +66,7 @@ use std::{
use crate::utils::next_pow2; use crate::utils::next_pow2;
use crate::AflError; use crate::AflError;
#[cfg(feature = "std")]
use super::shmem_translated::AflShmem; use super::shmem_translated::AflShmem;
/// We'll start off with 256 megabyte maps per fuzzer client /// We'll start off with 256 megabyte maps per fuzzer client

View File

@ -1,31 +1,29 @@
// TODO: llmp can be no_std, if we abstract away page creation
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub mod llmp; pub mod llmp;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub mod shmem_translated; pub mod shmem_translated;
use alloc::string::String; use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::time::Duration;
use core::{marker::PhantomData, time}; use core::{marker::PhantomData, time};
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
//#[cfg(feature = "std")]
//pub mod shmem_translated;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::time::Duration; use self::llmp::Tag;
use crate::corpus::Corpus; use crate::corpus::Corpus;
use crate::executors::Executor; use crate::executors::Executor;
use crate::feedbacks::FeedbacksTuple; use crate::feedbacks::FeedbacksTuple;
use crate::inputs::Input; use crate::inputs::Input;
use crate::observers::ObserversTuple; use crate::observers::ObserversTuple;
#[cfg(feature = "std")]
use crate::serde_anymap::Ptr; use crate::serde_anymap::Ptr;
use crate::utils::Rand; use crate::utils::Rand;
use crate::AflError; use crate::AflError;
use crate::{engines::State, utils}; use crate::{engines::State, utils};
use self::llmp::Tag;
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
/// Indicate if an event worked or not /// Indicate if an event worked or not
pub enum BrokerEventResult { pub enum BrokerEventResult {
@ -377,6 +375,8 @@ where
message, message,
phantom: _, phantom: _,
} => { } => {
let (_, _) = (message, severity_level);
#[cfg(feature = "std")]
println!("[LOG {}]: {}", severity_level, message); println!("[LOG {}]: {}", severity_level, message);
Ok(BrokerEventResult::Handled) Ok(BrokerEventResult::Handled)
} //_ => Ok(BrokerEventResult::Forward), } //_ => Ok(BrokerEventResult::Forward),
@ -725,6 +725,7 @@ where
phantom: PhantomData<(C, E, OT, FT, I, R)>, phantom: PhantomData<(C, E, OT, FT, I, R)>,
} }
#[cfg(feature = "std")]
impl<C, E, OT, FT, I, R, ST> LlmpEventManager<C, E, OT, FT, I, R, ST> impl<C, E, OT, FT, I, R, ST> LlmpEventManager<C, E, OT, FT, I, R, ST>
where where
C: Corpus<I, R>, C: Corpus<I, R>,

View File

@ -1,3 +1,4 @@
use alloc::string::{String, ToString};
use alloc::vec::Vec; use alloc::vec::Vec;
use core::marker::PhantomData; use core::marker::PhantomData;
use num::Integer; use num::Integer;
@ -254,7 +255,7 @@ where
pub fn with_history_map(name: &'static str, history_map: Vec<T>) -> Self { pub fn with_history_map(name: &'static str, history_map: Vec<T>) -> Self {
Self { Self {
history_map: history_map, history_map: history_map,
name: name.into(), name: name.to_string(),
phantom: PhantomData, phantom: PhantomData,
} }
} }

View File

@ -1,5 +1,7 @@
extern crate num; extern crate num;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::serde_anymap::ArrayMut; use crate::serde_anymap::ArrayMut;
@ -186,7 +188,7 @@ where
let initial = if map.len() > 0 { map[0] } else { T::default() }; let initial = if map.len() > 0 { map[0] } else { T::default() };
Self { Self {
map: ArrayMut::Cptr((map.as_mut_ptr(), map.len())), map: ArrayMut::Cptr((map.as_mut_ptr(), map.len())),
name: name.into(), name: name.to_string(),
initial, initial,
} }
} }
@ -197,7 +199,7 @@ where
let initial = if len > 0 { *map_ptr } else { T::default() }; let initial = if len > 0 { *map_ptr } else { T::default() };
StdMapObserver { StdMapObserver {
map: ArrayMut::Cptr((map_ptr, len)), map: ArrayMut::Cptr((map_ptr, len)),
name: name.into(), name: name.to_string(),
initial, initial,
} }
} }

View File

@ -84,8 +84,10 @@ pub fn current_time() -> time::Duration {
/// Current time (fixed fallback for no_std) /// Current time (fixed fallback for no_std)
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
#[inline] #[inline]
fn current_time() -> time::Duration { pub fn current_time() -> time::Duration {
self.start_time() // We may not have a rt clock available.
// TODO: Make it somehow plugin-able
time::Duration::from_millis(1)
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]