]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Re: compress .gnu.debuglto_.debug_* sections if requested
authorAlan Modra <amodra@gmail.com>
Tue, 4 Oct 2022 02:39:36 +0000 (13:09 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 4 Oct 2022 08:06:45 +0000 (18:36 +1030)
Enable zlib-gnu compression for .gnu.debuglto_.debug_*.  This differs
from zlib-gnu for .debug_* where the name is changed to .zdebug_*.
The name change isn't really needed.

bfd/
* elf.c (elf_fake_sections): Replace "." with ".z" in debug
section names only when name was ".d*", ie. ".debug_*".
(_bfd_elf_assign_file_positions_for_non_load): Likewise.
gas/
* write.c (compress_debug): Compress .gnu.debuglto_.debug_*
for zlib-gnu too.  Compress .gnu.linkonce.wi.*.

bfd/elf.c
gas/write.c

index 8cd257fc65cc0708fb9cc95449378198b10c8895..420b524aae8fede59af2da8a9e6a81f962513dd7 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3234,7 +3234,8 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
              name = new_name;
            }
        }
-      else if (asect->compress_status == COMPRESS_SECTION_DONE)
+      else if (asect->compress_status == COMPRESS_SECTION_DONE
+              && name[1] == 'd')
        {
          /* PR binutils/18087: Compression does not always make a
             section smaller.  So only rename the section when
@@ -3246,7 +3247,6 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
              arg->failed = true;
              return;
            }
-         BFD_ASSERT (name[1] != 'z');
          name = new_name;
        }
     }
@@ -6689,7 +6689,8 @@ _bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
                    return false;
 
                  if (sec->compress_status == COMPRESS_SECTION_DONE
-                     && (abfd->flags & BFD_COMPRESS_GABI) == 0)
+                     && (abfd->flags & BFD_COMPRESS_GABI) == 0
+                     && name[1] == 'd')
                    {
                      /* If section is compressed with zlib-gnu, convert
                         section name from .debug_* to .zdebug_*.  */
index b8d5253006c98fec56e0c657723a1432d1b8fc21..30f6c1109088686416b9a047578141e75c819ebe 100644 (file)
@@ -1473,7 +1473,7 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
   char *header;
   int x;
   flagword flags = bfd_section_flags (sec);
-  unsigned int header_size, compression_header_size;
+  unsigned int header_size;
 
   if (seginfo == NULL
       || sec->size < 32
@@ -1482,8 +1482,8 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
 
   section_name = bfd_section_name (sec);
   if (!startswith (section_name, ".debug_")
-      && (!startswith (section_name, ".gnu.debuglto_.debug_")
-         || flag_compress_debug == COMPRESS_DEBUG_GNU_ZLIB))
+      && !startswith (section_name, ".gnu.debuglto_.debug_")
+      && !startswith (section_name, ".gnu.linkonce.wi."))
     return;
 
   bool use_zstd = abfd->flags & BFD_COMPRESS_ZSTD;
@@ -1492,16 +1492,9 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
     return;
 
   if (flag_compress_debug == COMPRESS_DEBUG_GNU_ZLIB)
-    {
-      compression_header_size = 0;
-      header_size = 12;
-    }
+    header_size = 12;
   else
-    {
-      compression_header_size
-       = bfd_get_compression_header_size (stdoutput, NULL);
-      header_size = compression_header_size;
-    }
+    header_size = bfd_get_compression_header_size (stdoutput, NULL);
 
   /* Create a new frag to contain the compression header.  */
   first_newf = frag_alloc (ob);
@@ -1609,7 +1602,8 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
   bfd_update_compression_header (abfd, (bfd_byte *) header, sec);
   x = bfd_set_section_size (sec, compressed_size);
   gas_assert (x);
-  if (!compression_header_size)
+  if (flag_compress_debug == COMPRESS_DEBUG_GNU_ZLIB
+      && section_name[1] == 'd')
     {
       compressed_name = concat (".z", section_name + 1, (char *) NULL);
       bfd_rename_section (sec, compressed_name);