1
Fork 0

don't bother inserting integer relocations into the relocation table

This commit is contained in:
Ralf Jung 2017-06-05 17:14:48 -07:00
parent 36505c7b40
commit 7bfda59fe2

View file

@ -620,7 +620,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
if size == 0 { if size == 0 {
return Ok(&[]); return Ok(&[]);
} }
if self.has_non_int_relocations(ptr, size)? { if self.relocations(ptr, size)?.count() != 0 {
return Err(EvalError::ReadPointerAsBytes); return Err(EvalError::ReadPointerAsBytes);
} }
self.check_defined(ptr, size)?; self.check_defined(ptr, size)?;
@ -718,7 +718,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
let offset = ptr.offset as usize; let offset = ptr.offset as usize;
match alloc.bytes[offset..].iter().position(|&c| c == 0) { match alloc.bytes[offset..].iter().position(|&c| c == 0) {
Some(size) => { Some(size) => {
if self.has_non_int_relocations(ptr, (size + 1) as u64)? { if self.relocations(ptr, (size + 1) as u64)?.count() != 0 {
return Err(EvalError::ReadPointerAsBytes); return Err(EvalError::ReadPointerAsBytes);
} }
self.check_defined(ptr, (size + 1) as u64)?; self.check_defined(ptr, (size + 1) as u64)?;
@ -761,7 +761,9 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
pub fn write_ptr(&mut self, dest: Pointer, ptr: Pointer) -> EvalResult<'tcx> { pub fn write_ptr(&mut self, dest: Pointer, ptr: Pointer) -> EvalResult<'tcx> {
self.write_usize(dest, ptr.offset as u64)?; self.write_usize(dest, ptr.offset as u64)?;
self.get_mut(dest.alloc_id)?.relocations.insert(dest.offset, ptr.alloc_id); if ptr.alloc_id != NEVER_ALLOC_ID {
self.get_mut(dest.alloc_id)?.relocations.insert(dest.offset, ptr.alloc_id);
}
Ok(()) Ok(())
} }
@ -902,12 +904,6 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
Ok(self.get(ptr.alloc_id)?.relocations.range(start..end)) Ok(self.get(ptr.alloc_id)?.relocations.range(start..end))
} }
fn has_non_int_relocations(&self, ptr: Pointer, size: u64)
-> EvalResult<'tcx, bool>
{
Ok(self.relocations(ptr, size)?.any(|(_, &alloc_id)| alloc_id != NEVER_ALLOC_ID))
}
fn clear_relocations(&mut self, ptr: Pointer, size: u64) -> EvalResult<'tcx> { fn clear_relocations(&mut self, ptr: Pointer, size: u64) -> EvalResult<'tcx> {
// Find all relocations overlapping the given range. // Find all relocations overlapping the given range.
let keys: Vec<_> = self.relocations(ptr, size)?.map(|(&k, _)| k).collect(); let keys: Vec<_> = self.relocations(ptr, size)?.map(|(&k, _)| k).collect();