Skip to content

Commit e2bcf29

Browse files
jonpalmiscbdash
authored andcommitted
[KernelCache] Set region display names
This makes it easier to obtain the bounds of segments and mirrors the functionality of the shared cache support.
1 parent cbab54c commit e2bcf29

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

view/kernelcache/core/KernelCacheController.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ bool KernelCacheController::ApplyImage(BinaryView& view, const CacheImage& image
122122
if (!view.IsValidOffset(image.headerVirtualAddress))
123123
{
124124
loadedRegion = true;
125+
auto memoryMap = view.GetMemoryMap();
125126
for (const auto& segment : image.header->segments)
126127
{
127128
if (segment.vmsize == 0)
@@ -130,6 +131,25 @@ bool KernelCacheController::ApplyImage(BinaryView& view, const CacheImage& image
130131
auto flags = SegmentFlagsForSegment(segment);
131132
view.AddAutoSegment(segment.vmaddr, segment.vmsize, segment.fileoff, segment.filesize, flags);
132133

134+
if (memoryMap)
135+
{
136+
std::string segmentName(segment.segname, std::find(segment.segname, std::end(segment.segname), '\0'));
137+
std::string displayName = image.GetName() + "::" + segmentName;
138+
139+
auto region = memoryMap->GetActiveMemoryRegionAt(segment.vmaddr);
140+
if (!region.empty())
141+
memoryMap->SetMemoryRegionDisplayName(region, displayName);
142+
143+
if (segment.vmsize != segment.filesize)
144+
{
145+
auto fillStart = segment.vmaddr + segment.filesize;
146+
auto fillRegion = memoryMap->GetActiveMemoryRegionAt(fillStart);
147+
148+
if (!fillRegion.empty() && fillRegion != region)
149+
memoryMap->SetMemoryRegionDisplayName(fillRegion, displayName + " (zero fill)");
150+
}
151+
}
152+
133153
const auto& relocations = m_cache.GetRelocations();
134154

135155
auto begin = std::lower_bound(relocations.begin(), relocations.end(), segment.vmaddr,

0 commit comments

Comments
 (0)