* elflink.c (bfd_elf_final_link): Move code reading relocs to..
authorAlan Modra <amodra@gmail.com>
Mon, 20 Oct 2008 10:57:33 +0000 (10:57 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 20 Oct 2008 10:57:33 +0000 (10:57 +0000)
* elf32-spu.c (spu_elf_count_relocs): ..here.  Adjust params.
* elf-bfd.h (struct elf_backend_data): Update elf_backend_count_relocs
params.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf32-spu.c
bfd/elflink.c

index 9447166..bd6e909 100644 (file)
@@ -1,5 +1,12 @@
 2008-10-20  Alan Modra  <amodra@bigpond.net.au>
 
+       * elflink.c (bfd_elf_final_link): Move code reading relocs to..
+       * elf32-spu.c (spu_elf_count_relocs): ..here.  Adjust params.
+       * elf-bfd.h (struct elf_backend_data): Update elf_backend_count_relocs
+       params.
+
+2008-10-20  Alan Modra  <amodra@bigpond.net.au>
+
        * elflink.c (bfd_elf_final_link): Use d_ptr rather than d_val
        where Elf_Internal_Dyn holds an address.
 
@@ -10,7 +17,8 @@
 
 2008-10-09  Kai Tietz  <kai.tietz@onevision.com>
 
-       * cofflink.c (_bfd_coff_generic_relocate_section): Dump bfd_vma sized addresses instead of long sized.
+       * cofflink.c (_bfd_coff_generic_relocate_section): Dump bfd_vma
+       sized addresses instead of long sized.
 
 2008-10-09  Alan Modra  <amodra@bigpond.net.au>
 
        BFD_MACH_O_x86_EXCEPTION_STATE.
        (bfd_mach_o_load_command_type): Add
        BFD_MACH_O_LC_SEGMENT_64, BFD_MACH_O_LC_ROUTINES_64,
-       BFD_MACH_O_LC_UUID.     
+       BFD_MACH_O_LC_UUID.
        (BFD_MACH_O_CPU_IS64BIT): Added.
        (bfd_mach_o_cpu_type): Add BFD_MACH_O_CPU_TYPE_POWERPC_64,
        BFD_MACH_O_CPU_TYPE_X86_64.
        (bfd_mach_o_scan_start_address): Ditto.
        (bfd_mach_o_scan): Ditto.
        (bfd_mach_o_lookup_section): Ditto.
-       
+
 2008-08-27  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * elf-hppa.h (elf_hppa_reloc_final_type): Handle R_PARISC_GPREL64,
index 993458e..9615a4a 100644 (file)
@@ -1012,7 +1012,7 @@ struct elf_backend_data
   /* Count relocations.  Not called for relocatable links
      or if all relocs are being preserved in the output.  */
   unsigned int (*elf_backend_count_relocs)
-    (asection *, Elf_Internal_Rela *);
+    (struct bfd_link_info *, asection *);
 
   /* This function, if defined, is called when an NT_PRSTATUS note is found
      in a core file.  */
index 00681b2..708ab24 100644 (file)
@@ -3895,16 +3895,27 @@ spu_elf_final_link (bfd *output_bfd, struct bfd_link_info *info)
    that need to be emitted.  */
 
 static unsigned int
-spu_elf_count_relocs (asection *sec, Elf_Internal_Rela *relocs)
+spu_elf_count_relocs (struct bfd_link_info *info, asection *sec)
 {
+  Elf_Internal_Rela *relocs;
   unsigned int count = 0;
-  Elf_Internal_Rela *relend = relocs + sec->reloc_count;
 
-  for (; relocs < relend; relocs++)
+  relocs = _bfd_elf_link_read_relocs (sec->owner, sec, NULL, NULL,
+                                     info->keep_memory);
+  if (relocs != NULL)
     {
-      int r_type = ELF32_R_TYPE (relocs->r_info);
-      if (r_type == R_SPU_PPU32 || r_type == R_SPU_PPU64)
-       ++count;
+      Elf_Internal_Rela *rel;
+      Elf_Internal_Rela *relend = relocs + sec->reloc_count;
+
+      for (rel = relocs; rel < relend; rel++)
+       {
+         int r_type = ELF32_R_TYPE (rel->r_info);
+         if (r_type == R_SPU_PPU32 || r_type == R_SPU_PPU64)
+           ++count;
+       }
+
+      if (elf_section_data (sec)->relocs != relocs)
+       free (relocs);
     }
 
   return count;
index d39ec68..f2015ee 100644 (file)
@@ -10095,22 +10095,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
              if (info->relocatable || info->emitrelocations)
                reloc_count = sec->reloc_count;
              else if (bed->elf_backend_count_relocs)
-               {
-                 Elf_Internal_Rela * relocs;
-
-                 relocs = _bfd_elf_link_read_relocs (sec->owner, sec,
-                                                     NULL, NULL,
-                                                     info->keep_memory);
-
-                 if (relocs != NULL)
-                   {
-                     reloc_count
-                       = (*bed->elf_backend_count_relocs) (sec, relocs);
-
-                     if (elf_section_data (sec)->relocs != relocs)
-                       free (relocs);
-                   }
-               }
+               reloc_count = (*bed->elf_backend_count_relocs) (info, sec);
 
              if (sec->rawsize > max_contents_size)
                max_contents_size = sec->rawsize;