[PATCH, nios2] Fix GOTOFF relocations

Chung-Lin Tang cltang@codesourcery.com
Thu Feb 20 05:52:00 GMT 2014


This patch fixes GOTOFF relocation calculations for Nios II.
Pre-approved by Sandra and committed to master. Not needed for 2.24 branch.

Thanks,
Chung-Lin

2014-02-20  Chung-Lin Tang  <cltang@codesourcery.com>

	* elf32-nios2.c (nios2_elf32_relocate_section): Fix calculation
	of GOTOFF relocations.
-------------- next part --------------
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index b6a60ff..a7547e8 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -3147,9 +3147,13 @@ nios2_elf32_relocate_section (bfd *output_bfd,
 		  break;
 		}
 
-	      /* Adjust the relocation to be relative to the GOT pointer.  */
-	      relocation -= (sgot->output_section->vma
-			     + sgot->output_offset - got_base);
+	      /* Note that sgot->output_offset is not involved in this
+		 calculation.  We always want the start of .got.  */
+	      relocation -= sgot->output_section->vma;
+
+	      /* Now we adjust the relocation to be relative to the GOT pointer
+		 (the _gp_got symbol), which possibly contains the 0x8000 bias.  */
+	      relocation -= got_base;
 
 	      switch (howto->type)
 		{


More information about the Binutils mailing list