wa-diff
0.3.0
See the version list below for details.
dotnet tool install --global wa-diff --version 0.3.0
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local wa-diff --version 0.3.0
#tool dotnet:?package=wa-diff&version=0.3.0
nuke :add-package wa-diff --version 0.3.0
wa-info
wa-info
is a tool to inspect WebAssembly binary format wasm files.
It can show sections overview in the summary output, disassemble function(s) code, show information about dotnet AOT. It is available as dotnet tool.
wa-diff
wa-diff
is a tool to compare WebAssembly binary files
wa-edit
wa-edit
is a tool to modify WebAssembly binary files
Installation
To install wa-info
, wa-diff
and wa-edit
as dotnet tool run:
dotnet tool install -g wa-info
dotnet tool install -g wa-diff
dotnet tool install -g wa-edit
to update use:
dotnet tool update -g wa-info
dotnet tool update -g wa-diff
dotnet tool update -g wa-edit
Nugets
The packaged tools can be also retrieved as nugets
https://www.nuget.org/packages/wa-info https://www.nuget.org/packages/wa-diff https://www.nuget.org/packages/wa-edit
Command line options
wa-info:
Usage: wa-info OPTIONS* file.wasm [file2.wasm ...]
Provides information about WebAssembly file(s)
Copyright 2021 Microsoft Corporation
Options:
--aot-stats Show stats about methods
-a, --assembly-filter=REGEX
Filter assemblies and process only those matching
REGEX
-d, --disassemble Show functions(s) disassembled code
-f, --function-filter=REGEX
Filter wasm functions REGEX
--function-offset=REGEX
Filter wasm functions REGEX
-h, --help, -? Show this message and exit
-o, --instruction-offsets Show instruction offsets
-t, --type-filter=REGEX Filter types and process only those matching REGEX
-v, --verbose Output information about progress during the run
of the tool. Use multiple times to increase
verbosity, like -vv
wa-diff:
Usage: wa-diff OPTIONS* file1.wasm file2.wasm
Compares WebAssembly binary file(s)
Copyright 2021 Microsoft Corporation
Options:
-d, --disassemble Show functions(s) disassembled code
-f, --function-filter=REGEX
Filter wasm functions REGEX
--function-offset=REGEX
Filter wasm functions REGEX
-h, --hide-const-loads Hide const loads values
-s, --function-size Compare function code sizes
-v, --verbose Output information about progress during the run
of the tool. Use multiple times to increase
verbosity, like -vv
wa-edit:
Usage: wa-edit OPTIONS* source.wasm destination.wasm
Modifies WebAssembly file (source.wasm) and writes updated file (destination.
wasm)
Copyright 2022 Microsoft Corporation
Options:
-a, --data-auto-split Split the data segment to avoid long empty chunks
with zeroes
-d, --data-section=FILE Replace the data section with content of the FILE
-m, --data-section-mode=MODE
Set the data section replacement MODE. Possible
values: Active, Passive
-o, --data-offset=VALUE Data section offset
-h, --help, -? Show this message and exit
-v, --verbose Output information about progress during the run
of the tool. Use multiple times to increase
verbosity, like -vv
Example usage
Disassemble function
> wa-info -d -f test test.wasm
(func test_simd(param i32) (result i32))
local 1 123
local.get $0
i32x4.splat [SIMD]
local.tee $1
local.get $1
i16x8.avgr.u [SIMD]
i32x4.extract.lane [SIMD]
Summary of the module and sections
> wa-info dotnet.wasm
Module: path: dotnet.wasm
size: 74,502,446
binary format version: 1
sections: 17
id: Type size: 5,237
id: Import size: 4,315
id: Function size: 163,566
id: Table size: 9
id: Memory size: 7
id: Global size: 19
id: Export size: 7,213
id: Element size: 428,929
id: Code size: 34,177,740
id: Data size: 9,520,741
id: Custom name: name size: 21,544,785
id: Custom name: .debug_info size: 4,035,679
id: Custom name: .debug_loc size: 1,436,083
id: Custom name: .debug_ranges size: 140,966
id: Custom name: .debug_abbrev size: 240,230
id: Custom name: .debug_line size: 2,060,872
id: Custom name: .debug_str size: 735,984
Disassemble function
note: build the app with -p:WasmNativeDebugSymbols=true -p:WasmNativeStrip=false
to preserve name custom section
> wa-info -d -f ves_icall_RuntimeFieldInfo_GetValueInternal$ dotnet.wasm
(func ves_icall_RuntimeFieldInfo_GetValueInternal(param i32 i32 i32) (result i32))
local.get $0
i32.load align:2
i32.load offset:12 align:2
local.tee $0
local.get $1
if
local.get $1
i32.load align:2
else
i32.const 0
local.tee $1
local.get $2
call mono_field_get_value_object_checked
i32.const 11201820
i32.load align:2
call mono_handle_new
Get AOT stats
> wa-info --aot-stats dotnet.wasm
AOT stats: 5005 function(s) call(s) interpreter, 2.96% of 169215 functions
Compare functions
> wa-diff -d -f corlib_System_RuntimeType_IsDelegate dotnet1.wasm dotnet2.wasm
(func corlib_System_RuntimeType_IsDelegate(param i32 i32) (result i32))
...
local.tee $2
global.set $__stack_pointer
- i32.const 1573600
+ i32.const 1573760
i32.load8.u
i32.eqz
...
i32.const 25177
call aot_wrapper_pinvoke_corlib__Interop_sl_Sys___le_PosixFAdvise_gt_g____PInvoke___verbar_83_0_pinvoke_i4_iii8i8cl1a_Interop_2fSys_2fFileAdvice_i4_iii8i8cl1a_Interop_2fSys_2fFileAdvice_
- i32.const 1573600
+ i32.const 1573760
i32.const 1
i32.store8
...
i32.store offset:12 align:2
local.get $2
- i32.const 1516792
+ i32.const 1516952
i32.load align:2
local.tee $3
Hide load consts, this helps to reduce "noise" when checking the code changes. Output with -h
> wa-diff -h -d -f corlib.*Vector128_1_long_GetHashCode 1.wasm 2.wasm
(func corlib_System_Runtime_Intrinsics_Vector128_1_long_GetHashCode(param i32, i32) (result i32))
...
i64.load align:3
local.get $1
- call corlib_System_HashCode_Add_T_ULONG_T_ULONG
+ call corlib_System_HashCode_Add_T_LONG_T_LONG
local.get $0
i32.const
...
i64.load offset:8 align:3
local.get $1
- call corlib_System_HashCode_Add_T_ULONG_T_ULONG
+ call corlib_System_HashCode_Add_T_LONG_T_LONG
local.get $1
local.get $1
and standard output:
> wa-diff -d -f corlib.*Vector128_1_long_GetHashCode 1.wasm 2.wasm
(func corlib_System_Runtime_Intrinsics_Vector128_1_long_GetHashCode(param i32, i32) (result i32))
...
local.tee $1
global.set $global:0
- i32.const 4411468
+ i32.const 4900240
i32.load8.u
i32.eqz
if
- i32.const 869872
+ i32.const 1032336
call mono_aot_corlib_init_method
- i32.const 4411468
+ i32.const 4900240
i32.const 1
i32.store8
...
i64.load align:3
local.get $1
- call corlib_System_HashCode_Add_T_ULONG_T_ULONG
+ call corlib_System_HashCode_Add_T_LONG_T_LONG
local.get $0
i32.const -1
...
i64.load offset:8 align:3
local.get $1
- call corlib_System_HashCode_Add_T_ULONG_T_ULONG
+ call corlib_System_HashCode_Add_T_LONG_T_LONG
local.get $1
local.get $1
Replace Data section
> wa-edit -v dotnet.wasm d4.wasm -a -o 0 -d memory.dat
Reading wasm file: dotnet.wasm
Writing wasm file: d4.wasm
WebAssembly binary format version: 1
Reading section: Type size: 1632
Reading section: Import size: 3104
Reading section: Function size: 17745
Reading section: Table size: 5
Reading section: Memory size: 7
Reading section: Global size: 2394
Reading section: Export size: 4227
Reading section: Element size: 8702
Reading section: Code size: 6282132
Reading section: Data size: 649676 segments detected: 29,539 zero bytes stripped: 48,137,494
Reading section: Custom size: 880619
Reading section: Custom size: 3388054
Reading section: Custom size: 360611
Reading section: Custom size: 134358
Reading section: Custom size: 211464
Reading section: Custom size: 3645378
Reading section: Custom size: 706701
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
This package has no dependencies.