WebAssembly / wabt

The WebAssembly Binary Toolkit
Apache License 2.0
6.85k stars 699 forks source link

Adding some validation of custom sections (e.g. linking section) #1166

Open sbc100 opened 5 years ago

sbc100 commented 5 years ago

wabt currently knows how to parse some custom sections, such as the linking section which are outside of the core spec.

I'd like to add some amount of validation there but its not clear where best to do this. Presumably not in ReadBinaryIr? Would it make sense to add this to ValidateModule? (disabled with the existing --ignore-custom-section-errors option)

binji commented 5 years ago

It probably won't work in ValidateModule, since that would require you to read the data into IR first.

I think the way that fits best with the current design would be to create a separate class for validating linking info. It would have a collection of functions that map directly to the callbacks in binary-reader.h. Then anyone who wants to validate that custom section can forward the calls. It's a bit clumsy with the current design, but that would mean you could share validation between wasm2wat and wasm-objdump, for example.

sbc100 commented 5 years ago

And it would make sense to you to run it as part of wasm-validate?

binji commented 5 years ago

Maybe not by default, but I think it makes sense as a flag.