From: Alan Hayward Date: Mon, 4 Jun 2018 16:21:04 +0000 (+0100) Subject: Use ELF_SECTION_IN_SEGMENT to map segments X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=62b74cb8b00ca2b42de30ceff4d2f1552b77a10d;p=binutils-gdb.git Use ELF_SECTION_IN_SEGMENT to map segments The macro ELF_SECTION_IN_SEGMENT should be used when calculating if a section maps to a segment. gdb/ * elfread.c (elf_symfile_segments): Use ELF_SECTION_IN_SEGMENT. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 330dc18db66..d0c43027d6e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -14,6 +14,10 @@ (cpname_state::d_unary, cpname_state::d_binary): Now methods. (%union): Move earlier. +2018-06-04 Alan Hayward + + * elfread.c (elf_symfile_segments): Use ELF_SECTION_IN_SEGMENT. + 2018-06-04 Alan Hayward * aarch64-tdep.c (aarch64_pseudo_read_value_1): New helper func. diff --git a/gdb/elfread.c b/gdb/elfread.c index b4b4a1b24c0..0fe2adbd4d2 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -120,17 +120,14 @@ elf_symfile_segments (bfd *abfd) for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next) { int j; - CORE_ADDR vma; if ((bfd_get_section_flags (abfd, sect) & SEC_ALLOC) == 0) continue; - vma = bfd_get_section_vma (abfd, sect); + Elf_Internal_Shdr *this_hdr = &elf_section_data (sect)->this_hdr; for (j = 0; j < num_segments; j++) - if (segments[j]->p_memsz > 0 - && vma >= segments[j]->p_vaddr - && (vma - segments[j]->p_vaddr) < segments[j]->p_memsz) + if (ELF_SECTION_IN_SEGMENT (this_hdr, segments[j])) { data->segment_info[i] = j + 1; break;