Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 583
vossad01 Avatar asked Jan 22 '26 09:01

vossad01


1 Answers

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.

like image 56
kanaka Avatar answered Jan 25 '26 06:01

kanaka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!