diff --git a/README.md b/README.md index 53677bca9..2a97592ed 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ## Introduction -[Wasmer](https://wasmer.io/) is a standalone JIT WebAssembly runtime, aiming to be fully compatible with Emscripten, Rust and Go. +[Wasmer](https://wasmer.io/) is a standalone JIT WebAssembly runtime, aiming to be fully compatible with [WASI](https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/) and [Emscripten](https://emscripten.org/). Install Wasmer with: @@ -164,6 +164,7 @@ Below are some of the goals of this project (in order of priority): - [x] It should be 100% compatible with the [WebAssembly spec tests](https://github.com/wasmerio/wasmer/tree/master/lib/spectests/spectests) - [x] It should be fast _(partially achieved)_ +- [ ] Support WASI _(in the works)_ - [ ] Support Emscripten calls _(in the works)_ - [ ] Support Rust ABI calls - [ ] Support Go ABI calls diff --git a/lib/emscripten/src/emscripten_target.rs b/lib/emscripten/src/emscripten_target.rs index 0ae8eaab2..5e6b927e8 100644 --- a/lib/emscripten/src/emscripten_target.rs +++ b/lib/emscripten/src/emscripten_target.rs @@ -12,24 +12,6 @@ pub fn getTempRet0(_ctx: &mut Ctx) -> i32 { debug!("emscripten::getTempRet0"); 0 } -pub fn nullFunc_d(_ctx: &mut Ctx, _a: i32) { - debug!("emscripten::nullFunc_d"); -} -pub fn nullFunc_ji(_ctx: &mut Ctx, _a: i32) { - debug!("emscripten::nullFunc_ji"); -} -pub fn nullFunc_viidii(_ctx: &mut Ctx, _a: i32) { - debug!("emscripten::nullFunc_viidii"); -} -pub fn nullFunc_iiiiiii(_ctx: &mut Ctx, _a: i32) { - debug!("emscripten::nullFunc_iiiiiii"); -} -pub fn nullFunc_iiiiiiii(_ctx: &mut Ctx, _a: i32) { - debug!("emscripten::nullFunc_iiiiiiii"); -} -pub fn nullFunc_iiiiiiiiii(_ctx: &mut Ctx, _a: i32) { - debug!("emscripten::nullFunc_iiiiiiiiii"); -} pub fn invoke_i(ctx: &mut Ctx, index: i32) -> i32 { debug!("emscripten::invoke_i"); if let Some(dyn_call_i) = &get_emscripten_data(ctx).dyn_call_i { @@ -243,130 +225,6 @@ pub fn _getloadavg(_ctx: &mut Ctx, _loadavg: i32, _nelem: i32) -> i32 { debug!("emscripten::getloadavg"); 0 } -// round 2 -pub fn nullFunc_di(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_di"); -} -pub fn nullFunc_dii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_dii"); -} -pub fn nullFunc_diiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_diiii"); -} -pub fn nullFunc_iiji(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiji"); -} -pub fn nullFunc_iiid(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiid"); -} -pub fn nullFunc_iij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iij"); -} -pub fn nullFunc_iiiiiiiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiiiiiiii"); -} -pub fn nullFunc_iiiiiiiiiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiiiiiiiiii"); -} -pub fn nullFunc_iiiiijii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiiiijii"); -} -pub fn nullFunc_iiiijii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiiijii"); -} -pub fn nullFunc_iiiij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiiij"); -} -pub fn nullFunc_iiij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiij"); -} -pub fn nullFunc_iijii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iijii"); -} -pub fn nullFunc_iijj(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iijj"); -} -pub fn nullFunc_iiiiji(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_iiiiji"); -} -pub fn nullFunc_ij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_ij"); -} -pub fn nullFunc_j(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_j"); -} -pub fn nullFunc_jij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_jij"); -} -pub fn nullFunc_jj(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_jj"); -} -pub fn nullFunc_jjj(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_jjj"); -} -pub fn nullFunc_jii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_jii"); -} -pub fn nullFunc_jiij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_jiij"); -} -pub fn nullFunc_vd(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_vd"); -} -pub fn nullFunc_vid(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_vid"); -} -pub fn nullFunc_viiiiiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viiiiiii"); -} -pub fn nullFunc_viiiij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viiiij"); -} -pub fn nullFunc_viiiiiiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viiiiiiii"); -} -pub fn nullFunc_viiiiiiiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viiiiiiiii"); -} -pub fn nullFunc_viiij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viiij"); -} -pub fn nullFunc_viiijiiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viiijiiii"); -} -pub fn nullFunc_viiijiiiiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viiijiiiiii"); -} -pub fn nullFunc_viij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viij"); -} -pub fn nullFunc_viijii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viijii"); -} -pub fn nullFunc_viiji(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viiji"); -} -pub fn nullFunc_vijii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_vijii"); -} -pub fn nullFunc_viijiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viijiii"); -} -pub fn nullFunc_viijj(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viijj"); -} -pub fn nullFunc_vij(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_vij"); -} -pub fn nullFunc_viji(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viji"); -} -pub fn nullFunc_vijiii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_vijiii"); -} -pub fn nullFunc_vijj(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_vijj"); -} pub fn invoke_dii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) -> f64 { debug!("emscripten::invoke_dii"); if let Some(dyn_call_dii) = &get_emscripten_data(ctx).dyn_call_dii { diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index 4c1ce2b35..f0ca666b2 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -40,7 +40,6 @@ mod linking; mod lock; mod math; mod memory; -mod nullfunc; mod process; mod signal; mod storage; @@ -347,6 +346,7 @@ pub struct EmscriptenGlobals { pub table: Table, pub memory_min: Pages, pub memory_max: Option, + pub null_func_names: Vec, } impl EmscriptenGlobals { @@ -420,12 +420,29 @@ impl EmscriptenGlobals { emscripten_set_up_memory(&memory, &data); + let mut null_func_names = vec![]; + for ( + _, + ImportName { + namespace_index, + name_index, + }, + ) in &module.info().imported_functions + { + let namespace = module.info().namespace_table.get(*namespace_index); + let name = module.info().name_table.get(*name_index); + if namespace == "env" && name.starts_with("nullFunc_") { + null_func_names.push(name.to_string()) + } + } + Self { data, memory, table, memory_min, memory_max, + null_func_names, } } } @@ -437,358 +454,301 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject func!(crate::memory::abort_on_cannot_grow_memory).to_export() }; - imports! { - "env" => { - "memory" => Export::Memory(globals.memory.clone()), - "table" => Export::Table(globals.table.clone()), + let mut env_ns = namespace! { + "memory" => Export::Memory(globals.memory.clone()), + "table" => Export::Table(globals.table.clone()), - // Globals - "STACKTOP" => Global::new(Value::I32(globals.data.stacktop as i32)), - "STACK_MAX" => Global::new(Value::I32(globals.data.stack_max as i32)), - "DYNAMICTOP_PTR" => Global::new(Value::I32(globals.data.dynamictop_ptr as i32)), - "tableBase" => Global::new(Value::I32(globals.data.table_base as i32)), - "__table_base" => Global::new(Value::I32(globals.data.table_base as i32)), - "ABORT" => Global::new(Value::I32(globals.data.abort as i32)), - "memoryBase" => Global::new(Value::I32(globals.data.memory_base as i32)), - "__memory_base" => Global::new(Value::I32(globals.data.memory_base as i32)), - "tempDoublePtr" => Global::new(Value::I32(globals.data.temp_double_ptr as i32)), + // Globals + "STACKTOP" => Global::new(Value::I32(globals.data.stacktop as i32)), + "STACK_MAX" => Global::new(Value::I32(globals.data.stack_max as i32)), + "DYNAMICTOP_PTR" => Global::new(Value::I32(globals.data.dynamictop_ptr as i32)), + "tableBase" => Global::new(Value::I32(globals.data.table_base as i32)), + "__table_base" => Global::new(Value::I32(globals.data.table_base as i32)), + "ABORT" => Global::new(Value::I32(globals.data.abort as i32)), + "memoryBase" => Global::new(Value::I32(globals.data.memory_base as i32)), + "__memory_base" => Global::new(Value::I32(globals.data.memory_base as i32)), + "tempDoublePtr" => Global::new(Value::I32(globals.data.temp_double_ptr as i32)), - // IO - "printf" => func!(crate::io::printf), - "putchar" => func!(crate::io::putchar), - "___lock" => func!(crate::lock::___lock), - "___unlock" => func!(crate::lock::___unlock), - "___wait" => func!(crate::lock::___wait), - "_flock" => func!(crate::lock::_flock), - "_chroot" => func!(crate::io::chroot), - "_getprotobyname" => func!(crate::io::getprotobyname), - "_getprotobynumber" => func!(crate::io::getprotobynumber), - "_getpwuid" => func!(crate::io::getpwuid), - "_sigdelset" => func!(crate::io::sigdelset), - "_sigfillset" => func!(crate::io::sigfillset), - "_tzset" => func!(crate::io::tzset), - "_strptime" => func!(crate::io::strptime), + // IO + "printf" => func!(crate::io::printf), + "putchar" => func!(crate::io::putchar), + "___lock" => func!(crate::lock::___lock), + "___unlock" => func!(crate::lock::___unlock), + "___wait" => func!(crate::lock::___wait), + "_flock" => func!(crate::lock::_flock), + "_chroot" => func!(crate::io::chroot), + "_getprotobyname" => func!(crate::io::getprotobyname), + "_getprotobynumber" => func!(crate::io::getprotobynumber), + "_getpwuid" => func!(crate::io::getpwuid), + "_sigdelset" => func!(crate::io::sigdelset), + "_sigfillset" => func!(crate::io::sigfillset), + "_tzset" => func!(crate::io::tzset), + "_strptime" => func!(crate::io::strptime), - // exec - "_execvp" => func!(crate::exec::execvp), - "_execl" => func!(crate::exec::execl), - "_execle" => func!(crate::exec::execle), + // exec + "_execvp" => func!(crate::exec::execvp), + "_execl" => func!(crate::exec::execl), + "_execle" => func!(crate::exec::execle), - // exit - "__exit" => func!(crate::exit::exit), + // exit + "__exit" => func!(crate::exit::exit), - // Env - "___assert_fail" => func!(crate::env::___assert_fail), - "_getenv" => func!(crate::env::_getenv), - "_setenv" => func!(crate::env::_setenv), - "_putenv" => func!(crate::env::_putenv), - "_unsetenv" => func!(crate::env::_unsetenv), - "_getpwnam" => func!(crate::env::_getpwnam), - "_getgrnam" => func!(crate::env::_getgrnam), - "___buildEnvironment" => func!(crate::env::___build_environment), - "___setErrNo" => func!(crate::errno::___seterrno), - "_getpagesize" => func!(crate::env::_getpagesize), - "_sysconf" => func!(crate::env::_sysconf), - "_getaddrinfo" => func!(crate::env::_getaddrinfo), - "_initgroups" => func!(crate::env::_initgroups), + // Env + "___assert_fail" => func!(crate::env::___assert_fail), + "_getenv" => func!(crate::env::_getenv), + "_setenv" => func!(crate::env::_setenv), + "_putenv" => func!(crate::env::_putenv), + "_unsetenv" => func!(crate::env::_unsetenv), + "_getpwnam" => func!(crate::env::_getpwnam), + "_getgrnam" => func!(crate::env::_getgrnam), + "___buildEnvironment" => func!(crate::env::___build_environment), + "___setErrNo" => func!(crate::errno::___seterrno), + "_getpagesize" => func!(crate::env::_getpagesize), + "_sysconf" => func!(crate::env::_sysconf), + "_getaddrinfo" => func!(crate::env::_getaddrinfo), + "_initgroups" => func!(crate::env::_initgroups), - // Null func - "nullFunc_i" => func!(crate::nullfunc::nullfunc_i), - "nullFunc_ii" => func!(crate::nullfunc::nullfunc_ii), - "nullFunc_iii" => func!(crate::nullfunc::nullfunc_iii), - "nullFunc_iiii" => func!(crate::nullfunc::nullfunc_iiii), - "nullFunc_iiiii" => func!(crate::nullfunc::nullfunc_iiiii), - "nullFunc_iiiiii" => func!(crate::nullfunc::nullfunc_iiiiii), - "nullFunc_v" => func!(crate::nullfunc::nullfunc_v), - "nullFunc_vi" => func!(crate::nullfunc::nullfunc_vi), - "nullFunc_vii" => func!(crate::nullfunc::nullfunc_vii), - "nullFunc_viii" => func!(crate::nullfunc::nullfunc_viii), - "nullFunc_viiii" => func!(crate::nullfunc::nullfunc_viiii), - "nullFunc_viiiii" => func!(crate::nullfunc::nullfunc_viiiii), - "nullFunc_viiiiii" => func!(crate::nullfunc::nullfunc_viiiiii), + // Syscalls + "___syscall1" => func!(crate::syscalls::___syscall1), + "___syscall3" => func!(crate::syscalls::___syscall3), + "___syscall4" => func!(crate::syscalls::___syscall4), + "___syscall5" => func!(crate::syscalls::___syscall5), + "___syscall6" => func!(crate::syscalls::___syscall6), + "___syscall9" => func!(crate::syscalls::___syscall9), + "___syscall10" => func!(crate::syscalls::___syscall10), + "___syscall12" => func!(crate::syscalls::___syscall12), + "___syscall15" => func!(crate::syscalls::___syscall15), + "___syscall20" => func!(crate::syscalls::___syscall20), + "___syscall33" => func!(crate::syscalls::___syscall33), + "___syscall34" => func!(crate::syscalls::___syscall34), + "___syscall39" => func!(crate::syscalls::___syscall39), + "___syscall38" => func!(crate::syscalls::___syscall38), + "___syscall40" => func!(crate::syscalls::___syscall40), + "___syscall41" => func!(crate::syscalls::___syscall41), + "___syscall42" => func!(crate::syscalls::___syscall42), + "___syscall54" => func!(crate::syscalls::___syscall54), + "___syscall57" => func!(crate::syscalls::___syscall57), + "___syscall60" => func!(crate::syscalls::___syscall60), + "___syscall63" => func!(crate::syscalls::___syscall63), + "___syscall64" => func!(crate::syscalls::___syscall64), + "___syscall66" => func!(crate::syscalls::___syscall66), + "___syscall75" => func!(crate::syscalls::___syscall75), + "___syscall77" => func!(crate::syscalls::___syscall77), + "___syscall83" => func!(crate::syscalls::___syscall83), + "___syscall85" => func!(crate::syscalls::___syscall85), + "___syscall91" => func!(crate::syscalls::___syscall191), + "___syscall94" => func!(crate::syscalls::___syscall194), + "___syscall97" => func!(crate::syscalls::___syscall97), + "___syscall102" => func!(crate::syscalls::___syscall102), + "___syscall110" => func!(crate::syscalls::___syscall110), + "___syscall114" => func!(crate::syscalls::___syscall114), + "___syscall118" => func!(crate::syscalls::___syscall118), + "___syscall122" => func!(crate::syscalls::___syscall122), + "___syscall140" => func!(crate::syscalls::___syscall140), + "___syscall142" => func!(crate::syscalls::___syscall142), + "___syscall145" => func!(crate::syscalls::___syscall145), + "___syscall146" => func!(crate::syscalls::___syscall146), + "___syscall148" => func!(crate::syscalls::___syscall148), + "___syscall168" => func!(crate::syscalls::___syscall168), + "___syscall180" => func!(crate::syscalls::___syscall180), + "___syscall181" => func!(crate::syscalls::___syscall181), + "___syscall183" => func!(crate::syscalls::___syscall183), + "___syscall191" => func!(crate::syscalls::___syscall191), + "___syscall192" => func!(crate::syscalls::___syscall192), + "___syscall194" => func!(crate::syscalls::___syscall194), + "___syscall195" => func!(crate::syscalls::___syscall195), + "___syscall196" => func!(crate::syscalls::___syscall196), + "___syscall197" => func!(crate::syscalls::___syscall197), + "___syscall198" => func!(crate::syscalls::___syscall198), + "___syscall199" => func!(crate::syscalls::___syscall199), + "___syscall200" => func!(crate::syscalls::___syscall200), + "___syscall201" => func!(crate::syscalls::___syscall201), + "___syscall202" => func!(crate::syscalls::___syscall202), + "___syscall205" => func!(crate::syscalls::___syscall205), + "___syscall207" => func!(crate::syscalls::___syscall207), + "___syscall212" => func!(crate::syscalls::___syscall212), + "___syscall219" => func!(crate::syscalls::___syscall219), + "___syscall220" => func!(crate::syscalls::___syscall220), + "___syscall221" => func!(crate::syscalls::___syscall221), + "___syscall268" => func!(crate::syscalls::___syscall268), + "___syscall272" => func!(crate::syscalls::___syscall272), + "___syscall295" => func!(crate::syscalls::___syscall295), + "___syscall300" => func!(crate::syscalls::___syscall300), + "___syscall324" => func!(crate::syscalls::___syscall324), + "___syscall330" => func!(crate::syscalls::___syscall330), + "___syscall334" => func!(crate::syscalls::___syscall334), + "___syscall340" => func!(crate::syscalls::___syscall340), - // Syscalls - "___syscall1" => func!(crate::syscalls::___syscall1), - "___syscall3" => func!(crate::syscalls::___syscall3), - "___syscall4" => func!(crate::syscalls::___syscall4), - "___syscall5" => func!(crate::syscalls::___syscall5), - "___syscall6" => func!(crate::syscalls::___syscall6), - "___syscall9" => func!(crate::syscalls::___syscall9), - "___syscall10" => func!(crate::syscalls::___syscall10), - "___syscall12" => func!(crate::syscalls::___syscall12), - "___syscall15" => func!(crate::syscalls::___syscall15), - "___syscall20" => func!(crate::syscalls::___syscall20), - "___syscall33" => func!(crate::syscalls::___syscall33), - "___syscall34" => func!(crate::syscalls::___syscall34), - "___syscall39" => func!(crate::syscalls::___syscall39), - "___syscall38" => func!(crate::syscalls::___syscall38), - "___syscall40" => func!(crate::syscalls::___syscall40), - "___syscall41" => func!(crate::syscalls::___syscall41), - "___syscall42" => func!(crate::syscalls::___syscall42), - "___syscall54" => func!(crate::syscalls::___syscall54), - "___syscall57" => func!(crate::syscalls::___syscall57), - "___syscall60" => func!(crate::syscalls::___syscall60), - "___syscall63" => func!(crate::syscalls::___syscall63), - "___syscall64" => func!(crate::syscalls::___syscall64), - "___syscall66" => func!(crate::syscalls::___syscall66), - "___syscall75" => func!(crate::syscalls::___syscall75), - "___syscall77" => func!(crate::syscalls::___syscall77), - "___syscall83" => func!(crate::syscalls::___syscall83), - "___syscall85" => func!(crate::syscalls::___syscall85), - "___syscall91" => func!(crate::syscalls::___syscall191), - "___syscall94" => func!(crate::syscalls::___syscall194), - "___syscall97" => func!(crate::syscalls::___syscall97), - "___syscall102" => func!(crate::syscalls::___syscall102), - "___syscall110" => func!(crate::syscalls::___syscall110), - "___syscall114" => func!(crate::syscalls::___syscall114), - "___syscall118" => func!(crate::syscalls::___syscall118), - "___syscall122" => func!(crate::syscalls::___syscall122), - "___syscall140" => func!(crate::syscalls::___syscall140), - "___syscall142" => func!(crate::syscalls::___syscall142), - "___syscall145" => func!(crate::syscalls::___syscall145), - "___syscall146" => func!(crate::syscalls::___syscall146), - "___syscall148" => func!(crate::syscalls::___syscall148), - "___syscall168" => func!(crate::syscalls::___syscall168), - "___syscall180" => func!(crate::syscalls::___syscall180), - "___syscall181" => func!(crate::syscalls::___syscall181), - "___syscall183" => func!(crate::syscalls::___syscall183), - "___syscall191" => func!(crate::syscalls::___syscall191), - "___syscall192" => func!(crate::syscalls::___syscall192), - "___syscall194" => func!(crate::syscalls::___syscall194), - "___syscall195" => func!(crate::syscalls::___syscall195), - "___syscall196" => func!(crate::syscalls::___syscall196), - "___syscall197" => func!(crate::syscalls::___syscall197), - "___syscall198" => func!(crate::syscalls::___syscall198), - "___syscall199" => func!(crate::syscalls::___syscall199), - "___syscall200" => func!(crate::syscalls::___syscall200), - "___syscall201" => func!(crate::syscalls::___syscall201), - "___syscall202" => func!(crate::syscalls::___syscall202), - "___syscall205" => func!(crate::syscalls::___syscall205), - "___syscall207" => func!(crate::syscalls::___syscall207), - "___syscall212" => func!(crate::syscalls::___syscall212), - "___syscall219" => func!(crate::syscalls::___syscall219), - "___syscall220" => func!(crate::syscalls::___syscall220), - "___syscall221" => func!(crate::syscalls::___syscall221), - "___syscall268" => func!(crate::syscalls::___syscall268), - "___syscall272" => func!(crate::syscalls::___syscall272), - "___syscall295" => func!(crate::syscalls::___syscall295), - "___syscall300" => func!(crate::syscalls::___syscall300), - "___syscall324" => func!(crate::syscalls::___syscall324), - "___syscall330" => func!(crate::syscalls::___syscall330), - "___syscall334" => func!(crate::syscalls::___syscall334), - "___syscall340" => func!(crate::syscalls::___syscall340), - - // Process - "abort" => func!(crate::process::em_abort), - "_abort" => func!(crate::process::_abort), - "abortStackOverflow" => func!(crate::process::abort_stack_overflow), - "_llvm_trap" => func!(crate::process::_llvm_trap), - "_fork" => func!(crate::process::_fork), - "_exit" => func!(crate::process::_exit), - "_system" => func!(crate::process::_system), - "_popen" => func!(crate::process::_popen), - "_endgrent" => func!(crate::process::_endgrent), - "_execve" => func!(crate::process::_execve), - "_kill" => func!(crate::process::_kill), - "_llvm_stackrestore" => func!(crate::process::_llvm_stackrestore), - "_llvm_stacksave" => func!(crate::process::_llvm_stacksave), - "_raise" => func!(crate::process::_raise), - "_sem_init" => func!(crate::process::_sem_init), - "_sem_post" => func!(crate::process::_sem_post), - "_sem_wait" => func!(crate::process::_sem_wait), - "_getgrent" => func!(crate::process::_getgrent), - "_sched_yield" => func!(crate::process::_sched_yield), - "_setgrent" => func!(crate::process::_setgrent), - "_setgroups" => func!(crate::process::_setgroups), - "_setitimer" => func!(crate::process::_setitimer), - "_usleep" => func!(crate::process::_usleep), - "_nanosleep" => func!(crate::process::_nanosleep), - "_utimes" => func!(crate::process::_utimes), - "_waitpid" => func!(crate::process::_waitpid), + // Process + "abort" => func!(crate::process::em_abort), + "_abort" => func!(crate::process::_abort), + "abortStackOverflow" => func!(crate::process::abort_stack_overflow), + "_llvm_trap" => func!(crate::process::_llvm_trap), + "_fork" => func!(crate::process::_fork), + "_exit" => func!(crate::process::_exit), + "_system" => func!(crate::process::_system), + "_popen" => func!(crate::process::_popen), + "_endgrent" => func!(crate::process::_endgrent), + "_execve" => func!(crate::process::_execve), + "_kill" => func!(crate::process::_kill), + "_llvm_stackrestore" => func!(crate::process::_llvm_stackrestore), + "_llvm_stacksave" => func!(crate::process::_llvm_stacksave), + "_raise" => func!(crate::process::_raise), + "_sem_init" => func!(crate::process::_sem_init), + "_sem_post" => func!(crate::process::_sem_post), + "_sem_wait" => func!(crate::process::_sem_wait), + "_getgrent" => func!(crate::process::_getgrent), + "_sched_yield" => func!(crate::process::_sched_yield), + "_setgrent" => func!(crate::process::_setgrent), + "_setgroups" => func!(crate::process::_setgroups), + "_setitimer" => func!(crate::process::_setitimer), + "_usleep" => func!(crate::process::_usleep), + "_nanosleep" => func!(crate::process::_nanosleep), + "_utimes" => func!(crate::process::_utimes), + "_waitpid" => func!(crate::process::_waitpid), - // Signal - "_sigemptyset" => func!(crate::signal::_sigemptyset), - "_sigaddset" => func!(crate::signal::_sigaddset), - "_sigprocmask" => func!(crate::signal::_sigprocmask), - "_sigaction" => func!(crate::signal::_sigaction), - "_signal" => func!(crate::signal::_signal), - "_sigsuspend" => func!(crate::signal::_sigsuspend), + // Signal + "_sigemptyset" => func!(crate::signal::_sigemptyset), + "_sigaddset" => func!(crate::signal::_sigaddset), + "_sigprocmask" => func!(crate::signal::_sigprocmask), + "_sigaction" => func!(crate::signal::_sigaction), + "_signal" => func!(crate::signal::_signal), + "_sigsuspend" => func!(crate::signal::_sigsuspend), - // Memory - "abortOnCannotGrowMemory" => abort_on_cannot_grow_memory_export, - "_emscripten_memcpy_big" => func!(crate::memory::_emscripten_memcpy_big), - "_emscripten_get_heap_size" => func!(crate::memory::_emscripten_get_heap_size), - "_emscripten_resize_heap" => func!(crate::memory::_emscripten_resize_heap), - "enlargeMemory" => func!(crate::memory::enlarge_memory), - "getTotalMemory" => func!(crate::memory::get_total_memory), - "___map_file" => func!(crate::memory::___map_file), + // Memory + "abortOnCannotGrowMemory" => abort_on_cannot_grow_memory_export, + "_emscripten_memcpy_big" => func!(crate::memory::_emscripten_memcpy_big), + "_emscripten_get_heap_size" => func!(crate::memory::_emscripten_get_heap_size), + "_emscripten_resize_heap" => func!(crate::memory::_emscripten_resize_heap), + "enlargeMemory" => func!(crate::memory::enlarge_memory), + "getTotalMemory" => func!(crate::memory::get_total_memory), + "___map_file" => func!(crate::memory::___map_file), - // Exception - "___cxa_allocate_exception" => func!(crate::exception::___cxa_allocate_exception), - "___cxa_throw" => func!(crate::exception::___cxa_throw), + // Exception + "___cxa_allocate_exception" => func!(crate::exception::___cxa_allocate_exception), + "___cxa_throw" => func!(crate::exception::___cxa_throw), - // Time - "_gettimeofday" => func!(crate::time::_gettimeofday), - "_clock_gettime" => func!(crate::time::_clock_gettime), - "___clock_gettime" => func!(crate::time::_clock_gettime), - "_clock" => func!(crate::time::_clock), - "_difftime" => func!(crate::time::_difftime), - "_asctime" => func!(crate::time::_asctime), - "_asctime_r" => func!(crate::time::_asctime_r), - "_localtime" => func!(crate::time::_localtime), - "_time" => func!(crate::time::_time), - "_strftime" => func!(crate::time::_strftime), - "_localtime_r" => func!(crate::time::_localtime_r), - "_gmtime_r" => func!(crate::time::_gmtime_r), - "_mktime" => func!(crate::time::_mktime), - "_gmtime" => func!(crate::time::_gmtime), + // Time + "_gettimeofday" => func!(crate::time::_gettimeofday), + "_clock_gettime" => func!(crate::time::_clock_gettime), + "___clock_gettime" => func!(crate::time::_clock_gettime), + "_clock" => func!(crate::time::_clock), + "_difftime" => func!(crate::time::_difftime), + "_asctime" => func!(crate::time::_asctime), + "_asctime_r" => func!(crate::time::_asctime_r), + "_localtime" => func!(crate::time::_localtime), + "_time" => func!(crate::time::_time), + "_strftime" => func!(crate::time::_strftime), + "_localtime_r" => func!(crate::time::_localtime_r), + "_gmtime_r" => func!(crate::time::_gmtime_r), + "_mktime" => func!(crate::time::_mktime), + "_gmtime" => func!(crate::time::_gmtime), - // Math - "f64-rem" => func!(crate::math::f64_rem), - "_llvm_log10_f64" => func!(crate::math::_llvm_log10_f64), - "_llvm_log2_f64" => func!(crate::math::_llvm_log2_f64), - "_llvm_log10_f32" => func!(crate::math::_llvm_log10_f32), - "_llvm_log2_f32" => func!(crate::math::_llvm_log2_f64), - "_llvm_sin_f64" => func!(crate::math::_llvm_sin_f64), - "_llvm_cos_f64" => func!(crate::math::_llvm_cos_f64), - "_emscripten_random" => func!(crate::math::_emscripten_random), + // Math + "f64-rem" => func!(crate::math::f64_rem), + "_llvm_log10_f64" => func!(crate::math::_llvm_log10_f64), + "_llvm_log2_f64" => func!(crate::math::_llvm_log2_f64), + "_llvm_log10_f32" => func!(crate::math::_llvm_log10_f32), + "_llvm_log2_f32" => func!(crate::math::_llvm_log2_f64), + "_llvm_sin_f64" => func!(crate::math::_llvm_sin_f64), + "_llvm_cos_f64" => func!(crate::math::_llvm_cos_f64), + "_emscripten_random" => func!(crate::math::_emscripten_random), - // Bitwise - "_llvm_bswap_i64" => func!(crate::bitwise::_llvm_bswap_i64), + // Jump + "__setjmp" => func!(crate::jmp::__setjmp), + "__longjmp" => func!(crate::jmp::__longjmp), + "_longjmp" => func!(crate::jmp::__longjmp), - // Jump - "__setjmp" => func!(crate::jmp::__setjmp), - "__longjmp" => func!(crate::jmp::__longjmp), - "_longjmp" => func!(crate::jmp::__longjmp), + // Bitwise + "_llvm_bswap_i64" => func!(crate::bitwise::_llvm_bswap_i64), - // Linking - "_dlclose" => func!(crate::linking::_dlclose), - "_dlerror" => func!(crate::linking::_dlerror), - "_dlopen" => func!(crate::linking::_dlopen), - "_dlsym" => func!(crate::linking::_dlsym), + // Linking + "_dlclose" => func!(crate::linking::_dlclose), + "_dlerror" => func!(crate::linking::_dlerror), + "_dlopen" => func!(crate::linking::_dlopen), + "_dlsym" => func!(crate::linking::_dlsym), - // wasm32-unknown-emscripten - "setTempRet0" => func!(crate::emscripten_target::setTempRet0), - "getTempRet0" => func!(crate::emscripten_target::getTempRet0), - "nullFunc_ji" => func!(crate::emscripten_target::nullFunc_ji), - "nullFunc_d" => func!(crate::emscripten_target::nullFunc_d), - "nullFunc_viidii" => func!(crate::emscripten_target::nullFunc_viidii), - "nullFunc_iiiiiii" => func!(crate::emscripten_target::nullFunc_iiiiiii), - "nullFunc_iiiiiiii" => func!(crate::emscripten_target::nullFunc_iiiiiiii), - "nullFunc_iiiiiiiiii" => func!(crate::emscripten_target::nullFunc_iiiiiiiiii), - "invoke_i" => func!(crate::emscripten_target::invoke_i), - "invoke_ii" => func!(crate::emscripten_target::invoke_ii), - "invoke_iii" => func!(crate::emscripten_target::invoke_iii), - "invoke_iiii" => func!(crate::emscripten_target::invoke_iiii), - "invoke_v" => func!(crate::emscripten_target::invoke_v), - "invoke_vi" => func!(crate::emscripten_target::invoke_vi), - "invoke_vii" => func!(crate::emscripten_target::invoke_vii), - "invoke_viii" => func!(crate::emscripten_target::invoke_viii), - "invoke_viiii" => func!(crate::emscripten_target::invoke_viiii), - "__Unwind_Backtrace" => func!(crate::emscripten_target::__Unwind_Backtrace), - "__Unwind_FindEnclosingFunction" => func!(crate::emscripten_target::__Unwind_FindEnclosingFunction), - "__Unwind_GetIPInfo" => func!(crate::emscripten_target::__Unwind_GetIPInfo), - "___cxa_find_matching_catch_2" => func!(crate::emscripten_target::___cxa_find_matching_catch_2), - "___cxa_find_matching_catch_3" => func!(crate::emscripten_target::___cxa_find_matching_catch_3), - "___cxa_free_exception" => func!(crate::emscripten_target::___cxa_free_exception), - "___resumeException" => func!(crate::emscripten_target::___resumeException), - "_dladdr" => func!(crate::emscripten_target::_dladdr), - "_pthread_create" => func!(crate::emscripten_target::_pthread_create), - "_pthread_join" => func!(crate::emscripten_target::_pthread_join), - "_pthread_cond_destroy" => func!(crate::emscripten_target::_pthread_cond_destroy), - "_pthread_cond_init" => func!(crate::emscripten_target::_pthread_cond_init), - "_pthread_cond_signal" => func!(crate::emscripten_target::_pthread_cond_signal), - "_pthread_cond_wait" => func!(crate::emscripten_target::_pthread_cond_wait), - "_pthread_condattr_destroy" => func!(crate::emscripten_target::_pthread_condattr_destroy), - "_pthread_condattr_init" => func!(crate::emscripten_target::_pthread_condattr_init), - "_pthread_condattr_setclock" => func!(crate::emscripten_target::_pthread_condattr_setclock), - "_pthread_mutex_destroy" => func!(crate::emscripten_target::_pthread_mutex_destroy), - "_pthread_mutex_init" => func!(crate::emscripten_target::_pthread_mutex_init), - "_pthread_mutexattr_destroy" => func!(crate::emscripten_target::_pthread_mutexattr_destroy), - "_pthread_mutexattr_init" => func!(crate::emscripten_target::_pthread_mutexattr_init), - "_pthread_mutexattr_settype" => func!(crate::emscripten_target::_pthread_mutexattr_settype), - "_pthread_rwlock_rdlock" => func!(crate::emscripten_target::_pthread_rwlock_rdlock), - "_pthread_rwlock_unlock" => func!(crate::emscripten_target::_pthread_rwlock_unlock), - "_pthread_setcancelstate" => func!(crate::emscripten_target::_pthread_setcancelstate), - "___gxx_personality_v0" => func!(crate::emscripten_target::___gxx_personality_v0), - "_getdtablesize" => func!(crate::emscripten_target::_getdtablesize), - "_gethostbyaddr" => func!(crate::emscripten_target::_gethostbyaddr), - "_gethostbyname_r" => func!(crate::emscripten_target::_gethostbyname_r), - "_getloadavg" => func!(crate::emscripten_target::_getloadavg), - // round 2 - "nullFunc_di" => func!(crate::emscripten_target::nullFunc_di), - "nullFunc_dii" => func!(crate::emscripten_target::nullFunc_dii), - "nullFunc_diiii" => func!(crate::emscripten_target::nullFunc_diiii), - "nullFunc_iiid" => func!(crate::emscripten_target::nullFunc_iiid), - "nullFunc_iiji" => func!(crate::emscripten_target::nullFunc_iiji), - "nullFunc_iijj" => func!(crate::emscripten_target::nullFunc_iijj), - "nullFunc_iij" => func!(crate::emscripten_target::nullFunc_iij), - "nullFunc_ij" => func!(crate::emscripten_target::nullFunc_ij), - "nullFunc_j" => func!(crate::emscripten_target::nullFunc_j), - "nullFunc_jij" => func!(crate::emscripten_target::nullFunc_jij), - "nullFunc_jj" => func!(crate::emscripten_target::nullFunc_jj), - "nullFunc_jjj" => func!(crate::emscripten_target::nullFunc_jjj), - "nullFunc_jii" => func!(crate::emscripten_target::nullFunc_jii), - "nullFunc_jiij" => func!(crate::emscripten_target::nullFunc_jiij), - "nullFunc_vd" => func!(crate::emscripten_target::nullFunc_vd), - "nullFunc_iiiiiiiii" => func!(crate::emscripten_target::nullFunc_iiiiiiiii), - "nullFunc_iiiiiiiiiii" => func!(crate::emscripten_target::nullFunc_iiiiiiiiiii), - "nullFunc_iiiiijii" => func!(crate::emscripten_target::nullFunc_iiiiijii), - "nullFunc_iiiij" => func!(crate::emscripten_target::nullFunc_iiiij), - "nullFunc_iiij" => func!(crate::emscripten_target::nullFunc_iiij), - "nullFunc_iiiiji" => func!(crate::emscripten_target::nullFunc_iiiiji), - "nullFunc_iijii" => func!(crate::emscripten_target::nullFunc_iijii), - "nullFunc_iiiijii" => func!(crate::emscripten_target::nullFunc_iiiijii), - "nullFunc_viiiiiii" => func!(crate::emscripten_target::nullFunc_viiiiiii), - "nullFunc_viiiiiiii" => func!(crate::emscripten_target::nullFunc_viiiiiiii), - "nullFunc_viiiiiiiii" => func!(crate::emscripten_target::nullFunc_viiiiiiiii), - "nullFunc_viiij" => func!(crate::emscripten_target::nullFunc_viiij), - "nullFunc_viiijiiii" => func!(crate::emscripten_target::nullFunc_viiijiiii), - "nullFunc_viiijiiiiii" => func!(crate::emscripten_target::nullFunc_viiijiiiiii), - "nullFunc_viij" => func!(crate::emscripten_target::nullFunc_viij), - "nullFunc_viiji" => func!(crate::emscripten_target::nullFunc_viiji), - "nullFunc_vijii" => func!(crate::emscripten_target::nullFunc_vijii), - "nullFunc_viijii" => func!(crate::emscripten_target::nullFunc_viijii), - "nullFunc_viiiij" => func!(crate::emscripten_target::nullFunc_viiiij), - "nullFunc_viijiii" => func!(crate::emscripten_target::nullFunc_viijiii), - "nullFunc_viijj" => func!(crate::emscripten_target::nullFunc_viijj), - "nullFunc_vij" => func!(crate::emscripten_target::nullFunc_vij), - "nullFunc_vid" => func!(crate::emscripten_target::nullFunc_vid), - "nullFunc_viji" => func!(crate::emscripten_target::nullFunc_viji), - "nullFunc_vijiii" => func!(crate::emscripten_target::nullFunc_vijiii), - "nullFunc_vijj" => func!(crate::emscripten_target::nullFunc_vijj), - "invoke_dii" => func!(crate::emscripten_target::invoke_dii), - "invoke_diiii" => func!(crate::emscripten_target::invoke_diiii), - "invoke_iiiii" => func!(crate::emscripten_target::invoke_iiiii), - "invoke_iiiiii" => func!(crate::emscripten_target::invoke_iiiiii), - "invoke_iiiiiii" => func!(crate::emscripten_target::invoke_iiiiiii), - "invoke_iiiiiiii" => func!(crate::emscripten_target::invoke_iiiiiiii), - "invoke_iiiiiiiiii" => func!(crate::emscripten_target::invoke_iiiiiiiiii), - "invoke_vd" => func!(crate::emscripten_target::invoke_vd), - "invoke_viiiii" => func!(crate::emscripten_target::invoke_viiiii), - "invoke_viiiiii" => func!(crate::emscripten_target::invoke_viiiiii), - "invoke_viiiiiii" => func!(crate::emscripten_target::invoke_viiiiiii), - "invoke_viiiiiiii" => func!(crate::emscripten_target::invoke_viiiiiiii), - "invoke_viiiiiiiii" => func!(crate::emscripten_target::invoke_viiiiiiiii), - "invoke_iiji" => func!(crate::emscripten_target::invoke_iiji), - "invoke_j" => func!(crate::emscripten_target::invoke_j), - "invoke_ji" => func!(crate::emscripten_target::invoke_ji), - "invoke_jij" => func!(crate::emscripten_target::invoke_jij), - "invoke_jjj" => func!(crate::emscripten_target::invoke_jjj), - "invoke_viiij" => func!(crate::emscripten_target::invoke_viiij), - "invoke_viiijiiii" => func!(crate::emscripten_target::invoke_viiijiiii), - "invoke_viiijiiiiii" => func!(crate::emscripten_target::invoke_viiijiiiiii), - "invoke_viij" => func!(crate::emscripten_target::invoke_viij), - "invoke_viiji" => func!(crate::emscripten_target::invoke_viiji), - "invoke_viijiii" => func!(crate::emscripten_target::invoke_viijiii), - "invoke_viijj" => func!(crate::emscripten_target::invoke_viijj), - "invoke_vij" => func!(crate::emscripten_target::invoke_vij), - "invoke_viji" => func!(crate::emscripten_target::invoke_viji), - "invoke_vijiii" => func!(crate::emscripten_target::invoke_vijiii), - "invoke_vijj" => func!(crate::emscripten_target::invoke_vijj), - "invoke_viidii" => func!(crate::emscripten_target::invoke_viidii), - }, + // wasm32-unknown-emscripten + "setTempRet0" => func!(crate::emscripten_target::setTempRet0), + "getTempRet0" => func!(crate::emscripten_target::getTempRet0), + "invoke_i" => func!(crate::emscripten_target::invoke_i), + "invoke_ii" => func!(crate::emscripten_target::invoke_ii), + "invoke_iii" => func!(crate::emscripten_target::invoke_iii), + "invoke_iiii" => func!(crate::emscripten_target::invoke_iiii), + "invoke_v" => func!(crate::emscripten_target::invoke_v), + "invoke_vi" => func!(crate::emscripten_target::invoke_vi), + "invoke_vii" => func!(crate::emscripten_target::invoke_vii), + "invoke_viii" => func!(crate::emscripten_target::invoke_viii), + "invoke_viiii" => func!(crate::emscripten_target::invoke_viiii), + "__Unwind_Backtrace" => func!(crate::emscripten_target::__Unwind_Backtrace), + "__Unwind_FindEnclosingFunction" => func!(crate::emscripten_target::__Unwind_FindEnclosingFunction), + "__Unwind_GetIPInfo" => func!(crate::emscripten_target::__Unwind_GetIPInfo), + "___cxa_find_matching_catch_2" => func!(crate::emscripten_target::___cxa_find_matching_catch_2), + "___cxa_find_matching_catch_3" => func!(crate::emscripten_target::___cxa_find_matching_catch_3), + "___cxa_free_exception" => func!(crate::emscripten_target::___cxa_free_exception), + "___resumeException" => func!(crate::emscripten_target::___resumeException), + "_dladdr" => func!(crate::emscripten_target::_dladdr), + "_pthread_create" => func!(crate::emscripten_target::_pthread_create), + "_pthread_join" => func!(crate::emscripten_target::_pthread_join), + "_pthread_cond_destroy" => func!(crate::emscripten_target::_pthread_cond_destroy), + "_pthread_cond_init" => func!(crate::emscripten_target::_pthread_cond_init), + "_pthread_cond_signal" => func!(crate::emscripten_target::_pthread_cond_signal), + "_pthread_cond_wait" => func!(crate::emscripten_target::_pthread_cond_wait), + "_pthread_condattr_destroy" => func!(crate::emscripten_target::_pthread_condattr_destroy), + "_pthread_condattr_init" => func!(crate::emscripten_target::_pthread_condattr_init), + "_pthread_condattr_setclock" => func!(crate::emscripten_target::_pthread_condattr_setclock), + "_pthread_mutex_destroy" => func!(crate::emscripten_target::_pthread_mutex_destroy), + "_pthread_mutex_init" => func!(crate::emscripten_target::_pthread_mutex_init), + "_pthread_mutexattr_destroy" => func!(crate::emscripten_target::_pthread_mutexattr_destroy), + "_pthread_mutexattr_init" => func!(crate::emscripten_target::_pthread_mutexattr_init), + "_pthread_mutexattr_settype" => func!(crate::emscripten_target::_pthread_mutexattr_settype), + "_pthread_rwlock_rdlock" => func!(crate::emscripten_target::_pthread_rwlock_rdlock), + "_pthread_rwlock_unlock" => func!(crate::emscripten_target::_pthread_rwlock_unlock), + "_pthread_setcancelstate" => func!(crate::emscripten_target::_pthread_setcancelstate), + "___gxx_personality_v0" => func!(crate::emscripten_target::___gxx_personality_v0), + "_getdtablesize" => func!(crate::emscripten_target::_getdtablesize), + "_gethostbyaddr" => func!(crate::emscripten_target::_gethostbyaddr), + "_gethostbyname_r" => func!(crate::emscripten_target::_gethostbyname_r), + "_getloadavg" => func!(crate::emscripten_target::_getloadavg), + "invoke_dii" => func!(crate::emscripten_target::invoke_dii), + "invoke_diiii" => func!(crate::emscripten_target::invoke_diiii), + "invoke_iiiii" => func!(crate::emscripten_target::invoke_iiiii), + "invoke_iiiiii" => func!(crate::emscripten_target::invoke_iiiiii), + "invoke_iiiiiii" => func!(crate::emscripten_target::invoke_iiiiiii), + "invoke_iiiiiiii" => func!(crate::emscripten_target::invoke_iiiiiiii), + "invoke_iiiiiiiiii" => func!(crate::emscripten_target::invoke_iiiiiiiiii), + "invoke_vd" => func!(crate::emscripten_target::invoke_vd), + "invoke_viiiii" => func!(crate::emscripten_target::invoke_viiiii), + "invoke_viiiiii" => func!(crate::emscripten_target::invoke_viiiiii), + "invoke_viiiiiii" => func!(crate::emscripten_target::invoke_viiiiiii), + "invoke_viiiiiiii" => func!(crate::emscripten_target::invoke_viiiiiiii), + "invoke_viiiiiiiii" => func!(crate::emscripten_target::invoke_viiiiiiiii), + "invoke_iiji" => func!(crate::emscripten_target::invoke_iiji), + "invoke_j" => func!(crate::emscripten_target::invoke_j), + "invoke_ji" => func!(crate::emscripten_target::invoke_ji), + "invoke_jij" => func!(crate::emscripten_target::invoke_jij), + "invoke_jjj" => func!(crate::emscripten_target::invoke_jjj), + "invoke_viiij" => func!(crate::emscripten_target::invoke_viiij), + "invoke_viiijiiii" => func!(crate::emscripten_target::invoke_viiijiiii), + "invoke_viiijiiiiii" => func!(crate::emscripten_target::invoke_viiijiiiiii), + "invoke_viij" => func!(crate::emscripten_target::invoke_viij), + "invoke_viiji" => func!(crate::emscripten_target::invoke_viiji), + "invoke_viijiii" => func!(crate::emscripten_target::invoke_viijiii), + "invoke_viijj" => func!(crate::emscripten_target::invoke_viijj), + "invoke_vij" => func!(crate::emscripten_target::invoke_vij), + "invoke_viji" => func!(crate::emscripten_target::invoke_viji), + "invoke_vijiii" => func!(crate::emscripten_target::invoke_vijiii), + "invoke_vijj" => func!(crate::emscripten_target::invoke_vijj), + "invoke_viidii" => func!(crate::emscripten_target::invoke_viidii), + }; + + for null_func_name in globals.null_func_names.iter() { + env_ns.insert(null_func_name.as_str(), Func::new(nullfunc).to_export()); + } + + let import_object: ImportObject = imports! { + "env" => env_ns, "global" => { "NaN" => Global::new(Value::F64(f64::NAN)), "Infinity" => Global::new(Value::F64(f64::INFINITY)), @@ -801,7 +761,18 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "asm2wasm" => { "f64-rem" => func!(crate::math::f64_rem), }, - } + }; + + import_object +} + +pub fn nullfunc(ctx: &mut Ctx, _x: u32) { + use crate::process::abort_with_message; + debug!("emscripten::nullfunc_i {}", _x); + abort_with_message(ctx, "Invalid function pointer. Perhaps this is an invalid value \ + (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an \ + incorrect type, which will fail? (it is worth building your source files with -Werror (\ + warnings are errors), as warnings can indicate undefined behavior which can cause this)"); } /// The current version of this crate diff --git a/lib/emscripten/src/nullfunc.rs b/lib/emscripten/src/nullfunc.rs deleted file mode 100644 index 8f289599b..000000000 --- a/lib/emscripten/src/nullfunc.rs +++ /dev/null @@ -1,67 +0,0 @@ -use super::process::abort_with_message; -use wasmer_runtime_core::vm::Ctx; - -pub fn nullfunc_i(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_i {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'i'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_ii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_ii {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'ii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_iii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_iii {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'iii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_iiii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_iiii {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'iiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_iiiii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_iiiii {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'iiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_iiiiii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_iiiiii {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'iiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_v(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_v {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_vi(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_vi {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'vi'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_vii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_vii {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'vii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_viii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_viii {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'viii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_viiii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_viiii {}", _x); - abort_with_message(ctx, "Invalid function pointer called with signature 'viiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_viiiii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_viiiii"); - abort_with_message(ctx, "Invalid function pointer called with signature 'viiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} - -pub fn nullfunc_viiiiii(ctx: &mut Ctx, _x: u32) { - debug!("emscripten::nullfunc_viiiiii"); - abort_with_message(ctx, "Invalid function pointer called with signature 'viiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); -} diff --git a/lib/runtime-core/src/macros.rs b/lib/runtime-core/src/macros.rs index a7bdff1b0..e23ce1185 100644 --- a/lib/runtime-core/src/macros.rs +++ b/lib/runtime-core/src/macros.rs @@ -75,3 +75,15 @@ macro_rules! __imports_internal { $ns }; } + +#[macro_export] +#[doc(hidden)] +macro_rules! namespace { + ( $( $imp_name:expr => $import_item:expr, )* ) => {{ + let mut ns = $crate::import::Namespace::new(); + $( + ns.insert($imp_name, $import_item); + )* + ns + }}; +}