aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2005-05-28 22:00:27 +0000
committerDaniel Jacobowitz <drow@false.org>2005-05-28 22:00:27 +0000
commit3133ddbf1df21d48dc35cc6917d395da0add78c7 (patch)
tree01f28dc19bb3098ea2bc8a564914b29c60b6c916
parent01e94249b651dfe388b015d54911c35392ef1f0b (diff)
downloadgdb-3133ddbf1df21d48dc35cc6917d395da0add78c7.zip
gdb-3133ddbf1df21d48dc35cc6917d395da0add78c7.tar.gz
gdb-3133ddbf1df21d48dc35cc6917d395da0add78c7.tar.bz2
2005-05-28 David Daney <ddaney@avtrex.com>
* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Move calculation of DT_RELSZ to occur after all dynamic relocations are created.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elfxx-mips.c61
2 files changed, 55 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 32f83dc..86ae224 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2005-05-28 David Daney <ddaney@avtrex.com>
+
+ * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Move
+ calculation of DT_RELSZ to occur after all dynamic relocations
+ are created.
+
2005-05-28 Eli Zaretskii <eliz@gnu.org>
* configure.in: Add snprintf and vsnprintf to AC_CHECK_DECLS.
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 55d5f75..9bae5d5 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -7696,18 +7696,6 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
dyn.d_un.d_ptr = s->vma;
break;
- case DT_RELSZ:
- /* Reduce DT_RELSZ to account for any relocations we
- decided not to make. This is for the n64 irix rld,
- which doesn't seem to apply any relocations if there
- are trailing null entries. */
- s = mips_elf_rel_dyn_section (dynobj, FALSE);
- dyn.d_un.d_val = (s->reloc_count
- * (ABI_64_P (output_bfd)
- ? sizeof (Elf64_Mips_External_Rel)
- : sizeof (Elf32_External_Rel)));
- break;
-
default:
swap_out_p = FALSE;
break;
@@ -7769,6 +7757,55 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
}
}
+ /* The generation of dynamic relocations for the non-primary gots
+ adds more dynamic relocations. We cannot count them until
+ here. */
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ bfd_byte *b;
+ bfd_boolean swap_out_p;
+
+ BFD_ASSERT (sdyn != NULL);
+
+ for (b = sdyn->contents;
+ b < sdyn->contents + sdyn->size;
+ b += MIPS_ELF_DYN_SIZE (dynobj))
+ {
+ Elf_Internal_Dyn dyn;
+ asection *s;
+
+ /* Read in the current dynamic entry. */
+ (*get_elf_backend_data (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn);
+
+ /* Assume that we're going to modify it and write it out. */
+ swap_out_p = TRUE;
+
+ switch (dyn.d_tag)
+ {
+ case DT_RELSZ:
+ /* Reduce DT_RELSZ to account for any relocations we
+ decided not to make. This is for the n64 irix rld,
+ which doesn't seem to apply any relocations if there
+ are trailing null entries. */
+ s = mips_elf_rel_dyn_section (dynobj, FALSE);
+ dyn.d_un.d_val = (s->reloc_count
+ * (ABI_64_P (output_bfd)
+ ? sizeof (Elf64_Mips_External_Rel)
+ : sizeof (Elf32_External_Rel)));
+ break;
+
+ default:
+ swap_out_p = FALSE;
+ break;
+ }
+
+ if (swap_out_p)
+ (*get_elf_backend_data (dynobj)->s->swap_dyn_out)
+ (dynobj, &dyn, b);
+ }
+ }
+
{
asection *s;
Elf32_compact_rel cpt;