Index: include/lldb/Core/Section.h =================================================================== --- include/lldb/Core/Section.h +++ include/lldb/Core/Section.h @@ -170,6 +170,7 @@ bool ResolveContainedAddress (lldb::addr_t offset, Address &so_addr) const; + // The offset between the start of the section and the start of the file. lldb::offset_t GetFileOffset () const { @@ -200,8 +201,10 @@ bool SetFileAddress (lldb::addr_t file_addr); + // The offset in virtual memory between this section and its parent. + // If this section does not have a parent, returns the starting virtual memory address of this section. lldb::addr_t - GetOffset () const; + GetMemoryOffset () const; lldb::addr_t Index: source/Core/Section.cpp =================================================================== --- source/Core/Section.cpp +++ source/Core/Section.cpp @@ -128,7 +128,7 @@ } lldb::addr_t -Section::GetOffset () const +Section::GetMemoryOffset () const { // This section has a parent which means m_file_addr is an offset. SectionSP parent_sp (GetParent ()); @@ -148,7 +148,7 @@ { load_base_addr = parent_sp->GetLoadBaseAddress (target); if (load_base_addr != LLDB_INVALID_ADDRESS) - load_base_addr += GetOffset(); + load_base_addr += GetMemoryOffset(); } if (load_base_addr == LLDB_INVALID_ADDRESS) { @@ -167,7 +167,7 @@ { Section* child_section = m_children.GetSectionAtIndex (i).get(); - addr_t child_offset = child_section->GetOffset(); + addr_t child_offset = child_section->GetMemoryOffset(); if (child_offset <= offset && offset - child_offset < child_section->GetByteSize()) return child_section->ResolveContainedAddress (offset - child_offset, so_addr); } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -746,7 +746,16 @@ // See if we memory mapped the DWARF segment? if (m_dwarf_data.GetByteSize()) { - data.SetData(m_dwarf_data, section_sp->GetOffset (), section_sp->GetFileSize()); + // Get the offset of this section from the beginning of the file. + lldb::offset_t offset = section_sp->GetFileOffset(); + SectionSP parent_sp (section_sp->GetParent()); + // If this section has a parent then we need the offset in the file from + // the beginning of the parent section. + if (parent_sp) + { + offset = offset - parent_sp->GetFileOffset(); + } + data.SetData(m_dwarf_data, offset, section_sp->GetFileSize()); } else {