aboutsummaryrefslogtreecommitdiff
path: root/bfd/compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/compress.c')
-rw-r--r--bfd/compress.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/bfd/compress.c b/bfd/compress.c
index 0087a66..ad1fbee 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -441,7 +441,18 @@ bfd_init_section_compress_status (bfd *abfd ATTRIBUTE_UNUSED,
uncompressed_buffer,
uncompressed_size);
- free (uncompressed_buffer);
+ /* PR binutils/18087: If compression didn't make
+ the section smaller, just keep it uncompressed. */
+ if (ret && uncompressed_size < sec->size)
+ {
+ free (sec->contents);
+ sec->contents = uncompressed_buffer;
+ sec->size = uncompressed_size;
+ sec->compress_status = COMPRESS_SECTION_NONE;
+ }
+ else
+ free (uncompressed_buffer);
+
return ret;
#endif
}