diff options
| author | Xusheng <xusheng@vector35.com> | 2024-11-08 13:29:00 +0800 |
|---|---|---|
| committer | Xusheng <xusheng@vector35.com> | 2024-11-13 18:45:59 +0800 |
| commit | 8a00fb5b8c1b9c82db5528b288859227a7e35868 (patch) | |
| tree | 8d240dcd729437064c0c9d254cde37dc2229dd07 /view/elf/elfview.cpp | |
| parent | 30a0fbb5839b08dc58efe602a5cd19c90fbd4c50 (diff) | |
Bulk add segments in the binary view to improve performance
Diffstat (limited to 'view/elf/elfview.cpp')
| -rw-r--r-- | view/elf/elfview.cpp | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index 8be478f1..fb6942e3 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -496,38 +496,23 @@ bool ElfView::Init() m_entryPoint = m_entryPoint + imageBaseAdjustment; - // Add segments in bulk first - { - vector<BNSegmentInfo> segmentsToAdd; - for (auto& i : m_programHeaders) - { - uint64_t adjustedVirtualAddr = i.virtualAddress + imageBaseAdjustment; - if (i.type == ELF_PT_LOAD) // || i.type == ELF_PT_GNU_RELRO) - { - uint32_t flags = 0; - if (i.flags & 1) - flags |= SegmentExecutable; - if (i.flags & 2) - flags |= SegmentWritable; - if (i.flags & 4) - flags |= SegmentReadable; - - BNSegmentInfo segmentInfo; - segmentInfo.start = adjustedVirtualAddr; - segmentInfo.length = i.memorySize; - segmentInfo.dataOffset = i.offset; - segmentInfo.dataLength = i.fileSize; - segmentInfo.flags = flags; - segmentsToAdd.push_back(segmentInfo); - } - } - AddAutoSegments(segmentsToAdd); - } - + BeginBulkAddSegments(); for (auto& i : m_programHeaders) { uint64_t adjustedVirtualAddr = i.virtualAddress + imageBaseAdjustment; + if (i.type == ELF_PT_LOAD) // || i.type == ELF_PT_GNU_RELRO) + { + uint32_t flags = 0; + if (i.flags & 1) + flags |= SegmentExecutable; + if (i.flags & 2) + flags |= SegmentWritable; + if (i.flags & 4) + flags |= SegmentReadable; + AddAutoSegment(adjustedVirtualAddr, i.memorySize, i.offset, i.fileSize, flags); + } + // Create sections for the program headers with the standard section names. This will ensure that // the standard name for sections such as .dynamic will always refer to what the loader actually uses. if (i.type == ELF_PT_DYNAMIC) @@ -583,6 +568,8 @@ bool ElfView::Init() } } + EndBulkAddSegments(); + // Gather names for the sections vector<string> sectionNames {""}; for (size_t i = 1; i < m_elfSections.size(); i++) |
