switch (sec->compress_status)
{
case COMPRESS_SECTION_NONE:
+ /* PR binutils/17512: Avoid malloc or file reading errors due to
+ ridiculous section sizes. But ignore linker created objects
+ with no contents (yet). */
+ if (bfd_get_size (abfd) > 0
+ && sz > (bfd_size_type) bfd_get_size (abfd))
+ return FALSE;
+
if (p == NULL)
{
p = (bfd_byte *) bfd_malloc (sz);