From c3620d6d5639ab7a0b483030350e8f2929212ea7 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 7 Dec 2022 09:28:18 +1030 Subject: Compression tidy and fixes Tidies: - Move stuff from bfd-in.h and libbfd.c to compress.c - Delete COMPRESS_DEBUG from enum compressed_debug_section_type - Move compress_debug field out of link_info to ld_config. Fixes: - Correct test in bfd_convert_section_setup to use obfd flags, not ibfd. - Apply bfd_applicable_file_flags to compression bfd flags added by gas and ld to the output bfd. bfd/ * bfd-in.h (enum compressed_debug_section_type), (struct compressed_type_tuple), (bfd_get_compression_algorithm), (bfd_get_compression_algorithm_name), * libbfd.c (compressed_debug_section_names), (bfd_get_compression_algorithm), (bfd_get_compression_algorithm_name): Move.. * compress.c: ..to here, deleting COMPRESS_DEBUG from enum compressed_debug_section_type. (bfd_convert_section_setup): Test obfd flags not ibfd for compression flags. * elf.c (elf_fake_sections): Replace link_info->compress_debug test with abfd->flags test. * bfd-in2.h: Regenerate. binutils/ * objcopy.c (copy_file): Tidy setting of bfd compress flags. Expand comment. gas/ * write.c (compress_debug): Test bfd compress flags rather than flag_compress_debug. (write_object_file): Apply bfd_applicable_file_flags to compress debug flags added to output bfd. include/ * bfdlink.h (struct bfd_link_info): Delete compress_debug. ld/ * ld.h (ld_config_type): Add compress_debug. * emultempl/elf.em: Replace references to link_info.compress_debug with config.compress_debug. * lexsup.c (elf_static_list_options): Likewise. * ldmain.c (main): Likewise. Apply bfd_applicable_file_flags to compress debug flags added to output bfd. --- binutils/objcopy.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'binutils/objcopy.c') diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 19dbb50..be08f7b 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -3804,15 +3804,17 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, switch (do_debug_sections) { + case compress_gnu_zlib: + ibfd->flags |= BFD_COMPRESS; + break; case compress: case compress_zlib: - case compress_gnu_zlib: + /* The above two cases ought to just set BFD_COMPRESS for non-ELF + but we can't tell whether a file is ELF or not until after + bfd_check_format_matches. FIXME maybe: decide compression + style in BFD after bfd_check_format_matches. */ case compress_gabi_zlib: - ibfd->flags |= BFD_COMPRESS; - /* Don't check if input is ELF here since this information is - only available after bfd_check_format_matches is called. */ - if (do_debug_sections != compress_gnu_zlib) - ibfd->flags |= BFD_COMPRESS_GABI; + ibfd->flags |= BFD_COMPRESS | BFD_COMPRESS_GABI; break; case compress_zstd: ibfd->flags |= BFD_COMPRESS | BFD_COMPRESS_GABI | BFD_COMPRESS_ZSTD; -- cgit v1.1