Make all the function bodies executable, not just the start function.
This commit is contained in:
@@ -84,23 +84,26 @@ pub fn execute(
|
|||||||
let start_index = compilation.module.start_func.ok_or_else(|| {
|
let start_index = compilation.module.start_func.ok_or_else(|| {
|
||||||
String::from("No start function defined, aborting execution")
|
String::from("No start function defined, aborting execution")
|
||||||
})?;
|
})?;
|
||||||
let code_buf = &compilation.functions[start_index];
|
for code_buf in &compilation.functions {
|
||||||
match unsafe {
|
match unsafe {
|
||||||
protect(
|
protect(
|
||||||
code_buf.as_ptr(),
|
code_buf.as_ptr(),
|
||||||
code_buf.len(),
|
code_buf.len(),
|
||||||
Protection::ReadWriteExecute,
|
Protection::ReadWriteExecute,
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"failed to give executable permission to code: {}",
|
"failed to give executable permission to code: {}",
|
||||||
err
|
err
|
||||||
))
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let code_buf = &compilation.functions[start_index];
|
||||||
|
|
||||||
let vmctx = make_vmctx(instance);
|
let vmctx = make_vmctx(instance);
|
||||||
|
|
||||||
// Rather than writing inline assembly to jump to the code region, we use the fact that
|
// Rather than writing inline assembly to jump to the code region, we use the fact that
|
||||||
|
|||||||
Reference in New Issue
Block a user