diff options
| author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:31:57 +0900 |
|---|---|---|
| committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:33:27 +0900 |
| commit | df025ebf872052c0761d44a3ef9b65e9675af8a8 (patch) | |
| tree | 9b4e94583e2536546d6606270bcdf846c95e1ba2 /lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp | |
| parent | 4428c9d0b1344179f85a72e183a44796976521e3 (diff) | |
| parent | bdcf47e4bcb92889665825654bb80a8bbe30379e (diff) | |
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/single/loopusers/chapuni/cov/single/loop
Conflicts:
clang/lib/CodeGen/CoverageMappingGen.cpp
Diffstat (limited to 'lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index b3916cc913f7..5f85f99ce7bd 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -1031,6 +1031,8 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) { std::vector<uint8_t> ph_bytes; ph_bytes.resize(elf_header.e_phentsize); + lldb::addr_t base_addr = 0; + bool found_first_load_segment = false; for (unsigned int i = 0; i < elf_header.e_phnum; ++i) { byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, ph_bytes.data(), elf_header.e_phentsize, error); @@ -1041,6 +1043,11 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) { offset = 0; elf::ELFProgramHeader program_header; program_header.Parse(program_header_data, &offset); + if (program_header.p_type == llvm::ELF::PT_LOAD && + !found_first_load_segment) { + base_addr = program_header.p_vaddr; + found_first_load_segment = true; + } if (program_header.p_type != llvm::ELF::PT_NOTE) continue; @@ -1049,7 +1056,7 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) { // We need to slide the address of the p_vaddr as these values don't get // relocated in memory. - const lldb::addr_t vaddr = program_header.p_vaddr + address; + const lldb::addr_t vaddr = program_header.p_vaddr + address - base_addr; byte_read = ReadMemory(vaddr, note_bytes.data(), program_header.p_memsz, error); if (byte_read != program_header.p_memsz) |
