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]

Correct elf32-ppc dynamic relocs


I'll commit this after some testing.

	* elf32-ppc.c (ppc_elf_relocate_section): When emitting dynamic
	relocs against a section symbol, subtract the output section symbol
	value.

Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.59
diff -u -p -r1.59 elf32-ppc.c
--- bfd/elf32-ppc.c	12 Dec 2002 10:26:01 -0000	1.59
+++ bfd/elf32-ppc.c	16 Dec 2002 23:43:32 -0000
@@ -3221,11 +3221,10 @@ ppc_elf_relocate_section (output_bfd, in
 		}
 	      else
 		{
+		  outrel.r_addend = relocation + rel->r_addend;
+
 		  if (r_type == R_PPC_ADDR32)
-		    {
-		      outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
-		      outrel.r_addend = relocation + rel->r_addend;
-		    }
+		    outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
 		  else
 		    {
 		      long indx;
@@ -3239,7 +3238,8 @@ ppc_elf_relocate_section (output_bfd, in
 					  == bfd_link_hash_defweak));
 			  sec = h->root.u.def.section;
 			}
-		      if (sec != NULL && bfd_is_abs_section (sec))
+
+		      if (bfd_is_abs_section (sec))
 			indx = 0;
 		      else if (sec == NULL || sec->owner == NULL)
 			{
@@ -3250,7 +3250,13 @@ ppc_elf_relocate_section (output_bfd, in
 			{
 			  asection *osec;
 
+			  /* We are turning this relocation into one
+			     against a section symbol, so subtract out the
+			     output section's address but not the offset
+			     of the input section in the output section.  */
 			  osec = sec->output_section;
+			  outrel.r_addend -= osec->vma;
+
 			  indx = elf_section_data (osec)->dynindx;
 			  BFD_ASSERT (indx > 0);
 #ifdef DEBUG
@@ -3264,7 +3270,6 @@ ppc_elf_relocate_section (output_bfd, in
 			}
 
 		      outrel.r_info = ELF32_R_INFO (indx, r_type);
-		      outrel.r_addend = relocation + rel->r_addend;
 		    }
 		}
 

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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