aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-msp430.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2014-05-20 15:42:23 -0400
committerDJ Delorie <dj@redhat.com>2014-05-20 15:42:23 -0400
commitbceec4b91193a4485f94c1fe56e20bc755674e59 (patch)
tree598148413db61273da7376d21146f5e1a5f042b3 /bfd/elf32-msp430.c
parent936d299246c2be32cfc92e0ad824f31d5b8cec73 (diff)
downloadgdb-bceec4b91193a4485f94c1fe56e20bc755674e59.zip
gdb-bceec4b91193a4485f94c1fe56e20bc755674e59.tar.gz
gdb-bceec4b91193a4485f94c1fe56e20bc755674e59.tar.bz2
* elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow.
Diffstat (limited to 'bfd/elf32-msp430.c')
-rw-r--r--bfd/elf32-msp430.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index c2d168c..2f55c53 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -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;
}