WebAssembly / binaryen

Optimizer and compiler/toolchain library for WebAssembly
Apache License 2.0
7.51k stars 745 forks source link

[Question] How to do type evaluation in Binaryen? #6476

Open hungryzzz opened 7 months ago

hungryzzz commented 7 months ago

Hi, I found that when I use WasmBinaryReader to parse a type-mismatched wasm file, it would not raise error messages. So I just wonder could I do the type evaluation in Binaryen? i.e., Simulate execution on an abstract stack to determine whether there is a type mismatch. Thank you!

(; example of type-mismatched code ;)
global.get 0
i32.const 32
i64.sub
kripken commented 7 months ago

To check if the module is valid you also need to run validation,

https://github.com/WebAssembly/binaryen/blob/main/src/wasm-validator.h