wasmrun verify
Validate a WebAssembly binary's format, structure, and integrity.
Synopsis
wasmrun verify [WASM_FILE] [OPTIONS]
Description
The verify command checks whether a .wasm file is a valid WebAssembly module. It validates the magic number, version, section structure, and internal consistency. Use it to catch corrupted files, incorrect compilation output, or incompatible WASM versions before execution.
Options
-p, --path <PATH>
Path to the WASM file.
wasmrun verify --path ./output.wasm
wasmrun verify -p ./output.wasm
Positional argument also works:
wasmrun verify ./output.wasm
-d, --detailed
Show detailed information about the module structure.
wasmrun verify ./output.wasm --detailed
Without --detailed, verify outputs a simple pass/fail. With it, you get:
- File size
- Section count and sizes
- Export names and types
- Memory limits
- Start function (if any)
- Function count
Examples
Quick Validation
wasmrun verify ./output.wasm
Output on success:
✅ Valid WebAssembly module: output.wasm
Size: 45,230 bytes
Sections: 8
Exports: 3
Output on failure:
❌ Invalid WebAssembly module: output.wasm
Error: Invalid magic number
Expected: \0asm (0x00 0x61 0x73 0x6D)
Detailed Verification
wasmrun verify ./output.wasm --detailed
✅ Valid WebAssembly module: output.wasm
📊 Module Details:
File size: 45,230 bytes
Sections: 8
Functions: 12
Memory: 1 page initial, 256 pages max
Start function: None
📦 Sections:
Type (1): 128 bytes
Import (2): 256 bytes
Function (3): 48 bytes
Memory (5): 6 bytes
Export (7): 192 bytes
Code (10): 42,800 bytes
Data (11): 1,600 bytes
📤 Exports:
_start (function)
memory (memory)
alloc (function)
Pre-Deployment Check
#!/bin/bash
if wasmrun verify ./dist/app.wasm --detailed; then
echo "✅ Deploying..."
deploy ./dist/app.wasm
else
echo "❌ Verification failed, aborting deployment"
exit 1
fi
After Compilation
wasmrun compile ./my-project --output ./dist
wasmrun verify ./dist/output.wasm --detailed
Batch Verification
for f in ./dist/*.wasm; do
echo "Verifying: $f"
wasmrun verify "$f" || echo "FAILED: $f"
done
Common Errors
Invalid Magic Number
❌ Invalid magic number
Expected: \0asm (0x00 0x61 0x73 0x6D)
The file is not a WASM binary. It may be a text file, wrong format, or corrupted download.
Invalid Version
❌ Invalid WebAssembly version
Expected: 1 (0x01 0x00 0x00 0x00)
The file uses an unsupported WASM version. Recompile with a standard toolchain.
Malformed Section
❌ Malformed section at offset 0x1234
Section: Function
Issue: Size mismatch
The binary is corrupted or was generated by a buggy compiler. Recompile from source.