* Introduce a `TargetFrontendConfig` type. `TargetFrontendConfig` is information specific to the target which is provided to frontends to allow them to produce Cranelift IR for the target. Currently this includes the pointer size and the default calling convention. The default calling convention is now inferred from the target, rather than being a setting. cranelift-native is now just a provider of target information, rather than also being a provider of settings, which gives it a clearer role. And instead of having cranelift-frontend routines require the whole `TargetIsa`, just require the `TargetFrontendConfig`, and add a way to get the `TargetFrontendConfig` from a `Module`. Fixes #529. Fixes #555.
26 lines
774 B
Rust
26 lines
774 B
Rust
#![no_main]
|
|
|
|
#[macro_use]
|
|
extern crate libfuzzer_sys;
|
|
extern crate binaryen;
|
|
extern crate cranelift_codegen;
|
|
extern crate cranelift_wasm;
|
|
#[macro_use]
|
|
extern crate target_lexicon;
|
|
|
|
use cranelift_codegen::{isa, settings};
|
|
use cranelift_wasm::{translate_module, DummyEnvironment, ReturnMode};
|
|
use std::str::FromStr;
|
|
|
|
fuzz_target!(|data: &[u8]| {
|
|
let binaryen_module = binaryen::tools::translate_to_fuzz_mvp(data);
|
|
|
|
let wasm = binaryen_module.write();
|
|
|
|
let flags = settings::Flags::new(settings::builder());
|
|
let triple = triple!("x86_64");
|
|
let isa = isa::lookup(triple).unwrap().finish(flags);
|
|
let mut dummy_environ = DummyEnvironment::new(isa.frontend_config(), ReturnMode::NormalReturns);
|
|
translate_module(&wasm, &mut dummy_environ).unwrap();
|
|
});
|