Support objcopy changing compression to or from zstd

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.

	* compress.c (bfd_is_section_compressed_info): Rename from
	bfd_is_section_compressed_with_header and add ch_type param
	to return compression header ch_type field.
	Update all callers.
	(decompress_section_contents): Remove buffer and size params.
	Rewrite.  Update callers.
	(bfd_init_section_compress_status): Free contents on failure.
	(bfd_compress_section): Likewise.
	* elf.c (_bfd_elf_make_section_from_shdr): Support objcopy
	changing between any of the three compression schemes.  Report
	"unable to compress/decompress" rather than "unable to
	initialize compress/decompress status" on compress/decompress
	failures.
	* bfd-in2.h: Regenerate.
This commit is contained in:
Alan Modra
2022-10-04 13:14:05 +10:30
parent 034235cebd
commit 758dd750bc
3 changed files with 168 additions and 168 deletions

View File

@ -7953,11 +7953,12 @@ bool bfd_get_full_section_contents
void bfd_cache_section_contents
(asection *sec, void *contents);
bool bfd_is_section_compressed_with_header
bool bfd_is_section_compressed_info
(bfd *abfd, asection *section,
int *compression_header_size_p,
bfd_size_type *uncompressed_size_p,
unsigned int *uncompressed_alignment_power_p);
unsigned int *uncompressed_alignment_power_p,
unsigned int *ch_type);
bool bfd_is_section_compressed
(bfd *abfd, asection *section);