From 64f173d71a0cc97de0d5b77b572b5637f481e2df Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 1 Apr 2016 17:34:21 -0700 Subject: verify imports are valid in wasm.js, do not wait to abort if/when they are called --- src/wasm-js.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/wasm-js.cpp') 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 { -- cgit v1.2.3