diff options
author | Derek Schuff <dschuff@chromium.org> | 2016-09-30 10:47:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-30 10:47:52 -0700 |
commit | cbe71a99f3b53db81cfd23f7a12f2010daeff65d (patch) | |
tree | 73342cd6db91ce3a6fd18b9ec6a733f9d91ea21f /src | |
parent | 2a543b48db250ea9cd7172b6db9a0b8d3657475a (diff) | |
download | binaryen-cbe71a99f3b53db81cfd23f7a12f2010daeff65d.tar.gz binaryen-cbe71a99f3b53db81cfd23f7a12f2010daeff65d.tar.bz2 binaryen-cbe71a99f3b53db81cfd23f7a12f2010daeff65d.zip |
Make the linker always create a table segment (#722)
Previously a table was only created if there were any address-taken
functions. New module validation rules require the existence of
a table for any call-indirects to validate (even if they are dead and
never called). However this use case seems common enough that we might
want to make it continue to work. So the linker now always creates an empty table segment (indicating an empty table).
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Print.cpp | 2 | ||||
-rw-r--r-- | src/wasm-linker.cpp | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 572732275..275d52888 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -634,6 +634,8 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } doIndent(o, indent); for (auto& segment : curr->segments) { + // Don't print empty segments + if (segment.data.empty()) continue; printOpening(o, "elem ", true); visit(segment.offset); for (auto name : segment.data) { diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index 80374c1e4..6e3eae1fb 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -122,6 +122,7 @@ void Linker::layout() { // Pad the indirect function table with a dummy function makeDummyFunction(); + ensureTableIsPopulated(); // Pre-assign the function indexes for (auto& pair : out.indirectIndexes) { @@ -359,6 +360,7 @@ void Linker::makeDummyFunction() { break; } } + if (!create) return; wasm::Builder wasmBuilder(out.wasm); Expression *unreachable = wasmBuilder.makeUnreachable(); |