From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id CF8D3385E010 for ; Tue, 4 Oct 2022 08:07:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF8D3385E010 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x432.google.com with SMTP id c3so7636315pfb.12 for ; Tue, 04 Oct 2022 01:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date; bh=Q9i/1KJe3zcCCu/HiDPFlcAQPcFGPZv1dkO8X0oJkig=; b=HCEIQa+/uaZZ5zsbNi5XhQ1HtuKBADutXMKVKA3b4ayZtL3DEWS97saWjRvQyrNThd oyC7gg8urzthFHyZEDWtW041+AnEP7XoevBxbTeV1VsKEmTB7/z6TXiHe67IP0eZMGXL 0/A5aKhhs4XPr+e0Rurkm4gFd9R9yTZKX93nklv6rXXVs9zWkgw7yBqTAKUoPfQt2Ums 3RCU4ydfCErgcgehrlESm7Oa5r6IrcLB8cd90EtaGh5DPlcMhQTgGuwqAn+QGZ6ADNJL pb6LMMGhAf+jP6xx6oEv4dhVQ0aqXZ2ZtsooEzWM/bfsz6yP30/XcEZWJ5dZKKaVUnQP M8Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=Q9i/1KJe3zcCCu/HiDPFlcAQPcFGPZv1dkO8X0oJkig=; b=le+/yR4yxOAjgAvKlsXwwUjJBSoVSNW8xERzxPHd+5hWrU3dGJRlgl+N752Iv1JAvP tY8hVCJWGBY8MRiRQLaflK7oCjvak9IBCnISgrTdcTl9Dh9CYIPL4NhkbIV00fQYweKS miKT1lRQBWJLd3BZbOm3vnRLmDf+81sLfKnuxdI8DojT9HugyO7joyXT/7clY7bfpnjf OKv11g1cka8/FUNWh+rgDI/MPvZqoLih5fukWND2fscL9X97RsX9UG4Ty1uXSIYwL1aZ nhmzvm3TAT8zCgcQBX8CdVBaNm/9131KMDi9BsM8CrdCFPWnUX4AR1Zp8k0CZMhG/odE rG4A== X-Gm-Message-State: ACrzQf3h6c6QcTbpz/AGHy9u1r+MuAsBWzFsGHpiCMTsJYQPy1Igl0E2 9FYyXyWsiRzZiuD1dtoPHVxfsEPdj50= X-Google-Smtp-Source: AMsMyM7Erm0CKzHMZJEfPgcY80WaKpvW7oWOydRw24JkO3fZ1pIF0b6OqZ8bmIorgUrPf1KiLHry+Q== X-Received: by 2002:a63:40d:0:b0:44b:3dc1:d4fb with SMTP id 13-20020a63040d000000b0044b3dc1d4fbmr10995263pge.469.1664870841548; Tue, 04 Oct 2022 01:07:21 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:63b5:ea40:cab:894b]) by smtp.gmail.com with ESMTPSA id d13-20020a170903230d00b00172d0c7edf4sm8470836plh.106.2022.10.04.01.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 01:07:20 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 15DF1114090F; Tue, 4 Oct 2022 18:37:18 +1030 (ACDT) Date: Tue, 4 Oct 2022 18:37:18 +1030 From: Alan Modra To: Martin =?utf-8?B?TGnFoWth?= Cc: binutils@sourceware.org Subject: Re: [PATCH] compress .gnu.debuglto_.debug_* sections if requested Message-ID: References: <7e8f08f2-6c4f-0bfb-8cd0-bec1bf6fe5c2@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-3035.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: On Fri, Sep 30, 2022 at 09:19:49AM +0200, Martin Liška wrote: > * write.c (compress_debug): Compress also ".gnu.debuglto_.debug_" > if the compression algorithm is different from zlib-gnu. OK, choosing to skip compression for zlib-gnu is a reasonable approach given that zlib-gnu has the clunky .debug_* to .zdebug_* section renaming scheme. I'm going to commit your patch, but then enable zlib-gnu with a followup patch of mine that doesn't rename the lto debug sections. ld.bfd and the binutils work fine without renaming, but there may be some other reason why zlib-gnu must have .zdebug sections. If that turns out to be the case, my patch below can be reverted. 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.*. diff --git a/bfd/elf.c b/bfd/elf.c index 8cd257fc65c..420b524aae8 100644 --- 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_*. */ diff --git a/gas/write.c b/gas/write.c index b8d5253006c..30f6c110908 100644 --- a/gas/write.c +++ b/gas/write.c @@ -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); -- Alan Modra Australia Development Lab, IBM