summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-02-09 16:28:46 -0800
committerGitHub <noreply@github.com>2021-02-10 00:28:46 +0000
commited9d1a190383cd4705cf5725dcaef59b122c9770 (patch)
tree5d102fcfe6fa819999dce98a749d998622f1864a /src
parente130b58895b64a0fe3a088e25f4043a12f3634ca (diff)
downloadbinaryen-ed9d1a190383cd4705cf5725dcaef59b122c9770.tar.gz
binaryen-ed9d1a190383cd4705cf5725dcaef59b122c9770.tar.bz2
binaryen-ed9d1a190383cd4705cf5725dcaef59b122c9770.zip
Use correct table name in GenerateDynCalls (#3560)
GenerateDynCalls was hardcoding the table name to use in the call_indirects in the dyncall thunks. The hardcoded name was different from the default name for imported tables, so the call_indirects referred to a nonexistent table when dynamic linking was enabled. This PR instead uses the name of table 0 when creating call_indirects for the dyncall thunks.
Diffstat (limited to 'src')
-rw-r--r--src/passes/GenerateDynCalls.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/passes/GenerateDynCalls.cpp b/src/passes/GenerateDynCalls.cpp
index a53f1d0de..9669dcdb8 100644
--- a/src/passes/GenerateDynCalls.cpp
+++ b/src/passes/GenerateDynCalls.cpp
@@ -129,9 +129,8 @@ void GenerateDynCalls::generateDynCallThunk(Signature sig) {
}
// FIXME: Should the existence of a table be ensured here? i.e. create one if
// there is none?
- Expression* call =
- builder.makeCallIndirect(Name::fromInt(0), fptr, args, sig);
- f->body = call;
+ assert(wasm->tables.size() > 0);
+ f->body = builder.makeCallIndirect(wasm->tables[0]->name, fptr, args, sig);
wasm->addFunction(std::move(f));
exportFunction(*wasm, name, true);