diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index e3c115cd0f..15e16d87f3 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -2422,6 +2422,7 @@ void SharedCache::InitializeHeader( if (settings && settings->Contains("loader.dsc.processFunctionStarts")) applyFunctionStarts = settings->Get("loader.dsc.processFunctionStarts", view); + std::set regionsWithNoSections(regionsToLoad.begin(), regionsToLoad.end()); for (size_t i = 0; i < header.sections.size(); i++) { bool skip = false; @@ -2429,6 +2430,7 @@ void SharedCache::InitializeHeader( { 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; @@ -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);