From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 40AEE3858D3C for ; Sun, 16 Oct 2022 20:46:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 40AEE3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-pj1-x1035.google.com with SMTP id x31-20020a17090a38a200b0020d2afec803so9265464pjb.2 for ; Sun, 16 Oct 2022 13:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hbOuUaWFqS0NGcpfKe51hSCDcLnPlVNmNIgoNb5goRg=; b=OYfR704NPZrve8T4vbMkzeSkfoWQc34wpatlDD1KAfsQdUzKEWPen0MtxOZHbyIvaQ yg0s2D4BNXnHR+8eqUtXL+aFgckT82ivQT1xNAo0YrAJ6YV9/KWDlhYbcHd/Aw5ABtER KdaCjWMKWZ4+Ah7Jd/6SbnKHQUZJTS6GjNjJAD3825SnO3RBGED8QuozLJfuI1kJralX hdD6wizKCSyHdMqZ4EcA3k3IWWUkr3EdqoArAAwwhSkuGuywin0SAeHDxU484mRh8qBs geKF9orfpi2q+udyJa9MhFOXNAWT2nsR718wzgG+wTwvTom9iOUVUIOVR03SM2wyA/5R +LkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hbOuUaWFqS0NGcpfKe51hSCDcLnPlVNmNIgoNb5goRg=; b=7EIFvazzAcM81s+0PKhlXrFksj/6QWIwBdgQfW3c5nVP5toUd+2XAEiW1zr6ItxrGH MYdoDCgOMzWM3nEd1sBfzPYKksn32eaCO+0tLs8ml5NO/kDwMm2L7FT8/GlZuN38o9yp iu5K7P3z3JCgYK3wWORzX3GKJ47GM449iiRNslPIoFTS9X7pczbDYKvnS/O9FjQIALHn GDnISQy28v8jVQFYFPxF4YBYUtymzaogS3e8afPoFcThV7J+gdS0vL3FgH56FCUxJoKR rauaz86z4ElvU9PGWo/OaoKRPDXSZSl99IfAvydco/M80Q3WNs+UelaXvIaINcHi6LWB GXpA== X-Gm-Message-State: ACrzQf04wIHjvdBjfe7LNqQev/Rfy0k43RZDTPeeP7+Y+ttp6uvwl+UJ v5hRHl5U/QWT3/Nh8VcB+/yhGJOLY699Dg== X-Google-Smtp-Source: AMsMyM5hJXFtkRXbwFsUHSqvwL5k+EeeWp4FO2tCF7rzotuIDpQ0RRWxOgCNkdGEIs3ow8pJGOQ9TQ== X-Received: by 2002:a17:903:2606:b0:180:8799:3685 with SMTP id jd6-20020a170903260600b0018087993685mr8504947plb.31.1665953218061; Sun, 16 Oct 2022 13:46:58 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:e6a7:e732:42fb:dc1d]) by smtp.gmail.com with ESMTPSA id i3-20020aa796e3000000b005633a06ad67sm5427956pfq.64.2022.10.16.13.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 13:46:56 -0700 (PDT) Date: Sun, 16 Oct 2022 13:46:52 -0700 From: Fangrui Song To: Alan Modra Cc: Martin =?utf-8?B?TGnFoWth?= , binutils@sourceware.org Subject: Re: [PATCH] readelf: support zstd compressed debug sections [PR 29640] Message-ID: <20221016204652.hhh4mfeugnrfkoou@google.com> References: <20221001062057.681440-1-maskray@google.com> <45fca661-a0e8-f0f8-78d6-8d90783de6d7@suse.cz> <20221014033511.vqanebcqikmi5k37@google.com> <56a23340-a416-0ac9-dc17-4be601edacf7@suse.cz> <5eeed442-a153-5805-eae9-44b006506fd1@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-20.0 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 2022-10-16, Alan Modra wrote: >On Fri, Oct 14, 2022 at 10:39:17PM +1030, Alan Modra wrote: >> On Fri, Oct 14, 2022 at 09:58:41PM +1030, Alan Modra wrote: >> > So we have a zlib-gabi .debug_info section that increases in size with >> > zstd, so much so that it's better to leave the section uncompressed. >> > Things go horribly wrong due to leaving compress_status as >> > COMPRESS_SECTION_NONE. The section is read again off disk using the >> > uncompressed size. So you get the zlib section again with some >> > garbage at the end. >> > >> > Also, if the section is to be left uncompressed, the input >> > SHF_COMPRESSED flag needs to be reset otherwise it is copied to >> > output. >> > >> > I'm not ready to commit this, just thought I'd post the results of a >> > bit of debugging. >> >> And if I'd run the testsuite before posting, I may have posted a >> better patch.. Using COMPRESS_SECTION_DONE led to .debug -> .zdebug >> renaming of sections, so it appears we want another compress_status >> that says the final section contents are in sec->contents. > >Another compress_status isn't elegant. I'm about to commit this: > > * bfd.c (bfd_convert_section_contents): Handle zstd. > * compress.c (bfd_compress_section_contents): When section > contents are uncompressed set SEC_IN_MEMORY flag, > compress_status to COMRESS_SECTION_NONE, and clear > SHF_COMPRESSED. Set SEC_IN_MEMORY for compressed contents. > (bfd_get_full_section_contents): Don't check section size > against file size when SEC_IN_MEMORY. > (bfd_cache_section_contents): Delete function. > * elf32-arm.c (elf32_arm_get_synthetic_symtab): Expand > bfd_cache_section_contents here. > * bfd-in2.h: Regenerate. Thanks. Commit 206e9791cb09459bf92603428370c16bfde282ac fixed the issue. ~/Dev/binutils-gdb/out/debug/binutils/objcopy -O elf32-x86-64 a.o a-x32.o --compress-debug-sections=zstd ~/Dev/binutils-gdb/out/debug/binutils/readelf -wi a-x32.o # good Is this readelf patch ok for installing?