diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/js/wasm.js-post.js | 2 | ||||
-rw-r--r-- | src/support/archive.cpp | 4 | ||||
-rw-r--r-- | src/wasm-linker.cpp | 38 |
3 files changed, 26 insertions, 18 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index a0c026c91..6d73981f1 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -188,7 +188,7 @@ function integrateWasmJS(Module) { info['env'] = env; var instance; try { - instance = Wasm.instantiateModule(getBinary(), info); + instance = Wasm['instantiateModule'](getBinary(), info); } catch (e) { Module['printErr']('failed to compile wasm module: ' + e); return false; diff --git a/src/support/archive.cpp b/src/support/archive.cpp index c0351bc05..126f4e2ce 100644 --- a/src/support/archive.cpp +++ b/src/support/archive.cpp @@ -210,8 +210,8 @@ static uint32_t read32be(const uint8_t* buf) { } void Archive::dump() const { - printf("Archive data %p len %lu, firstRegularData %p\n", data.data(), - (long unsigned)data.size(), firstRegularData); + printf("Archive data %p len %zu, firstRegularData %p\n", data.data(), + data.size(), firstRegularData); printf("Symbol table %p, len %u\n", symbolTable.data, symbolTable.len); printf("string table %p, len %u\n", stringTable.data, stringTable.len); const uint8_t* buf = symbolTable.data; diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index f4f516073..a4bd97e2f 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -217,23 +217,31 @@ bool Linker::linkObject(S2WasmBuilder& builder) { } bool Linker::linkArchive(Archive& archive) { - for (auto child = archive.child_begin(), end = archive.child_end(); - child != end; ++child) { - Archive::SubBuffer memberBuf = child->getBuffer(); - // S2WasmBuilder expects its input to be NUL-terminated. Archive members are - // not NUL-terminated. So we have to copy the contents out before parsing. - std::vector<char> memberString(memberBuf.len + 1); - memcpy(memberString.data(), memberBuf.data, memberBuf.len); - memberString[memberBuf.len] = '\0'; - S2WasmBuilder memberBuilder(memberString.data(), false); - auto* memberSymbols = memberBuilder.getSymbolInfo(); - for (const Name& symbol : memberSymbols->implementedFunctions) { - if (out.symbolInfo.undefinedFunctions.count(symbol)) { - if (!linkObject(memberBuilder)) return false; - break; + bool selected; + do { + selected = false; + for (auto child = archive.child_begin(), end = archive.child_end(); + child != end; ++child) { + Archive::SubBuffer memberBuf = child->getBuffer(); + // S2WasmBuilder expects its input to be NUL-terminated. Archive members + // are + // not NUL-terminated. So we have to copy the contents out before parsing. + std::vector<char> memberString(memberBuf.len + 1); + memcpy(memberString.data(), memberBuf.data, memberBuf.len); + memberString[memberBuf.len] = '\0'; + S2WasmBuilder memberBuilder(memberString.data(), false); + auto* memberSymbols = memberBuilder.getSymbolInfo(); + for (const Name& symbol : memberSymbols->implementedFunctions) { + if (out.symbolInfo.undefinedFunctions.count(symbol)) { + if (!linkObject(memberBuilder)) return false; + selected = true; + break; + } } } - } + // If we selected an archive member, it may depend on another archive member + // so continue to make passes over the members until no more are added. + } while (selected); return true; } |