Add way to access unknown custom sections in `Module`
Robbepop opened this issue · 0 comments
Currently Wasmi just ignores Wasm custom sections when parsing a Wasm module.
However, some users might have a need for querying information about their own custom sections.
For this purpose we might want to add a way to access and query a Wasm modules custom section information.
A potential API for this might look like the following:
impl Module {
pub fn custom_sections(&self) -> impl Iterator<Item = CustomSection>;
}
struct CustomSection { ... }
impl CustomSection {
pub fn name(&self) -> &str { ... }
pub fn data(&self) -> &[u8] { ... }
}
Once Wasmi supports the Wasm standardized name and branch hints custom sections these should no longer be yielded by Module::custom_sections
.
In order to not pessimize performance when parsing or validating Wasm modules with custom sections compared to today's Wasmi we might want to add a flag to wasmi::Config
to indicate that a user is not at all interested in custom section information and disable the new functionality entirely. This new wasmi::Config
flag might be set using config.ignore_custom_sections(true)
. If this flag is set to true
then Module::custom_sections
always returns an iterator that yields no items even if custom sections have been present in the Wasm module.
tl;dr
- Add
Module::custom_sections
method - Do not yield known Wasm custom sections in
Module::custom_sections
such asname
and branch hints section - Add
Config::ignore_custom_sections
configuration