+2017-06-27  Alan Modra  <amodra@gmail.com>
+
+       PR binutils/21665
+       * libbfd.c (_bfd_generic_get_section_contents): Delete abort.
+       Use unsigned file pointer type, and remove cast.
+       * libbfd.c (_bfd_generic_get_section_contents_in_window): Likewise.
+       Add "count", not "sz".
+
 2017-06-26  Pedro Alves  <palves@redhat.com>
 
        PR binutils/21665
 
                                   bfd_size_type count)
 {
   bfd_size_type sz;
-  file_ptr filesz;
+  ufile_ptr filesz;
   if (count == 0)
     return TRUE;
 
   else
     sz = section->size;
   filesz = bfd_get_file_size (abfd);
-  if (filesz < 0)
-    {
-      /* This should never happen.  */
-      abort ();
-    }
   if (offset + count < count
       || offset + count > sz
-      || (section->filepos + offset + count) > (bfd_size_type) filesz)
+      || section->filepos + offset + count > filesz)
     {
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
 {
 #ifdef USE_MMAP
   bfd_size_type sz;
-  file_ptr filesz;
+  ufile_ptr filesz;
 
   if (count == 0)
     return TRUE;
   else
     sz = section->size;
   filesz = bfd_get_file_size (abfd);
-  if (filesz < 0)
-    {
-      /* This should never happen.  */
-      abort ();
-    }
   if (offset + count > sz
-      || (section->filepos + offset + sz) > (bfd_size_type) filesz
+      || section->filepos + offset + count > filesz
       || ! bfd_get_file_window (abfd, section->filepos + offset, count, w,
                                TRUE))
     return FALSE;