When computing checksums, skip the contents of sections with the SHT_NOBITS type.
authorNick Clifton <nickc@redhat.com>
Wed, 14 Dec 2011 16:12:13 +0000 (16:12 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 14 Dec 2011 16:12:13 +0000 (16:12 +0000)
Revert change to compress.c

bfd/ChangeLog
bfd/compress.c
bfd/elfcode.h

index 96ab8798d12a54ac4bbd913741f8364c067e442b..9e995a1f72d80113503fa43117fb49a59dddebea 100644 (file)
@@ -2,7 +2,9 @@
 
        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.
index 713e30adc3fe019b6b4bc6e441c8f89ee203efe6..a82a8bc9e3cb205ef6b881fc73b91ff1eda8709d 100644 (file)
@@ -181,7 +181,7 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
     case COMPRESS_SECTION_NONE:
       if (p == NULL)
        {
-         p = (bfd_byte *) bfd_zmalloc (sz);
+         p = (bfd_byte *) bfd_malloc (sz);
          if (p == NULL)
            return FALSE;
        }
@@ -221,7 +221,7 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
       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;
 
index f5727feda442bb0f8cc690706ea990303ae73908..22448744a83412ad49ee4579cd471feb12615747 100644 (file)
@@ -1098,10 +1098,10 @@ elf_checksum_contents (bfd *abfd,
       (*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;