public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: Alan Modra <amodra@gmail.com>
Cc: "Martin Liška" <mliska@suse.cz>, binutils@sourceware.org
Subject: Re: [PATCH] readelf: support zstd compressed debug sections [PR 29640]
Date: Sun, 16 Oct 2022 13:46:52 -0700	[thread overview]
Message-ID: <20221016204652.hhh4mfeugnrfkoou@google.com> (raw)
In-Reply-To: <Y0uLoT+kABkzepCG@squeak.grove.modra.org>

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?

  reply	other threads:[~2022-10-16 20:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01  6:20 Fangrui Song
2022-10-06  2:20 ` Fangrui Song
2022-10-20  8:04   ` Martin Liška
2022-10-20  8:05   ` Martin Liška
2022-10-13 11:38 ` Martin Liška
2022-10-14  3:35   ` Fangrui Song
2022-10-14  7:47     ` Martin Liška
2022-10-14  8:26       ` Martin Liška
2022-10-14 11:28         ` Alan Modra
2022-10-14 12:09           ` Alan Modra
2022-10-16  4:42             ` Alan Modra
2022-10-16 20:46               ` Fangrui Song [this message]
2022-10-21  9:16                 ` Alan Modra
2022-10-17  7:52               ` Martin Liška

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221016204652.hhh4mfeugnrfkoou@google.com \
    --to=maskray@google.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).