Fix debug section compression so that it is only performed if it would make the secti...
[deliverable/binutils-gdb.git] / bfd / compress.c
index 0087a665d87b3357e0ba190acdc347892bd944ca..ad1fbee0133d93d289b59a62f7473171fdc937bc 100644 (file)
@@ -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
 }
This page took 0.027195 seconds and 4 git commands to generate.