Skip to content

Commit

Permalink
Merge pull request #168 from philipc/issue-167
Browse files Browse the repository at this point in the history
Don't assert for functions with overlapping address ranges
  • Loading branch information
philipc authored May 19, 2020
2 parents 6ab9f01 + 9a885df commit 6d499fc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,16 @@ impl<R: gimli::Reader> Functions<R> {
}
}
}

// The binary search requires the addresses to be sorted.
//
// It also requires them to be non-overlapping. In practice, overlapping
// function ranges are unlikely, so we don't try to handle that yet.
//
// It's possible for multiple functions to have the same address range if the
// compiler can detect and remove functions with identical code. In that case
// we'll nondeterministically return one of them.
addresses.sort_by_key(|x| x.range.begin);
debug_assert!(addresses
.windows(2)
.all(|w| w[0].range.end <= w[1].range.begin));

Ok(Functions {
functions: functions.into_boxed_slice(),
Expand Down

0 comments on commit 6d499fc

Please sign in to comment.