fix underflow in duration calculation

This commit is contained in:
Folkert 2022-09-24 22:53:50 +02:00
parent 220f975ea8
commit 320aa504cd
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -2102,15 +2102,14 @@ fn surgery_elf_and_macho(
report_timing("Loading and mmap-ing", load_and_mmap_duration); report_timing("Loading and mmap-ing", load_and_mmap_duration);
report_timing("Output Generation", out_gen_duration); report_timing("Output Generation", out_gen_duration);
report_timing("Flushing Data to Disk", flushing_data_duration); report_timing("Flushing Data to Disk", flushing_data_duration);
report_timing(
"Other", let sum = loading_metadata_duration
total_duration + app_parsing_duration
- loading_metadata_duration + load_and_mmap_duration
- app_parsing_duration + out_gen_duration
- load_and_mmap_duration + flushing_data_duration;
- out_gen_duration
- flushing_data_duration, report_timing("Other", total_duration.saturating_sub(sum));
);
report_timing("Total", total_duration); report_timing("Total", total_duration);
} }
} }
@ -2752,34 +2751,39 @@ fn surgery_elf(
}; };
if verbose { if verbose {
println!( println!(
"\t\tRelocation base location: {:+x} (virt: {:+x})", "\t\tRelocation base location: {base:+x} (virt: {virt_base:+x})",
base, virt_base
); );
println!("\t\tFinal relocation target offset: {:+x}", target); println!("\t\tFinal relocation target offset: {target:+x}");
} }
match rel.1.size() { match rel.1.size() {
32 => { 32 => {
let data = (target as i32).to_le_bytes(); let data = (target as i32).to_le_bytes();
exec_mmap[base..base + 4].copy_from_slice(&data); exec_mmap[base..][..4].copy_from_slice(&data);
} }
64 => { 64 => {
let data = target.to_le_bytes(); let data = target.to_le_bytes();
exec_mmap[base..base + 8].copy_from_slice(&data); exec_mmap[base..][..8].copy_from_slice(&data);
} }
x => { other => {
internal_error!("Relocation size not yet supported: {}", x); internal_error!("Relocation size not yet supported: {other}");
} }
} }
} else if matches!(app_obj.symbol_by_index(index), Ok(sym) if ["__divti3", "__udivti3"].contains(&sym.name().unwrap_or_default()))
{
// Explicitly ignore some symbols that are currently always linked.
continue;
} else { } else {
internal_error!( // Explicitly ignore some symbols that are currently always linked.
"Undefined Symbol in relocation, {:+x?}: {:+x?}", const ALWAYS_LINKED: &[&str] = &["__divti3", "__udivti3"];
rel,
app_obj.symbol_by_index(index) match app_obj.symbol_by_index(index) {
); Ok(sym) if ALWAYS_LINKED.contains(&sym.name().unwrap_or_default()) => {
continue
}
_ => {
internal_error!(
"Undefined Symbol in relocation, {:+x?}: {:+x?}",
rel,
app_obj.symbol_by_index(index)
);
}
}
} }
} }