mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 05:57:03 +03:00
don't bother inserting integer relocations into the relocation table
This commit is contained in:
+5
-9
@@ -620,7 +620,7 @@ fn get_bytes(&self, ptr: Pointer, size: u64, align: u64) -> EvalResult<'tcx, &[u
|
||||
if size == 0 {
|
||||
return Ok(&[]);
|
||||
}
|
||||
if self.has_non_int_relocations(ptr, size)? {
|
||||
if self.relocations(ptr, size)?.count() != 0 {
|
||||
return Err(EvalError::ReadPointerAsBytes);
|
||||
}
|
||||
self.check_defined(ptr, size)?;
|
||||
@@ -718,7 +718,7 @@ pub fn read_c_str(&self, ptr: Pointer) -> EvalResult<'tcx, &[u8]> {
|
||||
let offset = ptr.offset as usize;
|
||||
match alloc.bytes[offset..].iter().position(|&c| c == 0) {
|
||||
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);
|
||||
}
|
||||
self.check_defined(ptr, (size + 1) as u64)?;
|
||||
@@ -761,7 +761,9 @@ pub fn read_ptr(&self, ptr: Pointer) -> EvalResult<'tcx, Pointer> {
|
||||
|
||||
pub fn write_ptr(&mut self, dest: Pointer, ptr: Pointer) -> EvalResult<'tcx> {
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -902,12 +904,6 @@ fn relocations(&self, ptr: Pointer, size: u64)
|
||||
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> {
|
||||
// Find all relocations overlapping the given range.
|
||||
let keys: Vec<_> = self.relocations(ptr, size)?.map(|(&k, _)| k).collect();
|
||||
|
||||
Reference in New Issue
Block a user