diff options
Diffstat (limited to 'view/elf/elfview.cpp')
| -rw-r--r-- | view/elf/elfview.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index 4edb2ca7..8be478f1 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -496,21 +496,37 @@ bool ElfView::Init() m_entryPoint = m_entryPoint + imageBaseAdjustment; - for (auto& i : m_programHeaders) + // Add segments in bulk first { - uint64_t adjustedVirtualAddr = i.virtualAddress + imageBaseAdjustment; - - if (i.type == ELF_PT_LOAD) // || i.type == ELF_PT_GNU_RELRO) + vector<BNSegmentInfo> segmentsToAdd; + for (auto& i : m_programHeaders) { - 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); + 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); + } + + for (auto& i : m_programHeaders) + { + uint64_t adjustedVirtualAddr = i.virtualAddress + imageBaseAdjustment; // 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. |
