Add function to test whether function is exported in wasm blob (#9093)

* Add function to test whether function is exported in wasm blob

* Address Feedback

* Update based on feedback
This commit is contained in:
Lldenaurois
2021-06-13 06:24:05 -04:00
committed by GitHub
parent e508536ca4
commit 2d04fa8717
@@ -81,6 +81,15 @@ impl RuntimeBlob {
export_mutable_globals(&mut self.raw_module, "exported_internal_global");
}
/// Perform an instrumentation that makes sure that a specific function `entry_point` is exported
pub fn entry_point_exists(&self, entry_point: &str) -> bool {
self.raw_module.export_section().map(|e| {
e.entries()
.iter()
.any(|e| matches!(e.internal(), Internal::Function(_)) && e.field() == entry_point)
}).unwrap_or_default()
}
/// Returns an iterator of all globals which were exported by [`expose_mutable_globals`].
pub(super) fn exported_internal_global_names<'module>(
&'module self,