From ed9d1a190383cd4705cf5725dcaef59b122c9770 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Tue, 9 Feb 2021 16:28:46 -0800 Subject: 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. --- src/passes/GenerateDynCalls.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') 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); -- cgit v1.2.3