diff options
author | Alon Zakai <azakai@google.com> | 2024-07-17 10:48:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 10:48:34 -0700 |
commit | ddf919bb00d07c65caa516dcec3a5d65cc824abb (patch) | |
tree | e5985b37b2f4215007aa0ae588821e3e5041246a /src | |
parent | 9cee7d0c886fac271674ab495b3c15134719abdc (diff) | |
download | binaryen-ddf919bb00d07c65caa516dcec3a5d65cc824abb.tar.gz binaryen-ddf919bb00d07c65caa516dcec3a5d65cc824abb.tar.bz2 binaryen-ddf919bb00d07c65caa516dcec3a5d65cc824abb.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 10 |
1 files changed, 9 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() { |