From 7afbac7ddd7299491a88341149bc72b38173447a Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 29 Sep 2022 14:10:30 +0200 Subject: compress .gnu.debuglto_.debug_* sections if requested 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 bfd/ChangeLog: * elf.c (_bfd_elf_make_section_from_shdr): Compress all debug info sections. gas/ChangeLog: * write.c (compress_debug): Compress also ".gnu.debuglto_.debug_" if the compression algorithm is different from zlib-gnu. --- gas/write.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gas/write.c') diff --git a/gas/write.c b/gas/write.c index 0e49df7..b8d5253 100644 --- a/gas/write.c +++ b/gas/write.c @@ -1481,7 +1481,9 @@ 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_") + || flag_compress_debug == COMPRESS_DEBUG_GNU_ZLIB)) return; bool use_zstd = abfd->flags & BFD_COMPRESS_ZSTD; -- cgit v1.1