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.
This commit is contained in:
Nick Clifton 2019-11-26 14:06:12 +00:00
parent 4297119364
commit 239b426b11
3 changed files with 8 additions and 2 deletions

View 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> 2019-11-25 Alan Modra <amodra@gmail.com>
* archures.c (bfd_octets_per_byte): Tail call * archures.c (bfd_octets_per_byte): Tail call

View File

@ -632,7 +632,7 @@ sh_reloc (bfd * abfd,
sym_value -= 0x1000; sym_value -= 0x1000;
insn = (insn & 0xf000) | (sym_value & 0xfff); insn = (insn & 0xf000) | (sym_value & 0xfff);
bfd_put_16 (abfd, (bfd_vma) insn, hit_data); 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; return bfd_reloc_overflow;
break; break;
default: default:

View File

@ -288,7 +288,7 @@ sh_elf_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol_in,
sym_value -= 0x1000; sym_value -= 0x1000;
insn = (insn & 0xf000) | (sym_value & 0xfff); insn = (insn & 0xf000) | (sym_value & 0xfff);
bfd_put_16 (abfd, (bfd_vma) insn, hit_data); 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; return bfd_reloc_overflow;
break; break;
default: default: