wasmx / wasm-chisel

Some useful utilities to transform WebAssembly binaries.
Apache License 2.0
55 stars 11 forks source link

WASM validator module #18

Open axic opened 5 years ago

axic commented 5 years ago

This should do semantic validation of the module according to the Wasm specification.

Must also first check how much of that is done by pwasm.

zixuanzh commented 5 years ago

WASM specifies semantics here and pwasm does checking in places like here but not in the module itself. Is the goal of this module to have those semantic validation as shown in pwasm/examples in one place?

axic commented 5 years ago

This task has three parts: 1) Reviewing/documenting the semantic validation steps needed https://webassembly.github.io/spec/core/valid/index.html 2) Reviewing pwasm how much of that validation is implemented: https://github.com/paritytech/parity-wasm 3) Implementing the missing steps here.

zixuanzh commented 5 years ago

@Steampunkery and I implemented verification for a subset of numeric instructions in our fork. parity-wasm checks types for const operators but not for binary as specified in the spec.

We simulated the stack to check for types and hence we added a new validator interface that takes in a mutable self reference. We also use a self defined enum instead of String for error handling and propagation as advised by the documentation. We will be happy to submit a PR if it will be helpful to wasm-chisel.

axic commented 5 years ago

Can you please open a PR? We can review it that way.

pepyakin commented 5 years ago

There is no validation in parity-wasm left and everything migrated to wasmi (see this). Moreover, when we started compiling wasm into internal wasmi IR validation became mixed with compilation concerns.

There was some interest in creating a separate reusable crate from third-parties. I think parity will need this as well at some point.

axic commented 5 years ago

@pepyakin thanks for the heads up!