Mark JIT memory as readable in addition to executable.
While we don't currently need this, we will for jump tables and constant pools.
This commit is contained in:
@@ -406,7 +406,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
|
||||
fn publish(&mut self) {
|
||||
// Now that we're done patching, prepare the memory for execution!
|
||||
self.readonly_memory.set_readonly();
|
||||
self.code_memory.set_executable();
|
||||
self.code_memory.set_readable_and_executable();
|
||||
}
|
||||
|
||||
/// SimpleJIT emits code and data into memory as it processes them, so it
|
||||
|
||||
@@ -113,15 +113,15 @@ impl Memory {
|
||||
Ok(self.current.ptr)
|
||||
}
|
||||
|
||||
/// Set all memory allocated in this `Memory` up to now as executable.
|
||||
pub fn set_executable(&mut self) {
|
||||
/// Set all memory allocated in this `Memory` up to now as readable and executable.
|
||||
pub fn set_readable_and_executable(&mut self) {
|
||||
self.finish_current();
|
||||
|
||||
for &PtrLen { ptr, len } in &self.allocations[self.executable..] {
|
||||
if len != 0 {
|
||||
unsafe {
|
||||
region::protect(ptr, len, region::Protection::Execute)
|
||||
.expect("unable to make memory executable");
|
||||
region::protect(ptr, len, region::Protection::ReadExecute)
|
||||
.expect("unable to make memory readable+executable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user