From ddf919bb00d07c65caa516dcec3a5d65cc824abb Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 17 Jul 2024 10:48:34 -0700 Subject: Error more clearly on wasm components (#6751) Component binary format: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Binary.md#component-definitions Context: https://github.com/WebAssembly/binaryen/issues/6728#issuecomment-2231288924 --- src/wasm/wasm-binary.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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() { -- cgit v1.2.3