Fix comparison operations in SH code that trigger warning in clang.
authorNick Clifton <nickc@redhat.com>
Tue, 26 Nov 2019 14:06:12 +0000 (14:06 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 26 Nov 2019 14:06:12 +0000 (14:06 +0000)
* 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
bfd/coff-sh.c
bfd/elf32-sh.c

index 9789016199fe77bca6526f97f201996be5d6c930..515a127def04e9858ccae39364e40c2c3e4e92ae 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-26  Nick Clifton  <nickc@redhat.com>
+
+       * 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  <amodra@gmail.com>
 
        * archures.c (bfd_octets_per_byte): Tail call
index 4b6b0de5420ac05423aceeaf62f6326c979208be..1077a20e6c2149468d9345ec93ee4ee8b159987c 100644 (file)
@@ -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:
index 8aa49b099c336cbc38ed745a246652e96ec01f12..863e2e1bfc63536dd6f4bb2f07da16f365a5b857 100644 (file)
@@ -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: