Skip to content

Commit

Permalink
Use as load address the first mapping for a file
Browse files Browse the repository at this point in the history
This is still not a totally correct calculation, some applications such
as Rust + musl get their executable segments loaded in a way that we
don't recognise yet, but this fixes cases where the loader decides to
split the image in more than 2 segments.

Test Plan
========

See PR.
  • Loading branch information
javierhonduco committed May 8, 2024
1 parent 4247bc3 commit 619093e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,25 +989,22 @@ impl Profiler<'_> {
continue;
};

let mut load_address = map.address.0;
match maps.iter().nth(i.wrapping_sub(1)) {
Some(thing) => {
if thing.pathname == map.pathname {
load_address = thing.address.0;
let load_address = || {
for map2 in maps.iter() {
if map2.pathname == map.pathname {
return map2.address.0;
}
}
_ => {
// todo: cleanup
}
}
map.address.0
};

mappings.push(ExecutableMapping {
build_id: Some(build_id.clone()),
kind: MappingType::FileBacked,
start_addr: map.address.0,
end_addr: map.address.1,
offset: map.offset,
load_address,
load_address: load_address(),
unwinder,
});

Expand Down

0 comments on commit 619093e

Please sign in to comment.