vossad01
vossad01

Reputation: 11958

How to check the WebAssembly version of a wasm binary

Given a .wasm file how can I check the version of the binary encoding?


I have been trying to experiment with WebAssembly but have started to encounter what I understand to be versioning issues resulting in messages such as:

Error: Wasm.instantiateModule(): Wasm decoding failedResult = expected version 0c 00 00 00, found 0b 00 00 00 @+4

or

Error: Wasm.instantiateModule(): Wasm decoding failedResult = expected version 0c 00 00 00, found 01 00 00 00 @+4

Other than running it against a WebAssembly embedder that does not support a given file to get the above error, how can I check the version of a wasm file?


Edit: According to the recent release notes, this is a time-limited issue, going forward the version for all assemblies will 0x1.

Upvotes: 2

Views: 2273

Answers (1)

kanaka
kanaka

Reputation: 73187

If you have a hexdump utility you can look at the bytes 4-7 bytes of the file. For example, with the Linux hexdump utility:

$ hexdump -C -n8 examples_c/hello_sdl.wasm | head
00000000  00 61 73 6d 01 00 00 00                           |.asm....|
00000008

The first four bytes are the wasm magic number (0x0061736d or '\00asm'). The next 4 bytes are the version (little endian). So in the example above the version is 0x01 which is MVP (Minimum Viable Product).

At some point I'm sure the standard linux file command will identify WebAssembly files and print the version.

The full format is described in the WebAssembly binary encoding page.

Upvotes: 9

Related Questions