diff options
author | Ulf Carlsson <ulfc@engr.sgi.com> | 2000-07-09 13:48:21 +0000 |
---|---|---|
committer | Ulf Carlsson <ulfc@engr.sgi.com> | 2000-07-09 13:48:21 +0000 |
commit | f3e704f4ae41c65bfcb911e88bbeaf6523eb4129 (patch) | |
tree | b5babfdcdf25c3aaf734e8926597e7b5a4e831a6 | |
parent | 7ea05e670dbad47a2fdf7144794dab21dbe30d6f (diff) | |
download | gdb-f3e704f4ae41c65bfcb911e88bbeaf6523eb4129.tar.gz |
2000-07-09 Koundinya K <kk@ddeorg.soft.net>
* 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.
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf32-mips.c | 42 |
2 files changed, 49 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 805a3d79ba7..c1ebe2a6b9b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2000-07-09 Koundinya K <kk@ddeorg.soft.net> + + * 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 <alan@linuxcare.com.au> * elf64-hppa.c (elf64_hppa_dyn_hash_table_init): Add diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 39b9ae233fe..a0512acc158 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)); |