* elf-hppa.h (elf_hppa_osec_to_segment): New function.
[deliverable/binutils-gdb.git] / bfd / elf32-hppa.c
index 20a2f8093b231636c7f335dbcd42bcb95af06832..6fbcd646ecd46443b7746ad94df71e257391c42f 100644 (file)
@@ -3256,7 +3256,7 @@ elf32_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
 /* Record the lowest address for the data and text segments.  */
 
 static void
-hppa_record_segment_addr (bfd *abfd ATTRIBUTE_UNUSED,
+hppa_record_segment_addr (bfd *abfd,
                          asection *section,
                          void *data)
 {
@@ -3266,30 +3266,9 @@ hppa_record_segment_addr (bfd *abfd ATTRIBUTE_UNUSED,
 
   if ((section->flags & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
     {
-      bfd_vma value;
-      struct elf_segment_map *m;
-      Elf_Internal_Phdr *p;
-
-      /* Find the segment that contains the output_section for this section.  */
-      for (m = elf_tdata (abfd)->segment_map,
-            p = elf_tdata (abfd)->phdr;
-          m != NULL;
-          m = m->next, p++)
-       {
-         int i;
-
-         for (i = m->count - 1; i >= 0; i--)
-           if (m->sections[i] == section->output_section)
-             break;
-         if (i >= 0)
-           break;
-       }
+      unsigned seg = elf_hppa_osec_to_segment (abfd, section->output_section);
+      bfd_vma value = elf_tdata (abfd)->phdr[seg].p_vaddr;
 
-      if (m == NULL)
-        return;
-
-      value = p->p_vaddr;
-      
       if ((section->flags & SEC_READONLY) != 0)
        {
          if (value < htab->text_segment_base)
This page took 0.024596 seconds and 4 git commands to generate.