diff options
author | Sam Clegg <sbc@chromium.org> | 2019-08-06 17:25:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-06 17:25:05 -0700 |
commit | 777342684f5af51105be710c06591513433ed879 (patch) | |
tree | d5414f19925789cbe9b81ca6ee2e721adb28c033 /src/wasm/wasm-emscripten.cpp | |
parent | 36909a3205e807534d3bb0dbda6baaa49aedf3ff (diff) | |
download | binaryen-777342684f5af51105be710c06591513433ed879.tar.gz binaryen-777342684f5af51105be710c06591513433ed879.tar.bz2 binaryen-777342684f5af51105be710c06591513433ed879.zip |
wasm-emscripten-finalize: Remove reliance on name section (#2285)
There were a couple of places where we were relying on internal
names and therefore a name section. After this change
wasm-emscripten-finalize works correctly on binaries without a name
section at all and only relies on the names of imports and exports.
Diffstat (limited to 'src/wasm/wasm-emscripten.cpp')
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index c21016baa..caea83302 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -848,18 +848,19 @@ struct EmJsWalker : public PostWalker<EmJsWalker> { EmJsWalker(Module& _wasm) : wasm(_wasm), segmentOffsets(getSegmentOffsets(wasm)) {} - void visitFunction(Function* curr) { - if (curr->imported()) { + void visitExport(Export* curr) { + if (curr->kind != ExternalKind::Function) { return; } if (!curr->name.startsWith(EM_JS_PREFIX.str)) { return; } + auto* func = wasm.getFunction(curr->value); auto funcName = std::string(curr->name.stripPrefix(EM_JS_PREFIX.str)); // An EM_JS has a single const in the body. Typically it is just returned, // but in unoptimized code it might be stored to a local and loaded from // there, and in relocatable code it might get added to __memory_base etc. - FindAll<Const> consts(curr->body); + FindAll<Const> consts(func->body); if (consts.list.size() != 1) { Fatal() << "Unexpected generated __em_js__ function body: " << curr->name; } |