summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2011-12-14 16:12:12 +0000
committerNick Clifton <nickc@redhat.com>2011-12-14 16:12:12 +0000
commit97dc69a186828fd42e7ed11605c973cf77f8e4a9 (patch)
tree64b260fec9dabd560e3af41ad6eed1732ab5474c /bfd
parent5a212e0deaa09a7ec47f6b04b23d1979c331c4a2 (diff)
downloadbinutils-redhat-97dc69a186828fd42e7ed11605c973cf77f8e4a9.tar.gz
When computing checksums, skip the contents of sections with the SHT_NOBITS type.
Revert change to compress.c
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/compress.c4
-rw-r--r--bfd/elfcode.h4
3 files changed, 7 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 96ab8798d1..9e995a1f72 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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.
diff --git a/bfd/compress.c b/bfd/compress.c
index 713e30adc3..a82a8bc9e3 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -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;
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index f5727feda4..22448744a8 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -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;