Browse Source

Update for Cranelift API changes.

pull/28/head
Dan Gohman 6 years ago
parent
commit
82c8ef95c4
  1. 19
      fuzz/fuzz_targets/compile.rs

19
fuzz/fuzz_targets/compile.rs

@ -4,19 +4,20 @@
extern crate libfuzzer_sys;
extern crate cranelift_codegen;
extern crate cranelift_native;
extern crate wasmparser;
extern crate wasmtime_environ;
extern crate wasmtime_execute;
extern crate wasmparser;
use cranelift_codegen::settings;
use wasmtime_environ::{ModuleEnvironment, Module};
use wasmparser::{validate};
use wasmparser::validate;
use wasmtime_environ::{Module, ModuleEnvironment};
fuzz_target!(|data: &[u8]| {
if !validate(data, None) {
return;
}
let (flag_builder, isa_builder) = cranelift_native::builders().unwrap_or_else(|_| {
let flag_builder = settings::builder();
let isa_builder = cranelift_native::builder().unwrap_or_else(|_| {
panic!("host machine is not a supported target");
});
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
@ -26,8 +27,10 @@ fuzz_target!(|data: &[u8]| {
Ok(translation) => translation,
Err(_) => return,
};
let _exec = match wasmtime_execute::compile_and_link_module(&*isa, &translation) {
Ok(x) => x,
Err(_) => return,
};
let imports_resolver = |_env: &str, _function: &str| None;
let _exec =
match wasmtime_execute::compile_and_link_module(&*isa, &translation, imports_resolver) {
Ok(x) => x,
Err(_) => return,
};
});

Loading…
Cancel
Save