Revert "bfd: Always check sections with the corrupt size"

This reverts commit e0f7ea91436dd308a094c4c101fd4169e8245a91.
This commit is contained in:
H.J. Lu
2021-11-04 08:07:09 -07:00
parent e0f7ea9143
commit 33d3e18ed7

View File

@ -232,7 +232,6 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
bfd_size_type save_rawsize;
bfd_byte *compressed_buffer;
unsigned int compression_header_size;
ufile_ptr filesize;
if (abfd->direction != write_direction && sec->rawsize != 0)
sz = sec->rawsize;
@ -244,7 +243,12 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
return true;
}
filesize = bfd_get_file_size (abfd);
switch (sec->compress_status)
{
case COMPRESS_SECTION_NONE:
if (p == NULL)
{
ufile_ptr filesize = bfd_get_file_size (abfd);
if (filesize > 0
&& filesize < sz
/* PR 24753: Linker created sections can be larger than
@ -253,12 +257,10 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
/* PR 24753: Sections which have no content should also be
excluded as they contain no size on disk. */
&& (bfd_section_flags (sec) & SEC_HAS_CONTENTS) != 0
/* PR 28530: Check compressed sections with the corrupt size. */
&& (sec->compress_status != COMPRESS_SECTION_NONE
/* The MMO file format supports its own special compression
technique, but it uses COMPRESS_SECTION_NONE when loading
a section's contents. */
|| bfd_get_flavour (abfd) != bfd_target_mmo_flavour))
&& bfd_get_flavour (abfd) != bfd_target_mmo_flavour)
{
/* PR 24708: Avoid attempts to allocate a ridiculous amount
of memory. */
@ -269,12 +271,6 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
abfd, sec, (uint64_t) sz, (uint64_t) filesize);
return false;
}
switch (sec->compress_status)
{
case COMPRESS_SECTION_NONE:
if (p == NULL)
{
p = (bfd_byte *) bfd_malloc (sz);
if (p == NULL)
{