more no_std work
This commit is contained in:
parent
933e8588ee
commit
5ad556b419
@ -1,3 +1,6 @@
|
|||||||
|
#[macro_use]
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
use core::ffi::c_void;
|
use core::ffi::c_void;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
@ -16,7 +19,7 @@ unsafe fn llmp_test_clientloop(client: *mut llmp_client, _data: *mut c_void) ->
|
|||||||
counter += 1;
|
counter += 1;
|
||||||
|
|
||||||
let llmp_message = llmp_client_alloc_next(client, size_of::<u32>());
|
let llmp_message = llmp_client_alloc_next(client, size_of::<u32>());
|
||||||
std::ptr::copy(
|
core::ptr::copy(
|
||||||
counter.to_be_bytes().as_ptr(),
|
counter.to_be_bytes().as_ptr(),
|
||||||
(*llmp_message).buf.as_mut_ptr(),
|
(*llmp_message).buf.as_mut_ptr(),
|
||||||
size_of::<u32>(),
|
size_of::<u32>(),
|
||||||
@ -30,7 +33,7 @@ unsafe fn llmp_test_clientloop(client: *mut llmp_client, _data: *mut c_void) ->
|
|||||||
|
|
||||||
unsafe fn u32_from_msg(message: *const llmp_message) -> u32 {
|
unsafe fn u32_from_msg(message: *const llmp_message) -> u32 {
|
||||||
u32::from_be_bytes(
|
u32::from_be_bytes(
|
||||||
std::slice::from_raw_parts((*message).buf.as_ptr(), size_of::<u32>())
|
alloc::slice::from_raw_parts((*message).buf.as_ptr(), size_of::<u32>())
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
@ -62,7 +65,7 @@ unsafe fn test_adder_clientloop(client: *mut llmp_client, _data: *mut c_void) ->
|
|||||||
);
|
);
|
||||||
|
|
||||||
let llmp_message = llmp_client_alloc_next(client, size_of::<u32>());
|
let llmp_message = llmp_client_alloc_next(client, size_of::<u32>());
|
||||||
std::ptr::copy(
|
core::ptr::copy(
|
||||||
current_result.to_be_bytes().as_ptr(),
|
current_result.to_be_bytes().as_ptr(),
|
||||||
(*llmp_message).buf.as_mut_ptr(),
|
(*llmp_message).buf.as_mut_ptr(),
|
||||||
size_of::<u32>(),
|
size_of::<u32>(),
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub mod llmp;
|
pub mod llmp;
|
||||||
|
|
||||||
|
use alloc::borrow::ToOwned;
|
||||||
|
use alloc::string::String;
|
||||||
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub mod llmp_translated; // TODO: Abstract away.
|
pub mod llmp_translated; // TODO: Abstract away.
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
@ -9,7 +14,7 @@ pub mod shmem_translated;
|
|||||||
pub use crate::events::llmp::LLMP;
|
pub use crate::events::llmp::LLMP;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::{io::Write, marker::PhantomData};
|
use std::io::Write;
|
||||||
|
|
||||||
use crate::corpus::{Corpus, Testcase};
|
use crate::corpus::{Corpus, Testcase};
|
||||||
use crate::engines::State;
|
use crate::engines::State;
|
||||||
@ -190,6 +195,7 @@ where
|
|||||||
_marker,
|
_marker,
|
||||||
} => {
|
} => {
|
||||||
//TODO: broker.log()
|
//TODO: broker.log()
|
||||||
|
#[cfg(feature = "std")]
|
||||||
println!("{}[{}]: {}", sender_id, severity_level, message);
|
println!("{}[{}]: {}", sender_id, severity_level, message);
|
||||||
Ok(BrokerEventResult::Handled)
|
Ok(BrokerEventResult::Handled)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
use std::boxed::Box;
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
use std::cell::RefCell;
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::boxed::Box;
|
||||||
|
use alloc::rc::Rc;
|
||||||
|
use core::cell::RefCell;
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
use std::io::stderr;
|
use std::io::stderr;
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use afl::corpus::InMemoryCorpus;
|
use afl::corpus::InMemoryCorpus;
|
||||||
use afl::engines::{generate_initial_inputs, Engine, State, StdEngine, StdState};
|
use afl::engines::{generate_initial_inputs, Engine, State, StdEngine, StdState};
|
||||||
@ -40,6 +47,9 @@ pub extern "C" fn afl_libfuzzer_main() {
|
|||||||
|
|
||||||
let mut corpus = InMemoryCorpus::new();
|
let mut corpus = InMemoryCorpus::new();
|
||||||
let mut generator = RandPrintablesGenerator::new(32);
|
let mut generator = RandPrintablesGenerator::new(32);
|
||||||
|
|
||||||
|
// TODO: No_std event manager
|
||||||
|
#[cfg(feature = "std")]
|
||||||
let mut events = LoggerEventManager::new(stderr());
|
let mut events = LoggerEventManager::new(stderr());
|
||||||
|
|
||||||
let edges_observer = Rc::new(RefCell::new(StdMapObserver::new_from_ptr(
|
let edges_observer = Rc::new(RefCell::new(StdMapObserver::new_from_ptr(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user