================
@@ -3664,7 +3730,27 @@ llvm::ArrayRef<ELFProgramHeader>
ObjectFileELF::ProgramHeaders() {
}
DataExtractor ObjectFileELF::GetSegmentData(const ELFProgramHeader &H) {
- return DataExtractor(m_data, H.p_offset, H.p_filesz);
+ // Try and read the program header from our cached m_data which can come from
+ // the file on disk being mmap'ed or from the initial part of the ELF file we
+ // read from memory and cached.
+ DataExtractor data = DataExtractor(m_data, H.p_offset, H.p_filesz);
+ if (data.GetByteSize() == H.p_filesz)
+ return data;
+ if (IsInMemory()) {
+ // We have a ELF file in process memory, read the program header data from
+ // the process.
+ ProcessSP process_sp(m_process_wp.lock());
+ if (process_sp) {
+ const lldb::offset_t base_file_addr = GetBaseAddress().GetFileAddress();
+ // const addr_t data_addr = m_memory_addr + H.p_offset; // Not correct
for
----------------
labath wrote:
It might be less tempting to use p_offset if this were written as
```
addr_t load_bias = m_memory_addr - base_file_addr;
data_addr = h.p_vaddr + load_bias;
```
https://github.com/llvm/llvm-project/pull/101237
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits