From bceec4b91193a4485f94c1fe56e20bc755674e59 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Tue, 20 May 2014 15:42:23 -0400 Subject: [PATCH] * elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow. --- bfd/ChangeLog | 4 ++++ bfd/elf32-msp430.c | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5d15e645dae..c674220f614 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2014-05-20 DJ Delorie + + * elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow. + 2014-05-20 Alan Modra PR 16952 diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c index c2d168c50d9..2f55c538ddc 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; } -- 2.30.2