Support objcopy changing compression to or from zstd

Alan Modra amodra@gmail.com
Wed Oct 5 21:04:16 GMT 2022


On Tue, Oct 04, 2022 at 03:01:34PM -0700, Fangrui Song wrote:
> On 2022-10-04, Alan Modra via Binutils wrote:
> > Commit 2cac01e3ffff lacked support for objcopy changing compression
> > style.  Add that support, which meant a rewrite of
> > bfd_compress_section_contents.  In the process I've fixed some memory
> > leaks.
> 
> For objcopy --compress-debug-sections=zstd , I know that omitting
> recompression of zlib into zstd was intentional.
> 
> --compress-debug-sections=zstd does not specify what to do when a section is
> compressed, so both (a)
> do nothing (b) re-compression with zstd are fine but I think
> avoiding recompression can avoid some complexity...
> 
> If a .o is compressed with zlib level 5, should --compress-debug-sections=zlib
> re-compress it or leave it as-is?
> 
> At any rate, I think the  objcopy --compress-debug-sections=zstd
> behavior with zlib compressed sections is mostly not interesting to a
> user.

I could have lived with objcopy --compress-debug-sections=zstd doing
nothing on already compressed sections.  After all, users could change
compression schemes by a two step process, first objcopy
--decompress-debug-sections then compress with the desired scheme.

However, I discovered that objcopy --compress-debug-sections=zstd
on a zlib-gnu compressed file copied the zlib data and tacked on a
header specifying zstd.  Which of course then causes errors on
attempted decompression.  That needed fixing regardless of what anyone
thinks objcopy --compress-debug-sections=zstd should do with already
compressed debug sections.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list