Fix REL handling for MSP430
authorDJ Delorie <dj@redhat.com>
Thu, 25 Jun 2015 21:20:15 +0000 (17:20 -0400)
committerDJ Delorie <dj@redhat.com>
Thu, 25 Jun 2015 21:20:15 +0000 (17:20 -0400)
* elf32-msp430.c (msp430_final_link_relocate): Fix comments.  Fix
REL loads to match RELA stores.

bfd/ChangeLog
bfd/elf32-msp430.c

index 8724de43f1edcd8793a0336a9f5b922a0812c82d..955e9269033afe4e55d6756acbf6bf0de975e25a 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-25  DJ Delorie  <dj@redhat.com>
+
+       * elf32-msp430.c (msp430_final_link_relocate): Fix comments.  Fix
+       REL loads to match RELA stores.
+
 2015-06-25  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf.c (_bfd_elf_compute_section_file_positions): Don't
index edd49f7e4897d7f2b6bcffe0afcedc1ec72974c4..9e6979123f2ebb7900427a7ef5b0af8167eb3f10 100644 (file)
@@ -845,14 +845,14 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
 
       case R_MSP430X_PCR20_EXT_ODST:
-       /* [0,4]+[48,16] = ---F ---- FFFF */
+       /* [0,4]+[48,16] = ---F ---- ---- FFFF */
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
          {
            bfd_vma addend;
            addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
-           addend |= bfd_get_16 (input_bfd, contents+4);
+           addend |= bfd_get_16 (input_bfd, contents + 6);
            srel += addend;
            
          }
@@ -868,14 +868,14 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
 
       case R_MSP430X_ABS20_EXT_SRC:
-       /* [7,4]+[32,16] = -78- FFFF */
+       /* [7,4]+[32,16] = -78- ---- FFFF */
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
          {
            bfd_vma addend;
            addend = (bfd_get_16 (input_bfd, contents) & 0x0780) << 9;
-           addend |= bfd_get_16 (input_bfd, contents+2);
+           addend |= bfd_get_16 (input_bfd, contents + 4);
            srel += addend;
          }
        else
@@ -904,14 +904,14 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
 
       case R_MSP430X_PCR20_EXT_DST:
-       /* [0,4]+[32,16] = ---F FFFF */
+       /* [0,4]+[32,16] = ---F ---- FFFF */
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
          {
            bfd_vma addend;
            addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
-           addend |= bfd_get_16 (input_bfd, contents+2);
+           addend |= bfd_get_16 (input_bfd, contents + 4);
            srel += addend;
          }
        else
@@ -927,14 +927,14 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
 
       case R_MSP430X_PCR20_EXT_SRC:
-       /* [7,4]+32,16] = -78- FFFF */
+       /* [7,4]+[32,16] = -78- ---- FFFF */
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
          {
            bfd_vma addend;
            addend = ((bfd_get_16 (input_bfd, contents) & 0x0780) << 9);
-           addend |= bfd_get_16 (input_bfd, contents+2);
+           addend |= bfd_get_16 (input_bfd, contents + 4);
            srel += addend;;
          }
        else
@@ -961,10 +961,16 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
 
       case R_MSP430X_ABS20_EXT_DST:
+       /* [0,4]+[32,16] = ---F ---- FFFF */
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
-         srel += bfd_get_16 (input_bfd, contents) & 0xf;
+         {
+           bfd_vma addend;
+           addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
+           addend |= bfd_get_16 (input_bfd, contents + 4);
+           srel += addend;
+         }
        else
          srel += rel->r_addend;
        bfd_put_16 (input_bfd, (srel & 0xffff), contents + 4);
@@ -975,14 +981,14 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
 
       case R_MSP430X_ABS20_EXT_ODST:
-       /* [0,4]+[48,16] = ---F ---- FFFF */
+       /* [0,4]+[48,16] = ---F ---- ---- FFFF */
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
          {
            bfd_vma addend;
            addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
-           addend |= bfd_get_16 (input_bfd, contents+4);
+           addend |= bfd_get_16 (input_bfd, contents + 6);
            srel += addend;
          }
        else
@@ -995,7 +1001,7 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
 
       case R_MSP430X_ABS20_ADR_SRC:
-       /* [8,4]+[32,16] = -F-- FFFF */
+       /* [8,4]+[16,16] = -F-- FFFF */
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
@@ -1003,7 +1009,7 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
            bfd_vma addend;
 
            addend = ((bfd_get_16 (input_bfd, contents) & 0xf00) << 8);
-           addend |= bfd_get_16 (input_bfd, contents+2);
+           addend |= bfd_get_16 (input_bfd, contents + 2);
            srel += addend;
          }
        else
@@ -1016,14 +1022,14 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
 
       case R_MSP430X_ABS20_ADR_DST:
-       /* [0,4]+[32,16] = ---F FFFF */
+       /* [0,4]+[16,16] = ---F FFFF */
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
          {
            bfd_vma addend;
            addend = ((bfd_get_16 (input_bfd, contents) & 0xf) << 16);
-           addend |= bfd_get_16 (input_bfd, contents+2);
+           addend |= bfd_get_16 (input_bfd, contents + 2);
            srel += addend;
          }
        else
@@ -1058,14 +1064,14 @@ msp430_final_link_relocate (reloc_howto_type *     howto,
        break;
       
       case R_MSP430X_PCR20_CALL:
-       /* [0,4]+[32,16] = ---F FFFF*/
+       /* [0,4]+[16,16] = ---F FFFF*/
        contents += rel->r_offset;
        srel = (bfd_signed_vma) relocation;
        if (is_rel_reloc)
          {
            bfd_vma addend;
            addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
-           addend |= bfd_get_16 (input_bfd, contents+2);
+           addend |= bfd_get_16 (input_bfd, contents + 2);
            srel += addend;
          }
        else
This page took 0.028917 seconds and 4 git commands to generate.