hack gdb to relocate sections properly

This commit is contained in:
Wolfgang Thaller 2021-04-20 01:04:40 +02:00
parent 4912a44e49
commit ba04456f23

View File

@ -285,6 +285,12 @@ init_objfile_sect_indices (struct objfile *objfile)
sect = bfd_get_section_by_name (objfile->obfd, ".text");
if (sect)
objfile->sect_index_text = sect->index;
else
{
sect = bfd_get_section_by_name (objfile->obfd, ".code2");
if (sect)
objfile->sect_index_text = sect->index;
}
sect = bfd_get_section_by_name (objfile->obfd, ".data");
if (sect)
@ -705,6 +711,21 @@ default_symfile_offsets (struct objfile *objfile,
}
}
}
else
{
bfd *abfd = objfile->obfd;
section_offsets &offsets = objfile->section_offsets;
asection *cur_sec;
for (cur_sec = abfd->sections; cur_sec != NULL;
cur_sec = cur_sec->next)
{
if ((bfd_section_flags (cur_sec) & SEC_ALLOC) == 0)
continue;
uint32_t vma = cur_sec->vma;
offsets[cur_sec->index] -= vma;
}
}
/* Remember the bfd indexes for the .text, .data, .bss and
.rodata sections. */