@@ -2808,18 +2808,24 @@ std::vector<Ref<Symbol>> SharedCache::ParseExportTrie(std::shared_ptr<MMappedFil
28082808}
28092809
28102810
2811- std::vector<std::pair<uint64_t , std::pair<BNSymbolType, std::string>>> SharedCache::GetExportListForHeader (SharedCacheMachOHeader header, std::function<std::shared_ptr<MMappedFileAccessor>()> provideLinkeditFile)
2811+ std::vector<std::pair<uint64_t , std::pair<BNSymbolType, std::string>>> SharedCache::GetExportListForHeader (SharedCacheMachOHeader header, std::function<std::shared_ptr<MMappedFileAccessor>()> provideLinkeditFile, bool* didModifyExportList )
28122812{
28132813 if (auto it = m_state->exportInfos .find (header.textBase ); it != m_state->exportInfos .end ())
28142814 {
2815+ if (didModifyExportList)
2816+ *didModifyExportList = false ;
28152817 return it->second ;
28162818 }
28172819 else
28182820 {
28192821 // TODO does this have to be a functor? can't we just pass the accessor? if not, why?
28202822 std::shared_ptr<MMappedFileAccessor> linkeditFile = provideLinkeditFile ();
28212823 if (!linkeditFile)
2824+ {
2825+ if (didModifyExportList)
2826+ *didModifyExportList = false ;
28222827 return std::vector<std::pair<uint64_t , std::pair<BNSymbolType, std::string>>>();
2828+ }
28232829
28242830 auto exportList = SharedCache::ParseExportTrie (linkeditFile, header);
28252831 std::vector<std::pair<uint64_t , std::pair<BNSymbolType, std::string>>> exportMapping (exportList.size ());
@@ -2828,6 +2834,8 @@ std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> SharedCac
28282834 exportMapping.push_back ({sym->GetAddress (), {sym->GetType (), sym->GetRawName ()}});
28292835 }
28302836 m_state->exportInfos [header.textBase ] = exportMapping;
2837+ if (didModifyExportList)
2838+ *didModifyExportList = true ;
28312839 return exportMapping;
28322840 }
28332841}
@@ -2858,15 +2866,14 @@ std::vector<std::pair<std::string, Ref<Symbol>>> SharedCache::LoadAllSymbolsAndW
28582866 auto exportList = GetExportListForHeader (*header, [&]() {
28592867 try {
28602868 auto mapping = MMappedFileAccessor::Open (m_dscView, m_dscView->GetFile ()->GetSessionId (), header->exportTriePath )->lock ();
2861- doSave = true ;
28622869 return mapping;
28632870 }
28642871 catch (...)
28652872 {
28662873 m_logger->LogWarn (" Serious Error: Failed to open export trie %s for %s" , header->exportTriePath .c_str (), header->installName .c_str ());
28672874 return std::shared_ptr<MMappedFileAccessor>(nullptr );
28682875 }
2869- });
2876+ }, &doSave );
28702877 for (const auto & sym : exportList)
28712878 {
28722879 symbols.push_back ({img.installName , new Symbol (sym.second .first , sym.second .second , sym.first )});
0 commit comments