diff --git a/lib/execute/src/lib.rs b/lib/execute/src/lib.rs index 5b1d939b14..0e98adca15 100644 --- a/lib/execute/src/lib.rs +++ b/lib/execute/src/lib.rs @@ -84,23 +84,26 @@ pub fn execute( let start_index = compilation.module.start_func.ok_or_else(|| { String::from("No start function defined, aborting execution") })?; - let code_buf = &compilation.functions[start_index]; - match unsafe { - protect( - code_buf.as_ptr(), - code_buf.len(), - Protection::ReadWriteExecute, - ) - } { - Ok(()) => (), - Err(err) => { - return Err(format!( - "failed to give executable permission to code: {}", - err - )) + for code_buf in &compilation.functions { + match unsafe { + protect( + code_buf.as_ptr(), + code_buf.len(), + Protection::ReadWriteExecute, + ) + } { + Ok(()) => (), + Err(err) => { + return Err(format!( + "failed to give executable permission to code: {}", + err + )) + } } } + let code_buf = &compilation.functions[start_index]; + let vmctx = make_vmctx(instance); // Rather than writing inline assembly to jump to the code region, we use the fact that