diff options
| -rw-r--r-- | view/elf/elfview.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index 29914ca7..5bfcd5c8 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -1254,6 +1254,7 @@ bool ElfView::Init() } size_t commonSegmentOffset = 0; + auto allSections = GetSections(); for (auto entry = combinedSymbolTable.begin(); entry != combinedSymbolTable.end(); entry++) { if (entry->section == ELF_SHN_COMMON) @@ -1273,13 +1274,19 @@ bool ElfView::Init() // Object files "entry.value" is section relative uint64_t adjustedSectionAddr = m_elfSections[entry->section].address + imageBaseAdjustment; - auto secs = GetSectionsAt(adjustedSectionAddr); - if (secs.size() < 1) - continue; - - entry->value += secs[0]->GetStart(); - } - else + // Get the section who contains the adjustedSectionAddr + // We avoid using GetSectionAt() here as when the list of sections grows large calling this in an + // inner loop can be very slow. + for (const auto& section : allSections) + { + if (adjustedSectionAddr >= section->GetStart() && + adjustedSectionAddr < section->GetEnd()) + { + entry->value += section->GetStart(); + break; + } + } + } else entry->value += imageBaseAdjustment; if (entry->section == ELF_SHN_UNDEF) |
