[PATCH v2 1/3] bfd: fix reading compressed debug sections of pei-* images
Tobias Deiminger
tobias.deiminger@linutronix.de
Fri Nov 27 11:03:01 GMT 2026
Hi Jan,
Am Freitag, 27. November 2026, 11:14:54 Mitteleuropäische Normalzeit schrieb Jan Beulich:
> [...]
> This is okay, yet I wonder ...
>
> > --- a/bfd/compress.c
> > +++ b/bfd/compress.c
> > @@ -525,7 +525,8 @@ static bool
> > decompress_contents (bool is_zstd, bfd_byte *compressed_buffer,
> > bfd_size_type compressed_size,
> > bfd_byte *uncompressed_buffer,
> > - bfd_size_type uncompressed_size)
> > + bfd_size_type uncompressed_size,
> > + bool allow_padding)
> > {
> > if (is_zstd)
> > {
> > @@ -552,7 +553,21 @@ decompress_contents (bool is_zstd, bfd_byte *compressed_buffer,
> > compressed_size -= src_len;
> > }
> > while (compressed_size > 0 && uncompressed_size > 0);
> > - return compressed_size == 0 && uncompressed_size == 0;
>
> ... why this line needs deleting. Can't we keep it, doing ...
>
> > +
> > + if (allow_padding)
> > + {
> > + while (compressed_size > 0)
> > + {
> > + if (*compressed_buffer != 0)
> > + return false;
> > + compressed_buffer++;
> > + compressed_size--;
> > + }
> > + }
> > + else if (compressed_size > 0)
> > + return false;
> > +
> > + return uncompressed_size == 0;
> > }
>
> ... this a little differently:
>
> if (allow_padding)
> {
> while (compressed_size > 0)
> {
> if (*compressed_buffer != 0)
> return false;
> compressed_buffer++;
> compressed_size--;
> }
> }
>
> return compressed_size == 0 && uncompressed_size == 0;
>
> or even
>
> while (allow_padding && compressed_size > 0)
> {
> if (*compressed_buffer != 0)
> return false;
> compressed_buffer++;
> compressed_size--;
> }
>
> return compressed_size == 0 && uncompressed_size == 0;
ack, the behavior remains the same with both of your suggestions. I meant to
highlight the different padding expectations (only 0 bytes vs. no bytes at all),
but after comparing would also vote for your 2nd snippet.
> (I'm considering to simply switch to one of these when committing.)
Yes, thanks, please edit as it suites best.
Tobias
> Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/binutils/attachments/20261127/3df3830a/attachment-0001.sig>
More information about the Binutils
mailing list