diff options
author | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2019-02-07 17:02:24 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2019-02-07 17:02:24 +0100 |
commit | 68a091326f6ac25005c49c4cbda1855080ba1d5f (patch) | |
tree | 3dc784366d5d6a330377cf8e3a79d1d0f76cc6a5 /bfd/elf32-visium.c | |
parent | 0e7e9601bed5600881225e22fd4306f11907858b (diff) | |
download | binutils-gdb-68a091326f6ac25005c49c4cbda1855080ba1d5f.tar.gz |
Visium: fix bogus overflow check on 32-bit hosts
bfd/
* elf32-visium.c (visium_elf_howto_parity_reloc): Minor tweak.
<R_VISIUM_PC16>: Use explicit range test to detect an overflow.
Diffstat (limited to 'bfd/elf32-visium.c')
-rw-r--r-- | bfd/elf32-visium.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/bfd/elf32-visium.c b/bfd/elf32-visium.c index 316eb39a9ca..de81fdca639 100644 --- a/bfd/elf32-visium.c +++ b/bfd/elf32-visium.c @@ -312,7 +312,6 @@ visium_elf_howto_parity_reloc (bfd * input_bfd, arelent *reloc_entry, bfd_vma relocation; bfd_byte *inplace_address; bfd_vma insn; - const bfd_vma signmask = 0xffff8000; /* This part is from bfd_elf_generic_reloc. If we're relocating, and this an external symbol, we don't want @@ -351,19 +350,19 @@ visium_elf_howto_parity_reloc (bfd * input_bfd, arelent *reloc_entry, if (reloc_entry->howto->pc_relative) { - relocation -= input_section->output_section->vma - + input_section->output_offset; + relocation -= input_section->output_section->vma; + relocation -= input_section->output_offset; relocation -= reloc_entry->address; } switch (reloc_entry->howto->type) { case R_VISIUM_PC16: - relocation >>= 2; - if (ret == bfd_reloc_ok && (relocation & signmask) != 0 - && (relocation & signmask) != signmask) + if (ret == bfd_reloc_ok + && ((bfd_signed_vma) relocation < -0x20000 + || (bfd_signed_vma) relocation > 0x1ffff)) ret = bfd_reloc_overflow; - relocation &= 0xffff; + relocation = (relocation >> 2) & 0xffff; break; case R_VISIUM_HI16: case R_VISIUM_HI16_PCREL: |