@@ -1841,47 +1841,40 @@ class VMAddressProvider {
1841
1841
};
1842
1842
}
1843
1843
1844
- namespace {
1845
- // We have to do this because ELF doesn't have section IDs, and also
1846
- // doesn't require section names to be unique. (We use the section index
1847
- // for section IDs, but that isn't guaranteed to be the same in separate
1848
- // debug images.)
1849
- SectionSP FindMatchingSection (const SectionList §ion_list,
1850
- SectionSP section) {
1851
- SectionSP sect_sp;
1852
-
1853
- addr_t vm_addr = section->GetFileAddress ();
1854
- ConstString name = section->GetName ();
1855
- offset_t file_size = section->GetFileSize ();
1856
- offset_t byte_size = section->GetByteSize ();
1857
- SectionType type = section->GetType ();
1858
- bool thread_specific = section->IsThreadSpecific ();
1859
- uint32_t permissions = section->GetPermissions ();
1860
- uint32_t alignment = section->GetLog2Align ();
1861
-
1862
- for (auto sect_iter = section_list.begin ();
1863
- sect_iter != section_list.end ();
1864
- ++sect_iter) {
1865
- if ((*sect_iter)->GetName () == name
1866
- && (*sect_iter)->GetType () == type
1867
- && (*sect_iter)->IsThreadSpecific () == thread_specific
1868
- && (*sect_iter)->GetPermissions () == permissions
1869
- && (*sect_iter)->GetFileSize () == file_size
1870
- && (*sect_iter)->GetByteSize () == byte_size
1871
- && (*sect_iter)->GetFileAddress () == vm_addr
1872
- && (*sect_iter)->GetLog2Align () == alignment) {
1873
- sect_sp = *sect_iter;
1844
+ // We have to do this because ELF doesn't have section IDs, and also
1845
+ // doesn't require section names to be unique. (We use the section index
1846
+ // for section IDs, but that isn't guaranteed to be the same in separate
1847
+ // debug images.)
1848
+ static SectionSP FindMatchingSection (const SectionList §ion_list,
1849
+ SectionSP section) {
1850
+ SectionSP sect_sp;
1851
+
1852
+ addr_t vm_addr = section->GetFileAddress ();
1853
+ ConstString name = section->GetName ();
1854
+ offset_t file_size = section->GetFileSize ();
1855
+ offset_t byte_size = section->GetByteSize ();
1856
+ SectionType type = section->GetType ();
1857
+ bool thread_specific = section->IsThreadSpecific ();
1858
+ uint32_t permissions = section->GetPermissions ();
1859
+ uint32_t alignment = section->GetLog2Align ();
1860
+
1861
+ for (auto sect : section_list) {
1862
+ if (sect->GetName () == name && sect->GetType () == type &&
1863
+ sect->IsThreadSpecific () == thread_specific &&
1864
+ sect->GetPermissions () == permissions &&
1865
+ sect->GetFileSize () == file_size && sect->GetByteSize () == byte_size &&
1866
+ sect->GetFileAddress () == vm_addr &&
1867
+ sect->GetLog2Align () == alignment) {
1868
+ sect_sp = sect;
1869
+ break ;
1870
+ } else {
1871
+ sect_sp = FindMatchingSection (sect->GetChildren (), section);
1872
+ if (sect_sp)
1874
1873
break ;
1875
- } else {
1876
- sect_sp = FindMatchingSection ((*sect_iter)->GetChildren (),
1877
- section);
1878
- if (sect_sp)
1879
- break ;
1880
- }
1881
1874
}
1882
-
1883
- return sect_sp;
1884
1875
}
1876
+
1877
+ return sect_sp;
1885
1878
}
1886
1879
1887
1880
void ObjectFileELF::CreateSections (SectionList &unified_section_list) {
@@ -2097,7 +2090,11 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
2097
2090
SectionList *module_section_list =
2098
2091
module_sp ? module_sp->GetSectionList () : nullptr ;
2099
2092
2100
- // Cache the section mapping
2093
+ // We might have debug information in a separate object, in which case
2094
+ // we need to map the sections from that object to the sections in the
2095
+ // main object during symbol lookup. If we had to compare the sections
2096
+ // for every single symbol, that would be expensive, so this map is
2097
+ // used to accelerate the process.
2101
2098
std::unordered_map<lldb::SectionSP, lldb::SectionSP> section_map;
2102
2099
2103
2100
unsigned i;
@@ -2305,12 +2302,11 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
2305
2302
module_section_list != section_list) {
2306
2303
auto section_it = section_map.find (symbol_section_sp);
2307
2304
if (section_it == section_map.end ()) {
2308
- section_it =
2309
- section_map
2310
- .emplace (symbol_section_sp,
2311
- FindMatchingSection (*module_section_list,
2312
- symbol_section_sp))
2313
- .first ;
2305
+ section_it = section_map
2306
+ .emplace (symbol_section_sp,
2307
+ FindMatchingSection (*module_section_list,
2308
+ symbol_section_sp))
2309
+ .first ;
2314
2310
}
2315
2311
if (section_it->second )
2316
2312
symbol_section_sp = section_it->second ;
0 commit comments