From: Ulf Carlsson Date: Sun, 9 Jul 2000 13:48:21 +0000 (+0000) Subject: 2000-07-09 Koundinya K X-Git-Tag: newlib-1_9_0~1546 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=adb76a3e5c74975c5d8834c1192d6631499c7ae2;p=external%2Fbinutils.git 2000-07-09 Koundinya K * elf32-mips.c (sort_dynamic_relocs): New Function. (_bfd_mips_elf_finish_dynamic_sections): Call sort_dynamic_relocs via qsort to sort the dynamic relocations in increasing r_symndx value. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 805a3d7..c1ebe2a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2000-07-09 Koundinya K + + * elf32-mips.c (sort_dynamic_relocs): New Function. + (_bfd_mips_elf_finish_dynamic_sections): Call sort_dynamic_relocs + via qsort to sort the dynamic relocations in increasing r_symndx + value. + 2000-07-09 Alan Modra * elf64-hppa.c (elf64_hppa_dyn_hash_table_init): Add diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 39b9ae2..a0512ac 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -195,6 +195,8 @@ static void mips_elf_allocate_dynamic_relocations PARAMS ((bfd *, unsigned int)); static boolean mips_elf_stub_section_p PARAMS ((bfd *, asection *)); +static int sort_dynamic_relocs + PARAMS ((const void *, const void *)); /* The level of IRIX compatibility we're striving for. */ @@ -204,6 +206,9 @@ typedef enum { ict_irix6 } irix_compat_t; +/* This will be used when we sort the dynamic relocation records. */ +static bfd *reldyn_sorting_bfd; + /* Nonzero if ABFD is using the N32 ABI. */ #define ABI_N32_P(abfd) \ @@ -5141,6 +5146,26 @@ _bfd_mips_elf_final_link (abfd, info) return true; } +/* This function is called via qsort() to sort the dynamic relocation + entries by increasing r_symndx value. */ + +static int +sort_dynamic_relocs (arg1,arg2) + const PTR arg1; + const PTR arg2; +{ + const Elf32_External_Rel *ext_reloc1 = (const Elf32_External_Rel *) arg1; + const Elf32_External_Rel *ext_reloc2 = (const Elf32_External_Rel *) arg2; + + Elf_Internal_Rel int_reloc1; + Elf_Internal_Rel int_reloc2; + + bfd_elf32_swap_reloc_in(reldyn_sorting_bfd, ext_reloc1, &int_reloc1); + bfd_elf32_swap_reloc_in(reldyn_sorting_bfd, ext_reloc2, &int_reloc2); + + return (ELF32_R_SYM(int_reloc1.r_info) - ELF32_R_SYM(int_reloc2.r_info)); +} + /* Returns the GOT section for ABFD. */ static asection * @@ -8837,6 +8862,23 @@ _bfd_mips_elf_finish_dynamic_sections (output_bfd, info) } } + /* We need to sort the entries of the dynamic relocation section. */ + + if (!ABI_64_P (output_bfd)) + { + asection *reldyn; + + reldyn = bfd_get_section_by_name (dynobj, + MIPS_ELF_REL_DYN_SECTION_NAME (dynobj)); + if (reldyn != NULL && reldyn->reloc_count > 2) + { + reldyn_sorting_bfd = output_bfd; + qsort ((Elf32_External_Rel *) reldyn->contents + 1, + (size_t) reldyn->reloc_count - 1, + sizeof (Elf32_External_Rel), sort_dynamic_relocs); + } + } + /* Clean up a first relocation in .rel.dyn. */ s = bfd_get_section_by_name (dynobj, MIPS_ELF_REL_DYN_SECTION_NAME (dynobj));