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]

Re: Possible sparc64 relocation bug


Jason, could you test this for NetBSD/sparc64?
I'd also love to hear from any one that can test on Solaris or Linux.

Daniel, what do you think about letting this fix into the 2.13 branch?


On Tue, Nov 05, 2002 at 02:53:47PM +1030, Alan Modra wrote:
> On Mon, Nov 04, 2002 at 07:23:05PM -0800, David O'Brien wrote:
> > Thoughts on the below patch?
> 
> It's correct, but I'd be inclined to move the assignment to
> outrel.r_addend up a little so that you don't need to fiddle with
> "relocation".  Someone might decide later to set "relocate" for
> some reason.
> 
Index: bfd/elf64-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sparc.c,v
retrieving revision 1.60
diff -u -p -r1.60 elf64-sparc.c
--- bfd/elf64-sparc.c	24 Sep 2002 15:54:22 -0000	1.60
+++ bfd/elf64-sparc.c	5 Nov 2002 04:19:52 -0000
@@ -2164,11 +2164,9 @@ sparc64_elf_relocate_section (output_bfd
 		  }
 		else
 		  {
+		    outrel.r_addend = relocation + rel->r_addend;
 		    if (r_type == R_SPARC_64)
-		      {
-			outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
-			outrel.r_addend = relocation + rel->r_addend;
-		      }
+		      outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
 		    else
 		      {
 			long indx;
@@ -2198,6 +2196,13 @@ sparc64_elf_relocate_section (output_bfd
 			    osec = sec->output_section;
 			    indx = elf_section_data (osec)->dynindx;
 
+			    /* 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.  */
+			    outrel.r_addend -= osec->vma;
+
 			    /* FIXME: we really should be able to link non-pic
 			       shared libraries.  */
 			    if (indx == 0)
@@ -2216,7 +2221,6 @@ sparc64_elf_relocate_section (output_bfd
 					  ELF64_R_TYPE_INFO (
 					    ELF64_R_TYPE_DATA (rel->r_info),
 							       r_type));
-			outrel.r_addend = relocation + rel->r_addend;
 		      }
 		  }
 

-- 


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