- if (dst->sh_type != SHT_NOBITS
- && dst->sh_size > bfd_get_file_size (abfd))
- _bfd_error_handler
- (_("warning: %pB has a corrupt section with a size (%" BFD_VMA_FMT "x) larger than the file size"),
- abfd, dst->sh_size);
+ if (dst->sh_type != SHT_NOBITS)
+ {
+ ufile_ptr filesize = bfd_get_file_size (abfd);
+
+ if (filesize != 0 && dst->sh_size > filesize)
+ _bfd_error_handler
+ (_("warning: %pB has a corrupt section with a size (%"
+ BFD_VMA_FMT "x) larger than the file size"),
+ abfd, dst->sh_size);
+ }