* elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow.
authorDJ Delorie <dj@redhat.com>
Tue, 20 May 2014 19:42:23 +0000 (15:42 -0400)
committerDJ Delorie <dj@redhat.com>
Tue, 20 May 2014 19:42:23 +0000 (15:42 -0400)
bfd/ChangeLog
bfd/elf32-msp430.c

index 5d15e645dae82110cc53cabdb9feab87b1675653..c674220f614ec59633d992ae752d5caca67fba77 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-20  DJ Delorie  <dj@redhat.com>
+
+       * elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow.
+
 2014-05-20  Alan Modra  <amodra@gmail.com>
 
        PR 16952
index c2d168c50d9dd03d3e4c10b54d6f55cad56fbe6d..2f55c538ddc4210609f2a24d1a9466fbfabb1658 100644 (file)
@@ -1582,14 +1582,15 @@ msp430_elf_relax_adjust_locals (bfd * abfd, asection * sec, bfd_vma addr,
   irelend = irel + sec->reloc_count;
   symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
   isym = (Elf_Internal_Sym *) symtab_hdr->contents;
-  
+
   for (;irel < irelend; irel++)
     {
-      int sidx = ELF32_R_SYM(irel->r_info);
+      unsigned int sidx = ELF32_R_SYM(irel->r_info);
       Elf_Internal_Sym *lsym = isym + sidx;
-      
+
       /* Adjust symbols referenced by .sec+0xXX */
-      if (irel->r_addend > addr && irel->r_addend < toaddr 
+      if (irel->r_addend > addr && irel->r_addend < toaddr
+         && sidx < symtab_hdr->sh_info
          && lsym->st_shndx == sec_shndx)
        irel->r_addend -= count;
     }