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
}