summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-emscripten.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-08-06 17:25:05 -0700
committerGitHub <noreply@github.com>2019-08-06 17:25:05 -0700
commit777342684f5af51105be710c06591513433ed879 (patch)
treed5414f19925789cbe9b81ca6ee2e721adb28c033 /src/wasm/wasm-emscripten.cpp
parent36909a3205e807534d3bb0dbda6baaa49aedf3ff (diff)
downloadbinaryen-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.cpp7
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;
}