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) {
|
fn publish(&mut self) {
|
||||||
// Now that we're done patching, prepare the memory for execution!
|
// Now that we're done patching, prepare the memory for execution!
|
||||||
self.readonly_memory.set_readonly();
|
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
|
/// SimpleJIT emits code and data into memory as it processes them, so it
|
||||||
|
|||||||
@@ -113,15 +113,15 @@ impl Memory {
|
|||||||
Ok(self.current.ptr)
|
Ok(self.current.ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set all memory allocated in this `Memory` up to now as executable.
|
/// Set all memory allocated in this `Memory` up to now as readable and executable.
|
||||||
pub fn set_executable(&mut self) {
|
pub fn set_readable_and_executable(&mut self) {
|
||||||
self.finish_current();
|
self.finish_current();
|
||||||
|
|
||||||
for &PtrLen { ptr, len } in &self.allocations[self.executable..] {
|
for &PtrLen { ptr, len } in &self.allocations[self.executable..] {
|
||||||
if len != 0 {
|
if len != 0 {
|
||||||
unsafe {
|
unsafe {
|
||||||
region::protect(ptr, len, region::Protection::Execute)
|
region::protect(ptr, len, region::Protection::ReadExecute)
|
||||||
.expect("unable to make memory executable");
|
.expect("unable to make memory readable+executable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user