From 2d04fa8717b3d07c92334a4f81f78132b1f8a55e Mon Sep 17 00:00:00 2001 From: Lldenaurois Date: Sun, 13 Jun 2021 06:24:05 -0400 Subject: [PATCH] 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 --- .../executor/common/src/runtime_blob/runtime_blob.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/substrate/client/executor/common/src/runtime_blob/runtime_blob.rs b/substrate/client/executor/common/src/runtime_blob/runtime_blob.rs index aac023e960..82b9312dec 100644 --- a/substrate/client/executor/common/src/runtime_blob/runtime_blob.rs +++ b/substrate/client/executor/common/src/runtime_blob/runtime_blob.rs @@ -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,