Make all no_mangle fns extern "C" (#1369)

This commit is contained in:
Dominik Maier 2023-07-14 17:42:58 +02:00 committed by GitHub
parent eb362c5c77
commit 003b219826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 19 additions and 19 deletions

View File

@ -1,7 +1,7 @@
use libafl_targets::{map_shared_memory, start_forkserver}; use libafl_targets::{map_shared_memory, start_forkserver};
#[no_mangle] #[no_mangle]
pub fn libafl_start_forkserver() { pub extern "C" fn libafl_start_forkserver() {
// Map shared memory region for the edge coverage map // Map shared memory region for the edge coverage map
map_shared_memory(); map_shared_memory();
// Start the forkserver // Start the forkserver

View File

@ -57,7 +57,7 @@ use nix::{self, unistd::dup};
/// The fuzzer main (as `no_mangle` C function) /// The fuzzer main (as `no_mangle` C function)
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -64,7 +64,7 @@ use nix::{self, unistd::dup};
/// The fuzzer main (as `no_mangle` C function) /// The fuzzer main (as `no_mangle` C function)
#[no_mangle] #[no_mangle]
#[allow(clippy::too_many_lines)] #[allow(clippy::too_many_lines)]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -48,7 +48,7 @@ use libafl_targets::{
/// Set up our coverage map. /// Set up our coverage map.
#[no_mangle] #[no_mangle]
pub fn __sanitizer_cov_8bit_counters_init(start: *mut u8, stop: *mut u8) { pub extern "C" fn __sanitizer_cov_8bit_counters_init(start: *mut u8, stop: *mut u8) {
unsafe { unsafe {
EDGES_MAP_PTR = start; EDGES_MAP_PTR = start;
MAX_EDGES_NUM = (stop as usize - start as usize) / 8; MAX_EDGES_NUM = (stop as usize - start as usize) / 8;
@ -58,7 +58,7 @@ pub fn __sanitizer_cov_8bit_counters_init(start: *mut u8, stop: *mut u8) {
/// `pcs` tables seem to be unused by `Atheris`, so we can ignore this setup function, /// `pcs` tables seem to be unused by `Atheris`, so we can ignore this setup function,
/// but the symbol is still being called and, hence, required. /// but the symbol is still being called and, hence, required.
#[no_mangle] #[no_mangle]
pub fn __sanitizer_cov_pcs_init(_pcs_beg: *mut u8, _pcs_end: *mut u8) { pub extern "C" fn __sanitizer_cov_pcs_init(_pcs_beg: *mut u8, _pcs_end: *mut u8) {
// noop // noop
} }
@ -66,7 +66,7 @@ pub fn __sanitizer_cov_pcs_init(_pcs_beg: *mut u8, _pcs_end: *mut u8) {
/// This is a PoC implementation and could be improved. /// This is a PoC implementation and could be improved.
/// For example, it only takes up to 8 bytes into consideration. /// For example, it only takes up to 8 bytes into consideration.
#[no_mangle] #[no_mangle]
pub fn __sanitizer_weak_hook_memcmp( pub extern "C" fn __sanitizer_weak_hook_memcmp(
_caller_pc: *const c_void, _caller_pc: *const c_void,
s1: *const c_void, s1: *const c_void,
s2: *const c_void, s2: *const c_void,
@ -104,7 +104,7 @@ pub fn __sanitizer_weak_hook_memcmp(
/// and jumps back into `Atheris'` instrumented python code. /// and jumps back into `Atheris'` instrumented python code.
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn LLVMFuzzerRunDriver( pub extern "C" fn LLVMFuzzerRunDriver(
_argc: *const c_int, _argc: *const c_int,
_argv: *const *const c_char, _argv: *const *const c_char,
harness_fn: Option<extern "C" fn(*const u8, usize) -> c_int>, harness_fn: Option<extern "C" fn(*const u8, usize) -> c_int>,

View File

@ -42,7 +42,7 @@ extern "C" {
/// The main fn, usually parsing parameters, and starting the fuzzer /// The main fn, usually parsing parameters, and starting the fuzzer
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -41,7 +41,7 @@ use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, EDGES_MAP,
/// The main fn, `no_mangle` as it is a C main /// The main fn, `no_mangle` as it is a C main
#[cfg(not(test))] #[cfg(not(test))]
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -113,7 +113,7 @@ struct Opt {
/// The main fn, `no_mangle` as it is a C symbol /// The main fn, `no_mangle` as it is a C symbol
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -112,7 +112,7 @@ struct Opt {
/// The main fn, `no_mangle` as it is a C symbol /// The main fn, `no_mangle` as it is a C symbol
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
env_logger::init(); env_logger::init();
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer

View File

@ -44,7 +44,7 @@ use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, std_edges_m
/// The main fn, `no_mangle` as it is a C main /// The main fn, `no_mangle` as it is a C main
#[cfg(not(test))] #[cfg(not(test))]
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -108,7 +108,7 @@ struct Opt {
/// The main fn, `no_mangle` as it is a C symbol /// The main fn, `no_mangle` as it is a C symbol
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -111,7 +111,7 @@ struct Opt {
/// The main fn, `no_mangle` as it is a C symbol /// The main fn, `no_mangle` as it is a C symbol
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -129,7 +129,7 @@ struct Opt {
/// The main fn, `no_mangle` as it is a C symbol /// The main fn, `no_mangle` as it is a C symbol
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -32,7 +32,7 @@ extern "C" {
/// The main fn, `no_mangle` as it is a C symbol /// The main fn, `no_mangle` as it is a C symbol
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -27,7 +27,7 @@ use libafl::{
}; };
use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, std_edges_map_observer}; use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, std_edges_map_observer};
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
println!( println!(
"Workdir: {:?}", "Workdir: {:?}",
env::current_dir().unwrap().to_string_lossy().to_string() env::current_dir().unwrap().to_string_lossy().to_string()

View File

@ -100,7 +100,7 @@ struct Opt {
/// The main fn, `no_mangle` as it is a C symbol /// The main fn, `no_mangle` as it is a C symbol
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();

View File

@ -36,7 +36,7 @@ use metadata::*;
/// The main fn, `no_mangle` as it is a C main /// The main fn, `no_mangle` as it is a C main
#[cfg(not(test))] #[cfg(not(test))]
#[no_mangle] #[no_mangle]
pub fn libafl_main() { pub extern "C" fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();