@@ -1031,6 +1031,7 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
10311031
10321032 std::vector<uint8_t > ph_bytes;
10331033 ph_bytes.resize (elf_header.e_phentsize );
1034+ lldb::offset_t load_bias = 0 ;
10341035 for (unsigned int i = 0 ; i < elf_header.e_phnum ; ++i) {
10351036 byte_read = ReadMemory (ph_addr + i * elf_header.e_phentsize ,
10361037 ph_bytes.data (), elf_header.e_phentsize , error);
@@ -1041,6 +1042,10 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
10411042 offset = 0 ;
10421043 elf::ELFProgramHeader program_header;
10431044 program_header.Parse (program_header_data, &offset);
1045+ // Find the load bias of the main executable.
1046+ if (program_header.p_type == llvm::ELF::PT_PHDR) {
1047+ load_bias = address;
1048+ }
10441049 if (program_header.p_type != llvm::ELF::PT_NOTE)
10451050 continue ;
10461051
@@ -1049,7 +1054,7 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
10491054
10501055 // We need to slide the address of the p_vaddr as these values don't get
10511056 // relocated in memory.
1052- const lldb::addr_t vaddr = program_header.p_vaddr + address;
1057+ const lldb::addr_t vaddr = program_header.p_vaddr + address - load_bias ;
10531058 byte_read =
10541059 ReadMemory (vaddr, note_bytes.data (), program_header.p_memsz , error);
10551060 if (byte_read != program_header.p_memsz )
0 commit comments