From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 575623858D39 for ; Thu, 29 Sep 2022 13:35:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 575623858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9680521AC1; Thu, 29 Sep 2022 13:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1664458515; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U+OzumS3HIaaQt6gNxvfSeOEsX3HVFKKgjI5v8BXFVs=; b=yGknaqk4yqxWIKhxawxc+Wn/yhQeRdx7l43YKI+buFV+HcZPdptmGIL/aij0NnWSB6AGJD lEG+LipFjTashZ5SqAFseD/uiiEIKBt1ouAYDjP7C0sbBq6JGVf1nPVjNzs6r129F3KbbY oUWRmpESzNjxwmqJLY8GlrbKzbq4eEE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1664458515; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U+OzumS3HIaaQt6gNxvfSeOEsX3HVFKKgjI5v8BXFVs=; b=a04Qw9jQZ2YGxcJlfNgR27Y+IMaPst5oDGk3vLDadx5Y0N5UP5f6lAzW4E+xfMuEDZiyzW jfEFHXPNcGyBtDAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 85FC61348E; Thu, 29 Sep 2022 13:35:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FFKzHhOfNWPNKQAAMHmgww (envelope-from ); Thu, 29 Sep 2022 13:35:15 +0000 Message-ID: <7e8f08f2-6c4f-0bfb-8cd0-bec1bf6fe5c2@suse.cz> Date: Thu, 29 Sep 2022 15:35:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] compress .gnu.debuglto_.debug_* sections if requested To: binutils@sourceware.org Content-Language: en-US Cc: "H.J. Lu" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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