diff options
Diffstat (limited to 'lldb/source')
4 files changed, 23 insertions, 31 deletions
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index ddc59aea62e..0b5da9e06a3 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -706,6 +706,15 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); + + SectionSP image_sp = std::make_shared<Section>( + module_sp, this, ~user_id_t(0), ConstString(), eSectionTypeContainer, + m_coff_header_opt.image_base, m_coff_header_opt.image_size, + /*file_offset*/ 0, /*file_size*/ 0, m_coff_header_opt.sect_alignment, + /*flags*/ 0); + m_sections_up->AddSection(image_sp); + unified_section_list.AddSection(image_sp); + const uint32_t nsects = m_sect_headers.size(); ModuleSP module_sp(GetModule()); for (uint32_t idx = 0; idx < nsects; ++idx) { @@ -808,20 +817,16 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) { section_type = eSectionTypeData; } - // Use a segment ID of the segment index shifted left by 8 so they - // never conflict with any of the sections. SectionSP section_sp(new Section( - module_sp, // Module to which this section belongs - this, // Object file to which this section belongs - idx + 1, // Section ID is the 1 based segment index shifted right by - // 8 bits as not to collide with any of the 256 section IDs - // that are possible + image_sp, // Parent section + module_sp, // Module to which this section belongs + this, // Object file to which this section belongs + idx + 1, // Section ID is the 1 based section index. const_sect_name, // Name of this section - section_type, // This section is a container of other sections. - m_coff_header_opt.image_base + - m_sect_headers[idx].vmaddr, // File VM address == addresses as - // they are found in the object file - m_sect_headers[idx].vmsize, // VM size in bytes of this section + section_type, + m_sect_headers[idx].vmaddr, // File VM address == addresses as + // they are found in the object file + m_sect_headers[idx].vmsize, // VM size in bytes of this section m_sect_headers[idx] .offset, // Offset to the data for this section in the file m_sect_headers[idx] @@ -829,10 +834,7 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) { m_coff_header_opt.sect_alignment, // Section alignment m_sect_headers[idx].flags)); // Flags for this section - // section_sp->SetIsEncrypted (segment_is_encrypted); - - unified_section_list.AddSection(section_sp); - m_sections_up->AddSection(section_sp); + image_sp->GetChildren().AddSection(std::move(section_sp)); } } } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp index 2b9a56e1ba8..5db7de6f7c7 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp @@ -207,13 +207,7 @@ DWARFExpression lldb_private::npdb::MakeGlobalLocationExpression( SectionList *section_list = module->GetSectionList(); assert(section_list); - // Section indices in PDB are 1-based, but in DWARF they are 0-based, so - // we need to subtract 1. - uint32_t section_idx = section - 1; - if (section_idx >= section_list->GetSize()) - return false; - - auto section_ptr = section_list->GetSectionAtIndex(section_idx); + auto section_ptr = section_list->FindSectionByID(section); if (!section_ptr) return false; diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp index 0026aaeee98..c7cf8b235bf 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp @@ -90,11 +90,9 @@ DWARFExpression ConvertPDBLocationToDWARFExpression( if (!section_list) return DWARFExpression(nullptr); - uint32_t section_idx = symbol.getAddressSection() - 1; - if (section_idx >= section_list->GetSize()) - return DWARFExpression(nullptr); + uint32_t section_id = symbol.getAddressSection(); - auto section = section_list->GetSectionAtIndex(section_idx); + auto section = section_list->FindSectionByID(section_id); if (!section) return DWARFExpression(nullptr); diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 368b15680b3..8d71b1309b1 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1349,11 +1349,9 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) { return; while (auto pub_symbol = results->getNext()) { - auto section_idx = pub_symbol->getAddressSection() - 1; - if (section_idx >= section_list->GetSize()) - continue; + auto section_id = pub_symbol->getAddressSection(); - auto section = section_list->GetSectionAtIndex(section_idx); + auto section = section_list->FindSectionByID(section_id); if (!section) continue; |

