public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] compress .gnu.debuglto_.debug_* sections if requested
@ 2022-09-29 13:35 Martin Liška
  2022-09-30  0:20 ` Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Liška @ 2022-09-29 13:35 UTC (permalink / raw)
  To: binutils; +Cc: H.J. Lu

Right now, when using LTO, the intermediate object files do contain
debug info in sections starting with .gnu.debuglto_ prefix and are
not compressed when --compress-debug-sections is used.

It's a mistake and we can save quite some disk space. The following
example comes from tramp3d when the corresponding LTO sections
are compressed with zlib:

$ bloaty tramp3d-v4-v2.o -- tramp3d-v4.o
    FILE SIZE        VM SIZE
 --------------  --------------
   +83%     +10  [ = ]       0    [Unmapped]
 -68.0%    -441  [ = ]       0    .gnu.debuglto_.debug_line
 -52.3%    -759  [ = ]       0    .gnu.debuglto_.debug_line_str
 -62.4% -3.24Ki  [ = ]       0    .gnu.debuglto_.debug_abbrev
 -64.8% -1.12Mi  [ = ]       0    .gnu.debuglto_.debug_info
 -88.8% -4.58Mi  [ = ]       0    .gnu.debuglto_.debug_str
 -27.7% -5.70Mi  [ = ]       0    TOTAL

Survives tests on x86_64-linux-gnu.

Ready to be installed?
Thanks,
Martin

bfd/ChangeLog:

	* elf.c (_bfd_elf_make_section_from_shdr): Compress also
	".gnu.debuglto_.debug_" and use startswith for all 3 prefixes.

gas/ChangeLog:

	* write.c (compress_debug): Compress also ".gnu.debuglto_.debug_".
---
 bfd/elf.c   | 9 +++++----
 gas/write.c | 3 ++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/bfd/elf.c b/bfd/elf.c
index d496c1b2983..5d67c6f0694 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1199,12 +1199,13 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
 	}
     }
 
-  /* Compress/decompress DWARF debug sections with names: .debug_* and
-     .zdebug_*, after the section flags is set.  */
+  /* Compress/decompress DWARF debug sections with names: .debug_*,
+     .zdebug_*, .gnu.debuglto_.debug_, after the section flags is set.  */
   if ((newsect->flags & SEC_DEBUGGING) != 0
       && (newsect->flags & SEC_HAS_CONTENTS) != 0
-      && ((name[1] == 'd' && name[6] == '_')
-	  || (name[1] == 'z' && name[7] == '_')))
+      && (startswith (name, ".debug_")
+	  || startswith (name, ".zdebug_")
+	  || startswith (name, ".gnu.debuglto_.debug_")))
     {
       enum { nothing, compress, decompress } action = nothing;
       int compression_header_size;
diff --git a/gas/write.c b/gas/write.c
index 0e49df7c03f..7c6affd8d50 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1481,7 +1481,8 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
     return;
 
   section_name = bfd_section_name (sec);
-  if (!startswith (section_name, ".debug_"))
+  if (!startswith (section_name, ".debug_")
+      && !startswith (section_name, ".gnu.debuglto_.debug_"))
     return;
 
   bool use_zstd = abfd->flags & BFD_COMPRESS_ZSTD;
-- 
2.37.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-10-04 13:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 13:35 [PATCH] compress .gnu.debuglto_.debug_* sections if requested Martin Liška
2022-09-30  0:20 ` Alan Modra
2022-09-30  7:19   ` Martin Liška
2022-10-04  8:07     ` Alan Modra
2022-10-04  8:12       ` Martin Liška
2022-10-04 13:41         ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).