]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/write.c
Don't add the zlib header to SHF_COMPRESSED section
[thirdparty/binutils-gdb.git] / gas / write.c
index bc76962c600efc442d7d180e360320f69808685d..894b271f776fb06b18ab93a858064204c9656d86 100644 (file)
@@ -1414,8 +1414,6 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
   int x;
   flagword flags = bfd_get_section_flags (abfd, sec);
   unsigned int header_size, compression_header_size;
-  /* Maximimum compression header is 24 bytes.  */
-  bfd_byte compression_header[24];
 
   if (seginfo == NULL
       || sec->size < 32
@@ -1431,14 +1429,20 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
     return;
 
   if (flag_compress_debug == COMPRESS_DEBUG_GABI_ZLIB)
-    stdoutput->flags |= BFD_COMPRESS | BFD_COMPRESS_GABI;
+    {
+      stdoutput->flags |= BFD_COMPRESS | BFD_COMPRESS_GABI;
+      compression_header_size
+       = bfd_get_compression_header_size (stdoutput, NULL);
+      header_size = compression_header_size;
+    }
   else
-    stdoutput->flags |= BFD_COMPRESS;
-  compression_header_size
-    = bfd_get_compression_header_size (stdoutput, NULL);
+    {
+      stdoutput->flags |= BFD_COMPRESS;
+      compression_header_size = 0;
+      header_size = 12;
+    }
 
-  /* Create a new frag to contain the "ZLIB" header.  */
-  header_size = 12 + compression_header_size;
+  /* Create a new frag to contain the compression header.  */
   first_newf = frag_alloc (ob);
   if (obstack_room (ob) < header_size)
     first_newf = frag_alloc (ob);
@@ -1533,11 +1537,6 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
   if (compressed_size >= uncompressed_size)
     return;
 
-  if (compression_header_size)
-    memcpy (header, compression_header, compression_header_size);
-  memcpy (header + compression_header_size, "ZLIB", 4);
-  bfd_putb64 (uncompressed_size, header + compression_header_size + 4);
-
   /* Replace the uncompressed frag list with the compressed frag list.  */
   seginfo->frchainP->frch_root = first_newf;
   seginfo->frchainP->frch_last = last_newf;