diff options
| author | Wesley Wiser <wwiser@gmail.com> | 2018-06-30 00:44:58 -0400 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2018-06-30 00:44:58 -0400 |
| commit | 84fe0c40a1829ebac169a1f7804da4b557b31359 (patch) | |
| tree | 726ab2721377a18ae362a9f7bc5f03c2019728be /src/librustc_mir/interpret | |
| parent | c431f3fab90efa2100c5b7189d01a47bb69e4ed6 (diff) | |
| download | rust-84fe0c40a1829ebac169a1f7804da4b557b31359.tar.gz rust-84fe0c40a1829ebac169a1f7804da4b557b31359.zip | |
Fix relocations to include repeated values
Diffstat (limited to 'src/librustc_mir/interpret')
| -rw-r--r-- | src/librustc_mir/interpret/memory.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 2f961ef9d97..8aff58e09ba 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -621,13 +621,21 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { // first copy the relocations to a temporary buffer, because // `get_bytes_mut` will clear the relocations, which is correct, // since we don't want to keep any relocations at the target. - let relocations: Vec<_> = self.relocations(src, size)? - .iter() - .map(|&(offset, alloc_id)| { - // Update relocation offsets for the new positions in the destination allocation. - (offset + dest.offset - src.offset, alloc_id) - }) - .collect(); + let relocations = { + let relocations = self.relocations(src, size)?; + let mut new_relocations = Vec::with_capacity(relocations.len() * (length as usize)); + for i in 0..length { + new_relocations.extend( + relocations + .iter() + .map(|&(offset, alloc_id)| { + (offset + dest.offset - src.offset + (i * size * relocations.len() as u64), alloc_id) + }) + ); + } + + new_relocations + }; let src_bytes = self.get_bytes_unchecked(src, size, src_align)?.as_ptr(); let dest_bytes = self.get_bytes_mut(dest, size * length, dest_align)?.as_mut_ptr(); |
