2014-02-20 Chung-Lin Tang <cltang@codesourcery.com>
authorChung-Lin Tang <cltang@codesourcery.com>
Thu, 20 Feb 2014 05:40:21 +0000 (21:40 -0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Thu, 20 Feb 2014 05:40:21 +0000 (21:40 -0800)
        * elf32-nios2.c (nios2_elf32_relocate_section): Fix calculation
        of GOTOFF relocations.

bfd/ChangeLog
bfd/elf32-nios2.c

index cbeec9bbd0ba060698f76e151f52810c4836bccc..c5868efcaee31a1adf10815391b3e10fd9ecb3ba 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-20  Chung-Lin Tang  <cltang@codesourcery.com>
+
+       * elf32-nios2.c (nios2_elf32_relocate_section): Fix calculation
+       of GOTOFF relocations.
+
 2014-02-19  Igor Zamyatin  <igor.zamyatin@intel.com>
            H.J. Lu  <hongjiu.lu@intel.com>
 
index b6a60ff96c18997bb3b887b941caa7164362aa17..a7547e8cfb3df5d3d0f6bbf7fd28bdcc77a99c67 100644 (file)
@@ -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)
                {