@@ -935,6 +935,16 @@ lldb_private::Address ObjectFileELF::GetEntryPointAddress() {
935
935
}
936
936
937
937
Address ObjectFileELF::GetBaseAddress () {
938
+ if (GetType () == ObjectFile::eTypeObjectFile) {
939
+ for (SectionHeaderCollIter I = std::next (m_section_headers.begin ());
940
+ I != m_section_headers.end (); ++I) {
941
+ const ELFSectionHeaderInfo &header = *I;
942
+ if (header.sh_flags & SHF_ALLOC)
943
+ return Address (GetSectionList ()->FindSectionByID (SectionIndex (I)), 0 );
944
+ }
945
+ return LLDB_INVALID_ADDRESS;
946
+ }
947
+
938
948
for (const auto &EnumPHdr : llvm::enumerate (ProgramHeaders ())) {
939
949
const ELFProgramHeader &H = EnumPHdr.value ();
940
950
if (H.p_type != PT_LOAD)
@@ -1764,7 +1774,12 @@ class VMAddressProvider {
1764
1774
VMRange GetVMRange (const ELFSectionHeader &H) {
1765
1775
addr_t Address = H.sh_addr ;
1766
1776
addr_t Size = H.sh_flags & SHF_ALLOC ? H.sh_size : 0 ;
1767
- if (ObjectType == ObjectFile::Type::eTypeObjectFile && Segments.empty () && (H.sh_flags & SHF_ALLOC)) {
1777
+
1778
+ // When this is a debug file for relocatable file, the address is all zero
1779
+ // and thus needs to use accumulate method
1780
+ if ((ObjectType == ObjectFile::Type::eTypeObjectFile ||
1781
+ (ObjectType == ObjectFile::Type::eTypeDebugInfo && H.sh_addr == 0 )) &&
1782
+ Segments.empty () && (H.sh_flags & SHF_ALLOC)) {
1768
1783
NextVMAddress =
1769
1784
llvm::alignTo (NextVMAddress, std::max<addr_t >(H.sh_addralign , 1 ));
1770
1785
Address = NextVMAddress;
0 commit comments