From e1ad1aa09ce9e7760a68a8dc7c2dfe64c02aa100 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Tue, 2 Dec 2025 21:27:05 -0800 Subject: [KernelCache] Wrap section creation within BeginBulkAddSegments / EndBulkAddSegments This defers rebuilding of the section map until after all sections for an image have been added, rather than having the section map be rebuilt after adding each section. --- view/kernelcache/core/MachOProcessor.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'view/kernelcache') diff --git a/view/kernelcache/core/MachOProcessor.cpp b/view/kernelcache/core/MachOProcessor.cpp index 5731d80e..55afc408 100644 --- a/view/kernelcache/core/MachOProcessor.cpp +++ b/view/kernelcache/core/MachOProcessor.cpp @@ -31,12 +31,15 @@ void KernelCacheMachOProcessor::ApplyHeader(const KernelCache& cache, KernelCach }; // Add a section for the header itself. + m_view->BeginBulkAddSegments(); std::string headerSection = fmt::format("{}::__macho_header", header.identifierPrefix); uint64_t machHeaderSize = m_view->GetAddressSize() == 8 ? sizeof(mach_header_64) : sizeof(mach_header); uint64_t headerSectionSize = machHeaderSize + header.ident.sizeofcmds; m_view->AddUserSection(headerSection, header.textBase, headerSectionSize, ReadOnlyDataSectionSemantics); ApplyHeaderSections(header); + m_view->EndBulkAddSegments(); + ApplyHeaderDataVariables(header); // Pull the available type library for the image we are loading, so we can apply known types. -- cgit v1.3.1