diff options
| author | Mark Rowe <mark@vector35.com> | 2025-11-03 15:38:02 -0800 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2025-11-04 16:19:24 -0800 |
| commit | 8a5d29c6c64a32a66b590511b33196deebe7af8a (patch) | |
| tree | 71dd3861eedd43f39d128f9e2da7e7303ebd061b | |
| parent | ade58079a0a3e6b9d1a0793ab4c084d0f9431f4d (diff) | |
[MachO] Set display name of memory regions to match the segment names they correspond to
| -rw-r--r-- | view/macho/machoview.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/view/macho/machoview.cpp b/view/macho/machoview.cpp index 3b6fb74d..f60a538c 100644 --- a/view/macho/machoview.cpp +++ b/view/macho/machoview.cpp @@ -1630,6 +1630,30 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_ } EndBulkAddSegments(); + if (auto memoryMap = GetMemoryMap()) + { + for (auto& segment : header.segments) + { + if (segment.initprot == MACHO_VM_PROT_NONE || !segment.vmsize) + continue; + + auto region = memoryMap->GetActiveMemoryRegionAt(segment.vmaddr); + if (region.empty()) + continue; + + std::string segmentName(segment.segname, std::find(segment.segname, std::end(segment.segname), '\0')); + memoryMap->SetMemoryRegionDisplayName(region, segmentName); + + if (segment.vmsize == segment.filesize) + continue; + + uint64_t zeroFillStart = segment.vmaddr + segment.filesize; + auto zeroFillRegion = memoryMap->GetActiveMemoryRegionAt(zeroFillStart); + if (!zeroFillRegion.empty()) + memoryMap->SetMemoryRegionDisplayName(zeroFillRegion, segmentName + " (zero fill)"); + } + } + for (auto& section : header.sections) { char sectionName[17]; |
