bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly

Maciej W. Rozycki macro@ds2.pg.gda.pl
Mon Jun 19 07:55:00 GMT 2000


Hi,

 It looks like there is a problem when bfd has to emit a R_MIPS_REL32
relocation for an ELF executable (not a shared object) and the relocation
is against a versioned symbol.  The generic
_bfd_elf_link_hash_copy_indirect () function does not copy MIPS-specific
relocation data and as a result space for .rel.dyn's contents is not
allocated.  This leads to a segfault when
mips_elf_create_dynamic_relocation () is called. 

 The following patch seems to work for me -- I tested it successfully
linking problematic object files against glibc 2.1.90 and running
resulting binaries on a mipsel-linux system.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

Mon Jun 19 05:09:21 2000  Maciej W. Rozycki <macro@ds2.pg.gda.pl>

	* elf32-mips.c (_bfd_mips_elf_copy_indirect_symbol): New function.
	(elf_backend_copy_indirect_symbol): Map to the new function.
	Fix typos in comments.

diff -u --recursive --new-file binutils.macro/bfd/elf32-mips.c binutils/bfd/elf32-mips.c
--- binutils.macro/bfd/elf32-mips.c	Wed May 24 14:40:42 2000
+++ binutils/bfd/elf32-mips.c	Mon Jun 19 05:09:21 2000
@@ -5581,7 +5581,7 @@
 
 /* Create a rel.dyn relocation for the dynamic linker to resolve.  REL
    is the original relocation, which is now being transformed into a
-   dyanmic relocation.  The ADDENDP is adjusted if necessary; the
+   dynamic relocation.  The ADDENDP is adjusted if necessary; the
    caller should store the result in place of the original addend.  */
 
 static boolean
@@ -5634,7 +5634,7 @@
 	skip = true;
     }
 
-  /* If we've decided to skip this relocation, just output an emtpy
+  /* If we've decided to skip this relocation, just output an empty
      record.  Note that R_MIPS_NONE == 0, so that this call to memset
      is a way of setting R_TYPE to R_MIPS_NONE.  */
   if (skip)
@@ -7750,6 +7750,26 @@
   return true;
 }
 
+/* Copy data from a MIPS ELF indirect symbol to its direct symbol,
+   hiding the old indirect symbol.  Process additional relocation
+   information.  */
+
+void
+_bfd_mips_elf_copy_indirect_symbol (dir, ind)
+     struct elf_link_hash_entry *dir, *ind;
+{
+  struct mips_elf_link_hash_entry *dirmips, *indmips;
+
+  _bfd_elf_link_hash_copy_indirect (dir, ind);
+
+  dirmips = (struct mips_elf_link_hash_entry *) dir;
+  indmips = (struct mips_elf_link_hash_entry *) ind;
+  dirmips->possibly_dynamic_relocs += indmips->possibly_dynamic_relocs;
+  if (dirmips->min_dyn_reloc_index == 0
+      || (indmips->min_dyn_reloc_index != 0
+          && indmips->min_dyn_reloc_index < dirmips->min_dyn_reloc_index))
+    dirmips->min_dyn_reloc_index = indmips->min_dyn_reloc_index;
+}
 
 /* Adjust a symbol defined by a dynamic object and referenced by a
    regular object.  The current definition is in some section of the
@@ -9029,6 +9049,9 @@
 
 #define elf_backend_got_header_size	(4*MIPS_RESERVED_GOTNO)
 #define elf_backend_plt_header_size	0
+
+#define elf_backend_copy_indirect_symbol \
+					_bfd_mips_elf_copy_indirect_symbol
 
 #define bfd_elf32_bfd_is_local_label_name \
 					mips_elf_is_local_label_name



More information about the Binutils mailing list