aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Carlsson <ulfc@engr.sgi.com>2000-07-09 13:48:21 +0000
committerUlf Carlsson <ulfc@engr.sgi.com>2000-07-09 13:48:21 +0000
commitadb76a3e5c74975c5d8834c1192d6631499c7ae2 (patch)
tree65c8f5c0f497a85bfb4efb2ef5a692566258e6ee
parent958d649baf8cacfc73b80d4a753a9c8f4677bb0f (diff)
downloadgdb-adb76a3e5c74975c5d8834c1192d6631499c7ae2.zip
gdb-adb76a3e5c74975c5d8834c1192d6631499c7ae2.tar.gz
gdb-adb76a3e5c74975c5d8834c1192d6631499c7ae2.tar.bz2
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/ChangeLog7
-rw-r--r--bfd/elf32-mips.c42
2 files changed, 49 insertions, 0 deletions
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 <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 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));