summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/wasm-binary.cpp10
-rw-r--r--test/lit/binary/component-error.test6
-rw-r--r--test/lit/binary/component-error.test.wasmbin0 -> 8 bytes
3 files changed, 15 insertions, 1 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 74d74f473..ee8afeb93 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -2243,7 +2243,15 @@ void WasmBinaryReader::verifyInt64(int64_t x) {
void WasmBinaryReader::readHeader() {
BYN_TRACE("== readHeader\n");
verifyInt32(BinaryConsts::Magic);
- verifyInt32(BinaryConsts::Version);
+ auto version = getInt32();
+ if (version != BinaryConsts::Version) {
+ if (version == 0x1000d) {
+ throwError("this looks like a wasm component, which Binaryen does not "
+ "support yet (see "
+ "https://github.com/WebAssembly/binaryen/issues/6728)");
+ }
+ throwError("invalid version");
+ }
}
void WasmBinaryReader::readStart() {
diff --git a/test/lit/binary/component-error.test b/test/lit/binary/component-error.test
new file mode 100644
index 000000000..57bcec457
--- /dev/null
+++ b/test/lit/binary/component-error.test
@@ -0,0 +1,6 @@
+# Verify that we show an error when given a component.
+
+;; RUN: not wasm-opt %s.wasm 2>&1 | filecheck %s
+
+;; CHECK: this looks like a wasm component, which Binaryen does not support yet (see https://github.com/WebAssembly/binaryen/issues/6728)
+
diff --git a/test/lit/binary/component-error.test.wasm b/test/lit/binary/component-error.test.wasm
new file mode 100644
index 000000000..13d20e9f0
--- /dev/null
+++ b/test/lit/binary/component-error.test.wasm
Binary files differ