Use ELF_SECTION_IN_SEGMENT to map segments
authorAlan Hayward <alan.hayward@arm.com>
Mon, 4 Jun 2018 16:21:04 +0000 (17:21 +0100)
committerAlan Hayward <alan.hayward@arm.com>
Mon, 4 Jun 2018 16:23:07 +0000 (17:23 +0100)
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.

gdb/ChangeLog
gdb/elfread.c

index 330dc18db66aa2cbd9fd21ef152dfc89ac49bf28..d0c43027d6e45278723cfdad1c0ef67a56e39bf0 100644 (file)
        (cpname_state::d_unary, cpname_state::d_binary): Now methods.
        (%union): Move earlier.
 
+2018-06-04  Alan Hayward  <alan.hayward@arm.com>
+
+       * elfread.c (elf_symfile_segments): Use ELF_SECTION_IN_SEGMENT.
+
 2018-06-04  Alan Hayward  <alan.hayward@arm.com>
 
        * aarch64-tdep.c (aarch64_pseudo_read_value_1): New helper func.
index b4b4a1b24c05a36f29aceebcb68e08c5c49812a4..0fe2adbd4d21dd7d44a0bea5fe603176ffb481a6 100644 (file)
@@ -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;