diff options
| author | Josh Ferrell <josh@vector35.com> | 2024-05-29 12:13:14 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2024-05-29 12:14:20 -0400 |
| commit | f9da871f6bf0f62dbe4cf406e8192f69e6972938 (patch) | |
| tree | f1250d61f11b7f904811dc108c4b289a85e36cc7 /view | |
| parent | f6e5d78d2b3a92a9e793092f31ed8a81deb39751 (diff) | |
Improve load performance of Mach-Os with relocations and many symbols
Diffstat (limited to 'view')
| -rw-r--r-- | view/macho/machoview.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/view/macho/machoview.cpp b/view/macho/machoview.cpp index 5f3aa041..c01acadd 100644 --- a/view/macho/machoview.cpp +++ b/view/macho/machoview.cpp @@ -2031,13 +2031,25 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_ if (relocationHandler->GetRelocationInfo(this, m_arch, infoList)) { + unordered_map<string, vector<Ref<Symbol>>> symbolCache; for (auto& reloc: infoList) { if (reloc.symbolIndex >= m_symbols.size()) continue; // retrieve first symbol that is not a symbol relocation - auto symbols = GetSymbolsByName(m_symbols[reloc.symbolIndex]); + vector<Ref<Symbol>> symbols; + auto symName = m_symbols[reloc.symbolIndex]; + if (auto itr = symbolCache.find(symName); itr != symbolCache.end()) + { + symbols = itr->second; + } + else + { + symbols = GetSymbolsByName(symName); + symbolCache[symName] = symbols; + } + for (const auto& symbol : symbols) { if (symbol->GetAddress() == reloc.address) |
