This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Oh dear. I regret to inform you that commit 'More fixes for bfd_get_section_contents change' might be unfortunate


On Mon, Jun 26, 2017 at 11:34:50PM -0400, gdb-buildbot@sergiodj.net wrote:
> ../../binutils-gdb/bfd/libbfd.c:818:44: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
>        || section->filepos + offset + count > filesz)

The types are file_ptr, file_ptr, bfd_size_type, unsigned file_ptr.
file_ptr is signed, bfd_size_type unsigned.  The target is 32-bit, so
I guess the host is too, making bfd_size_type 32 bits.  It must be
that file_ptr on the host is 64-bit, which is the only way I see the
left hand expression being signed.

	PR binutils/21665
	* libbfd.c (_bfd_generic_get_section_contents): Warning fix.
	(_bfd_generic_get_section_contents_in_window): Likewise.

diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 0776451..0d9de2b 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -815,7 +815,7 @@ _bfd_generic_get_section_contents (bfd *abfd,
   filesz = bfd_get_file_size (abfd);
   if (offset + count < count
       || offset + count > sz
-      || section->filepos + offset + count > filesz)
+      || (ufile_ptr) section->filepos + offset + count > filesz)
     {
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
@@ -873,7 +873,7 @@ _bfd_generic_get_section_contents_in_window
     sz = section->size;
   filesz = bfd_get_file_size (abfd);
   if (offset + count > sz
-      || section->filepos + offset + count > filesz
+      || (ufile_ptr) section->filepos + offset + count > filesz
       || ! bfd_get_file_window (abfd, section->filepos + offset, count, w,
 				TRUE))
     return FALSE;

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]