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:
Dan Gohman
2018-09-19 18:44:23 -07:00
parent d514cec065
commit 6e9c33a1ef
2 changed files with 5 additions and 5 deletions

View File

@@ -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");
}
}
}