Revert change to compress.c
PR ld/12451
* elfcode.h (elf_checksum_contents): Read in the section's
- contents if they are not already available.
+ contents if they are not already available, and the section
+ actually has some contents.
+
* compress.c (bfd_get_full_section_contents): Use zmalloc to
allocate the buffers so that excess bytes are guaranteed to be
zero.
case COMPRESS_SECTION_NONE:
if (p == NULL)
{
- p = (bfd_byte *) bfd_zmalloc (sz);
+ p = (bfd_byte *) bfd_malloc (sz);
if (p == NULL)
return FALSE;
}
if (!ret)
goto fail_compressed;
- uncompressed_buffer = (bfd_byte *) bfd_zmalloc (uncompressed_size);
+ uncompressed_buffer = (bfd_byte *) bfd_malloc (uncompressed_size);
if (uncompressed_buffer == NULL)
goto fail_compressed;
(*process) (&x_shdr, sizeof x_shdr, arg);
/* PR ld/12451:
- Process the section's contents; reading them in if necessary. */
+ Process the section's contents, if it has some. Read them in if necessary. */
if (i_shdr.contents)
(*process) (i_shdr.contents, i_shdr.sh_size, arg);
- else
+ else if (i_shdr.sh_type != SHT_NOBITS)
{
asection *sec;