PR24392, Clang warning Wtautological-constant-out-of-range-compare

PR 24392
	* configure.ac: Invoke AC_CHECK_SIZEOF(int).
	* configure: Regenerate.
	* coffgen.c (coff_get_reloc_upper_bound): Replace gcc diagnostic
	workaround with SIZEOF_LONG vs. SIZEOF_INT check.
	* elf.c (_bfd_elf_get_reloc_upper_bound): Likewise.
	* elf64-sparc.c (elf64_sparc_get_reloc_upper_bound): Likewise.
	* mach-o.c (bfd_mach_o_get_reloc_upper_bound): Likewise.
This commit is contained in:
Alan Modra 2019-03-28 16:53:32 +10:30
parent 96a86c01d1
commit 242a115951
7 changed files with 53 additions and 29 deletions

View File

@ -1,3 +1,14 @@
2019-03-28 Alan Modra <amodra@gmail.com>
PR 24392
* configure.ac: Invoke AC_CHECK_SIZEOF(int).
* configure: Regenerate.
* coffgen.c (coff_get_reloc_upper_bound): Replace gcc diagnostic
workaround with SIZEOF_LONG vs. SIZEOF_INT check.
* elf.c (_bfd_elf_get_reloc_upper_bound): Likewise.
* elf64-sparc.c (elf64_sparc_get_reloc_upper_bound): Likewise.
* mach-o.c (bfd_mach_o_get_reloc_upper_bound): Likewise.
2019-03-21 Jim Wilson <jimw@sifive.com>
PR 24365

View File

@ -2007,10 +2007,6 @@ coff_get_normalized_symtab (bfd *abfd)
return internal;
}
#if GCC_VERSION >= 4003
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif
long
coff_get_reloc_upper_bound (bfd *abfd, sec_ptr asect)
{
@ -2019,16 +2015,15 @@ coff_get_reloc_upper_bound (bfd *abfd, sec_ptr asect)
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
#if SIZEOF_LONG == SIZEOF_INT
if (asect->reloc_count >= LONG_MAX / sizeof (arelent *))
{
bfd_set_error (bfd_error_file_too_big);
return -1;
}
#endif
return (asect->reloc_count + 1) * sizeof (arelent *);
}
#if GCC_VERSION >= 4003
# pragma GCC diagnostic pop
#endif
asymbol *
coff_make_empty_symbol (bfd *abfd)

33
bfd/configure vendored
View File

@ -13367,6 +13367,39 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
$as_echo_n "checking size of int... " >&6; }
if ${ac_cv_sizeof_int+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then :
else
if test "$ac_cv_type_int" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (int)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_int=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
$as_echo "$ac_cv_sizeof_int" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_INT $ac_cv_sizeof_int
_ACEOF
if test "x${ac_cv_sizeof_void_p}" = "x8"; then
host64=true

View File

@ -189,6 +189,7 @@ AC_TYPE_LONG_DOUBLE
AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
if test "x${ac_cv_sizeof_void_p}" = "x8"; then
host64=true

View File

@ -8268,25 +8268,19 @@ _bfd_elf_get_dynamic_symtab_upper_bound (bfd *abfd)
return symtab_size;
}
#if GCC_VERSION >= 4003
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif
long
_bfd_elf_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED,
sec_ptr asect)
{
#if SIZEOF_LONG == SIZEOF_INT
if (asect->reloc_count >= LONG_MAX / sizeof (arelent *))
{
bfd_set_error (bfd_error_file_too_big);
return -1;
}
#endif
return (asect->reloc_count + 1) * sizeof (arelent *);
}
#if GCC_VERSION >= 4003
# pragma GCC diagnostic pop
#endif
/* Canonicalize the relocs. */

View File

@ -34,23 +34,18 @@
section can represent up to two relocs, we must tell the user to allocate
more space. */
#if GCC_VERSION >= 4003
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif
static long
elf64_sparc_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
{
#if SIZEOF_LONG == SIZEOF_INT
if (sec->reloc_count >= LONG_MAX / 2 / sizeof (arelent *))
{
bfd_set_error (bfd_error_file_too_big);
return -1;
}
#endif
return (sec->reloc_count * 2 + 1) * sizeof (arelent *);
}
#if GCC_VERSION >= 4003
# pragma GCC diagnostic pop
#endif
static long
elf64_sparc_get_dynamic_reloc_upper_bound (bfd *abfd)

View File

@ -1417,24 +1417,19 @@ bfd_mach_o_write_dyld_info (bfd *abfd, bfd_mach_o_load_command *command)
return TRUE;
}
#if GCC_VERSION >= 4003
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif
long
bfd_mach_o_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED,
asection *asect)
{
#if SIZEOF_LONG == SIZEOF_INT
if (asect->reloc_count >= LONG_MAX / sizeof (arelent *))
{
bfd_set_error (bfd_error_file_too_big);
return -1;
}
#endif
return (asect->reloc_count + 1) * sizeof (arelent *);
}
#if GCC_VERSION >= 4003
# pragma GCC diagnostic pop
#endif
/* In addition to the need to byte-swap the symbol number, the bit positions
of the fields in the relocation information vary per target endian-ness. */