diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -503,6 +503,9 @@ return section->GetObjectFile()->ReadSectionData(section, section_offset, dst, dst_len); + if (!section->IsRelocated()) + RelocateSection(section); + if (IsInMemory()) { ProcessSP process_sp(m_process_wp.lock()); if (process_sp) { @@ -514,9 +517,6 @@ dst_len, error); } } else { - if (!section->IsRelocated()) - RelocateSection(section); - const lldb::offset_t section_file_size = section->GetFileSize(); if (section_offset < section_file_size) { const size_t section_bytes_left = section_file_size - section_offset; @@ -547,6 +547,9 @@ if (section->GetObjectFile() != this) return section->GetObjectFile()->ReadSectionData(section, section_data); + if (!section->IsRelocated()) + RelocateSection(section); + if (IsInMemory()) { ProcessSP process_sp(m_process_wp.lock()); if (process_sp) { @@ -563,17 +566,12 @@ } } } - return GetData(section->GetFileOffset(), section->GetFileSize(), - section_data); - } else { - // The object file now contains a full mmap'ed copy of the object file - // data, so just use this - if (!section->IsRelocated()) - RelocateSection(section); - - return GetData(section->GetFileOffset(), section->GetFileSize(), - section_data); } + + // The object file now contains a full mmap'ed copy of the object file + // data, so just use this + return GetData(section->GetFileOffset(), section->GetFileSize(), + section_data); } bool ObjectFile::SplitArchivePathWithObject(llvm::StringRef path_with_object, diff --git a/lldb/test/Shell/Breakpoint/jitbp_elf.test b/lldb/test/Shell/Breakpoint/jitbp_elf.test --- a/lldb/test/Shell/Breakpoint/jitbp_elf.test +++ b/lldb/test/Shell/Breakpoint/jitbp_elf.test @@ -7,5 +7,8 @@ # CHECK: Breakpoint 1: no locations (pending). # CHECK: (lldb) run -jit-kind=mcjit {{.*}}/jitbp_elf.test.tmp.ll # CHECK: Process {{.*}} stopped -# CHECK: JIT(0x{{.*}})`jitbp: +# CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15 +# CHECK: -> 1 int jitbp() { return 0; } +# CHECK: ^ +# CHECK: 2 int main() { return jitbp(); } # CHECK: Process {{.*}} launched: {{.*}}