[perf2bolt] Improve heuristic to map in-process addresses to specific… (#109397)

… segments in Elf binary.

The heuristic is improved by also taking into account that only
executable segments should contain instructions.

Fixes #109384.
This commit is contained in:
Kristof Beyls
2024-09-23 15:14:51 +02:00
committed by GitHub
parent 6f194a6dea
commit 6d216fb7b8
5 changed files with 41 additions and 18 deletions

View File

@@ -2021,6 +2021,9 @@ BinaryContext::getBaseAddressForMapping(uint64_t MMapAddress,
// Find a segment with a matching file offset.
for (auto &KV : SegmentMapInfo) {
const SegmentInfo &SegInfo = KV.second;
// Only consider executable segments.
if (!SegInfo.IsExecutable)
continue;
// FileOffset is got from perf event,
// and it is equal to alignDown(SegInfo.FileOffset, pagesize).
// If the pagesize is not equal to SegInfo.Alignment.