@@ -1854,47 +1854,40 @@ class VMAddressProvider {
18541854};
18551855}
18561856
1857- namespace {
1858- // We have to do this because ELF doesn't have section IDs, and also
1859- // doesn't require section names to be unique. (We use the section index
1860- // for section IDs, but that isn't guaranteed to be the same in separate
1861- // debug images.)
1862- SectionSP FindMatchingSection (const SectionList §ion_list,
1863- SectionSP section) {
1864- SectionSP sect_sp;
1865-
1866- addr_t vm_addr = section->GetFileAddress ();
1867- ConstString name = section->GetName ();
1868- offset_t file_size = section->GetFileSize ();
1869- offset_t byte_size = section->GetByteSize ();
1870- SectionType type = section->GetType ();
1871- bool thread_specific = section->IsThreadSpecific ();
1872- uint32_t permissions = section->GetPermissions ();
1873- uint32_t alignment = section->GetLog2Align ();
1874-
1875- for (auto sect_iter = section_list.begin ();
1876- sect_iter != section_list.end ();
1877- ++sect_iter) {
1878- if ((*sect_iter)->GetName () == name
1879- && (*sect_iter)->GetType () == type
1880- && (*sect_iter)->IsThreadSpecific () == thread_specific
1881- && (*sect_iter)->GetPermissions () == permissions
1882- && (*sect_iter)->GetFileSize () == file_size
1883- && (*sect_iter)->GetByteSize () == byte_size
1884- && (*sect_iter)->GetFileAddress () == vm_addr
1885- && (*sect_iter)->GetLog2Align () == alignment) {
1886- sect_sp = *sect_iter;
1857+ // We have to do this because ELF doesn't have section IDs, and also
1858+ // doesn't require section names to be unique. (We use the section index
1859+ // for section IDs, but that isn't guaranteed to be the same in separate
1860+ // debug images.)
1861+ static SectionSP FindMatchingSection (const SectionList §ion_list,
1862+ SectionSP section) {
1863+ SectionSP sect_sp;
1864+
1865+ addr_t vm_addr = section->GetFileAddress ();
1866+ ConstString name = section->GetName ();
1867+ offset_t file_size = section->GetFileSize ();
1868+ offset_t byte_size = section->GetByteSize ();
1869+ SectionType type = section->GetType ();
1870+ bool thread_specific = section->IsThreadSpecific ();
1871+ uint32_t permissions = section->GetPermissions ();
1872+ uint32_t alignment = section->GetLog2Align ();
1873+
1874+ for (auto sect : section_list) {
1875+ if (sect->GetName () == name && sect->GetType () == type &&
1876+ sect->IsThreadSpecific () == thread_specific &&
1877+ sect->GetPermissions () == permissions &&
1878+ sect->GetFileSize () == file_size && sect->GetByteSize () == byte_size &&
1879+ sect->GetFileAddress () == vm_addr &&
1880+ sect->GetLog2Align () == alignment) {
1881+ sect_sp = sect;
1882+ break ;
1883+ } else {
1884+ sect_sp = FindMatchingSection (sect->GetChildren (), section);
1885+ if (sect_sp)
18871886 break ;
1888- } else {
1889- sect_sp = FindMatchingSection ((*sect_iter)->GetChildren (),
1890- section);
1891- if (sect_sp)
1892- break ;
1893- }
18941887 }
1895-
1896- return sect_sp;
18971888 }
1889+
1890+ return sect_sp;
18981891}
18991892
19001893void ObjectFileELF::CreateSections (SectionList &unified_section_list) {
@@ -2110,7 +2103,11 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
21102103 SectionList *module_section_list =
21112104 module_sp ? module_sp->GetSectionList () : nullptr ;
21122105
2113- // Cache the section mapping
2106+ // We might have debug information in a separate object, in which case
2107+ // we need to map the sections from that object to the sections in the
2108+ // main object during symbol lookup. If we had to compare the sections
2109+ // for every single symbol, that would be expensive, so this map is
2110+ // used to accelerate the process.
21142111 std::unordered_map<lldb::SectionSP, lldb::SectionSP> section_map;
21152112
21162113 unsigned i;
@@ -2318,12 +2315,11 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
23182315 module_section_list != section_list) {
23192316 auto section_it = section_map.find (symbol_section_sp);
23202317 if (section_it == section_map.end ()) {
2321- section_it =
2322- section_map
2323- .emplace (symbol_section_sp,
2324- FindMatchingSection (*module_section_list,
2325- symbol_section_sp))
2326- .first ;
2318+ section_it = section_map
2319+ .emplace (symbol_section_sp,
2320+ FindMatchingSection (*module_section_list,
2321+ symbol_section_sp))
2322+ .first ;
23272323 }
23282324 if (section_it->second )
23292325 symbol_section_sp = section_it->second ;
0 commit comments