@@ -1031,6 +1031,7 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
1031
1031
1032
1032
std::vector<uint8_t > ph_bytes;
1033
1033
ph_bytes.resize (elf_header.e_phentsize );
1034
+ lldb::offset_t load_bias = 0 ;
1034
1035
for (unsigned int i = 0 ; i < elf_header.e_phnum ; ++i) {
1035
1036
byte_read = ReadMemory (ph_addr + i * elf_header.e_phentsize ,
1036
1037
ph_bytes.data (), elf_header.e_phentsize , error);
@@ -1041,6 +1042,10 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
1041
1042
offset = 0 ;
1042
1043
elf::ELFProgramHeader program_header;
1043
1044
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
+ }
1044
1049
if (program_header.p_type != llvm::ELF::PT_NOTE)
1045
1050
continue ;
1046
1051
@@ -1049,7 +1054,7 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
1049
1054
1050
1055
// We need to slide the address of the p_vaddr as these values don't get
1051
1056
// 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 ;
1053
1058
byte_read =
1054
1059
ReadMemory (vaddr, note_bytes.data (), program_header.p_memsz , error);
1055
1060
if (byte_read != program_header.p_memsz )
0 commit comments