From: Alan Modra Date: Mon, 20 Oct 2008 10:57:33 +0000 (+0000) Subject: * elflink.c (bfd_elf_final_link): Move code reading relocs to.. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=58217f292890a480df33735fd9292a4173f6b210;p=binutils-gdb.git * 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9447166ea77..bd6e9090334 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2008-10-20 Alan Modra + + * 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 * elflink.c (bfd_elf_final_link): Use d_ptr rather than d_val @@ -10,7 +17,8 @@ 2008-10-09 Kai Tietz - * 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 @@ -191,7 +199,7 @@ 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. @@ -223,7 +231,7 @@ (bfd_mach_o_scan_start_address): Ditto. (bfd_mach_o_scan): Ditto. (bfd_mach_o_lookup_section): Ditto. - + 2008-08-27 John David Anglin * elf-hppa.h (elf_hppa_reloc_final_type): Handle R_PARISC_GPREL64, diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 993458eb530..9615a4a5366 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -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. */ diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index 00681b2b5b9..708ab247ea0 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -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; diff --git a/bfd/elflink.c b/bfd/elflink.c index d39ec685f68..f2015ee6dc2 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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;