mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
simplify slices
This commit is contained in:
parent
4508a27fda
commit
ff7df65f36
1 changed files with 11 additions and 18 deletions
|
@ -2520,8 +2520,7 @@ pub fn surgery_elf(
|
|||
|
||||
// Backup section header table.
|
||||
let sh_size = sh_ent_size as usize * sh_num as usize;
|
||||
let mut sh_tab = vec![];
|
||||
sh_tab.extend_from_slice(&exec_mmap[sh_offset as usize..sh_offset as usize + sh_size]);
|
||||
let sh_tab = exec_mmap[sh_offset as usize..][..sh_size].to_vec();
|
||||
|
||||
let mut offset = sh_offset as usize;
|
||||
offset = align_by_constraint(offset, MIN_SECTION_ALIGNMENT);
|
||||
|
@ -2637,20 +2636,16 @@ pub fn surgery_elf(
|
|||
.chain(bss_sections.iter())
|
||||
.chain(text_sections.iter())
|
||||
{
|
||||
let data = match sec.data() {
|
||||
Ok(data) => data,
|
||||
Err(err) => {
|
||||
internal_error!(
|
||||
"Failed to load data for section, {:+x?}: {}",
|
||||
sec.name().unwrap(),
|
||||
err
|
||||
);
|
||||
}
|
||||
};
|
||||
let data = sec.data().unwrap_or_else(|err| {
|
||||
internal_error!(
|
||||
"Failed to load data for section, {:+x?}: {err}",
|
||||
sec.name().unwrap(),
|
||||
)
|
||||
});
|
||||
let (section_offset, section_virtual_offset) =
|
||||
section_offset_map.get(&sec.index()).unwrap();
|
||||
let (section_offset, section_virtual_offset) = (*section_offset, *section_virtual_offset);
|
||||
exec_mmap[section_offset..section_offset + data.len()].copy_from_slice(data);
|
||||
exec_mmap[section_offset..][..data.len()].copy_from_slice(data);
|
||||
// Deal with definitions and relocations for this section.
|
||||
if verbose {
|
||||
println!();
|
||||
|
@ -2745,7 +2740,7 @@ pub fn surgery_elf(
|
|||
|
||||
offset = align_by_constraint(offset, MIN_SECTION_ALIGNMENT);
|
||||
let new_sh_offset = offset;
|
||||
exec_mmap[offset..offset + sh_size].copy_from_slice(&sh_tab);
|
||||
exec_mmap[offset..][..sh_size].copy_from_slice(&sh_tab);
|
||||
offset += sh_size;
|
||||
|
||||
// Flush app only data to speed up write to disk.
|
||||
|
@ -2870,8 +2865,7 @@ pub fn surgery_elf(
|
|||
println!("\tTarget Jump: {:+x}", target);
|
||||
}
|
||||
let data = target.to_le_bytes();
|
||||
exec_mmap[(s.file_offset + md.added_byte_count) as usize
|
||||
..(s.file_offset + md.added_byte_count) as usize + 4]
|
||||
exec_mmap[(s.file_offset + md.added_byte_count) as usize..][..4]
|
||||
.copy_from_slice(&data);
|
||||
}
|
||||
8 => {
|
||||
|
@ -2880,8 +2874,7 @@ pub fn surgery_elf(
|
|||
println!("\tTarget Jump: {:+x}", target);
|
||||
}
|
||||
let data = target.to_le_bytes();
|
||||
exec_mmap[(s.file_offset + md.added_byte_count) as usize
|
||||
..(s.file_offset + md.added_byte_count) as usize + 8]
|
||||
exec_mmap[(s.file_offset + md.added_byte_count) as usize..][..8]
|
||||
.copy_from_slice(&data);
|
||||
}
|
||||
x => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue