diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-01 17:34:21 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-01 17:34:21 -0700 |
commit | 64f173d71a0cc97de0d5b77b572b5637f481e2df (patch) | |
tree | 2084d32bf6569f5fefb75a8eedf418a68b4847d1 | |
parent | c0c0abc12c62dc4f86eb42a09b0f47b212eb273d (diff) | |
download | binaryen-64f173d71a0cc97de0d5b77b572b5637f481e2df.tar.gz binaryen-64f173d71a0cc97de0d5b77b572b5637f481e2df.tar.bz2 binaryen-64f173d71a0cc97de0d5b77b572b5637f481e2df.zip |
verify imports are valid in wasm.js, do not wait to abort if/when they are called
-rw-r--r-- | src/wasm-js.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp index 151803db1..1db313727 100644 --- a/src/wasm-js.cpp +++ b/src/wasm-js.cpp @@ -177,6 +177,18 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { }, curr->name.str); } + // verify imports are provided + for (auto& pair : module->importsMap) { + auto& name = pair.first; + auto* import = pair.second; + EM_ASM_({ + var mod = Pointer_stringify($0); + var base = Pointer_stringify($1); + var name = Pointer_stringify($2); + assert(Module['lookupImport'](mod, base), 'checking import ' + name + ' = ' + mod + '.' + base); + }, import->module.str, import->base.str, name.str); + } + if (wasmJSDebug) std::cerr << "creating instance...\n"; struct JSExternalInterface : ModuleInstance::ExternalInterface { |