Add a custom section hook to ModuleEnvironment
This commit adds a hook to the `ModuleEnvironment` trait to learn when a custom section in a wasm file is read. This hook can in theory be used to parse and handle custom sections as they appear in the wasm file without having to re-iterate over the wasm file after cranelift has already parsed the wasm file. The `translate_module` function is now less strict in that it doesn't require sections to be in a particular order, but it's figured that the wasm file is already validated elsewhere to verify the section order.
This commit is contained in:
committed by
Dan Gohman
parent
8fd1128990
commit
dfda794f55
@@ -467,4 +467,14 @@ pub trait ModuleEnvironment<'data> {
|
||||
offset: usize,
|
||||
data: &'data [u8],
|
||||
) -> WasmResult<()>;
|
||||
|
||||
/// Indicates that a custom section has been found in the wasm file
|
||||
fn custom_section(
|
||||
&mut self,
|
||||
name: &'data str,
|
||||
data: &'data [u8],
|
||||
) -> WasmResult<()> {
|
||||
drop((name, data));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user