Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions view/sharedcache/core/SharedCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2422,13 +2422,15 @@ void SharedCache::InitializeHeader(
if (settings && settings->Contains("loader.dsc.processFunctionStarts"))
applyFunctionStarts = settings->Get<bool>("loader.dsc.processFunctionStarts", view);

std::set<const MemoryRegion*> regionsWithNoSections(regionsToLoad.begin(), regionsToLoad.end());
for (size_t i = 0; i < header.sections.size(); i++)
{
bool skip = false;
for (const auto& region : regionsToLoad)
{
if (header.sections[i].addr >= region->start && header.sections[i].addr < region->start + region->size)
{
regionsWithNoSections.erase(region);
if (MemoryRegionIsHeaderInitialized(lock, *region))
skip = true;
break;
Expand Down Expand Up @@ -2549,6 +2551,16 @@ void SharedCache::InitializeHeader(
type, header.sections[i].align);
}

// Some segments like `libobjc.A.dylib::__OBJC_RW` don't have any sections. A section is added for segments like
// this so that they display nicely in Binary Ninja. Otherwise it can be confusing where data came from if it has
// no section.
for (const auto& region : regionsWithNoSections)
{
if (MemoryRegionIsHeaderInitialized(lock, *region))
continue;
view->AddUserSection(region->prettyName, region->start, region->size, SectionSemanticsForRegion(*region));
}

auto typeLib = view->GetTypeLibrary(header.installName);

BinaryReader virtualReader(view);
Expand Down