Fix pc relative relocs.
authorNick Clifton <nickc@redhat.com>
Tue, 8 Dec 1998 15:44:06 +0000 (15:44 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 8 Dec 1998 15:44:06 +0000 (15:44 +0000)
bfd/ChangeLog
bfd/elf32-fr30.c

index 34651c5d7b0a4fac270a506b6c00abc4fe175ef7..0ec75297c23bdf4943166865ca1a0e35b27ad1ba 100644 (file)
@@ -1,3 +1,9 @@
+1998-12-08  Nick Clifton  <nickc@cygnus.com>
+
+       * elf32-fr30.c (fr30_final_link_relocate): Fix PC relative
+       relocations to include offset of 2 included in the insns, and the
+       offset of the relocs within the section.
+
 Wed Dec  2 15:03:59 1998  David Taylor  <taylor@texas.cygnus.com>
 
        The following changes were made by David Taylor
index 0e4171f67629f59c31d091458f83f27a9082c700..17bcc9879d0776308b885c7219fe7b1ed17f8d70 100644 (file)
@@ -383,8 +383,10 @@ fr30_final_link_relocate (howto, input_bfd, input_section, contents, rel, reloca
 
     case R_FR30_9_PCREL:
       contents   += rel->r_offset + 1;
-      relocation += rel->r_addend;
       srel = (bfd_signed_vma) relocation;
+      srel += rel->r_addend;
+      srel -= rel->r_offset;
+      srel -= 2;  /* Branch instructions add 2 to the PC... */
       srel -= (input_section->output_section->vma +
                     input_section->output_offset);
       
@@ -392,14 +394,16 @@ fr30_final_link_relocate (howto, input_bfd, input_section, contents, rel, reloca
        return bfd_reloc_outofrange;
       if (srel > ((1 << 8) - 1) || (srel < - (1 << 8)))
        return bfd_reloc_overflow;
-      
+
       bfd_put_8 (input_bfd, srel >> 1, contents);
       break;
 
     case R_FR30_12_PCREL:
       contents   += rel->r_offset;
-      relocation += rel->r_addend;
       srel = (bfd_signed_vma) relocation;
+      srel += rel->r_addend;
+      srel -= rel->r_offset;
+      srel -= 2; /* Branch instructions add 2 to the PC... */
       srel -= (input_section->output_section->vma +
                     input_section->output_offset);