From 239b426b11425c4bd6b36aa7fd92a01e74fd42cb Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 26 Nov 2019 14:06:12 +0000 Subject: Fix comparison operations in SH code that trigger warning in clang. * elf32-sh.c (sh_elf_reloc): Use a signed_vma when checking for a negative relocated value. * coff-sh.c (sh_reloc): Likewise. --- bfd/ChangeLog | 6 ++++++ bfd/coff-sh.c | 2 +- bfd/elf32-sh.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9789016..515a127 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2019-11-26 Nick Clifton + + * elf32-sh.c (sh_elf_reloc): Use a signed_vma when checking for a + negative relocated value. + * coff-sh.c (sh_reloc): Likewise. + 2019-11-25 Alan Modra * archures.c (bfd_octets_per_byte): Tail call diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index 4b6b0de..1077a20 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -632,7 +632,7 @@ sh_reloc (bfd * abfd, sym_value -= 0x1000; insn = (insn & 0xf000) | (sym_value & 0xfff); bfd_put_16 (abfd, (bfd_vma) insn, hit_data); - if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000) + if ((bfd_signed_vma) sym_value < -0x1000 || sym_value >= 0x1000) return bfd_reloc_overflow; break; default: diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 8aa49b0..863e2e1 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -288,7 +288,7 @@ sh_elf_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol_in, sym_value -= 0x1000; insn = (insn & 0xf000) | (sym_value & 0xfff); bfd_put_16 (abfd, (bfd_vma) insn, hit_data); - if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000) + if ((bfd_signed_vma) sym_value < -0x1000 || sym_value >= 0x1000) return bfd_reloc_overflow; break; default: -- cgit v1.1