This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Relocation bug


So after this discussion I propose below patch for the 2.13 branch.  Patch
was generated against the 2.13.2.1 release tarball.  The patch doesn't
easily apply to trunc unfortunately ...

  Ralf

2003-02-24  Ralf Baechle  <ralf at linux-mips dot org>

	* elfxx-mips.c (mips_elf_create_dynamic_relocation): Adjust
	relocations against local symbols by the value of the symbol and
	set their symbol index to zero.

diff -urN binutils-2.13.2.1.orig/bfd/elfxx-mips.c binutils-2.13.2.1/bfd/elfxx-mips.c
--- binutils-2.13.2.1.orig/bfd/elfxx-mips.c	Mon Oct 28 15:59:51 2002
+++ binutils-2.13.2.1/bfd/elfxx-mips.c	Tue Feb 25 15:27:51 2003
@@ -359,7 +359,7 @@
 static boolean mips_elf_create_dynamic_relocation
   PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Rela *,
 	   struct mips_elf_link_hash_entry *, asection *,
-	   bfd_vma, bfd_vma *, asection *));
+	   bfd_vma, bfd_vma *, asection *, boolean local_p));
 static INLINE int elf_mips_isa PARAMS ((flagword));
 static INLINE char* elf_mips_abi_name PARAMS ((bfd *));
 static void mips_elf_irix6_finish_dynamic_symbol
@@ -2355,7 +2355,8 @@
 						   sec,
 						   symbol,
 						   &value,
-						   input_section))
+						   input_section,
+						   local_p))
 	    return bfd_reloc_undefined;
 	}
       else
@@ -2817,7 +2818,7 @@
 
 static boolean
 mips_elf_create_dynamic_relocation (output_bfd, info, rel, h, sec,
-				    symbol, addendp, input_section)
+				    symbol, addendp, input_section, local_p)
      bfd *output_bfd;
      struct bfd_link_info *info;
      const Elf_Internal_Rela *rel;
@@ -2826,6 +2827,7 @@
      bfd_vma symbol;
      bfd_vma *addendp;
      asection *input_section;
+     boolean local_p;
 {
   Elf_Internal_Rel outrel[3];
   boolean skip;
@@ -2928,16 +2930,15 @@
 	  symbol = sec->output_section->vma;
 	}
 
-      /* If the relocation was previously an absolute relocation and
-	 this symbol will not be referred to by the relocation, we must
-	 adjust it by the value we give it in the dynamic symbol table.
-	 Otherwise leave the job up to the dynamic linker.  */
-      if (!indx && r_type != R_MIPS_REL32)
+     /* If the relocation is against a local symbol and was previously an
+	absolute relocation, we must adjust it by the value of the symbol.  */
+      if (local_p && r_type != R_MIPS_REL32)
 	*addendp += symbol;
 
       /* The relocation is always an REL32 relocation because we don't
 	 know where the shared library will wind up at load-time.  */
-      outrel[0].r_info = ELF_R_INFO (output_bfd, (unsigned long) indx,
+      outrel[0].r_info = ELF_R_INFO (output_bfd,
+				     local_p ? 0UL : (unsigned long) indx,
 				     R_MIPS_REL32);
       outrel[1].r_info = ELF_R_INFO (output_bfd, (unsigned long) 0,
 				     R_MIPS_NONE);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]