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.
This commit is contained in:
Alan Modra
2022-12-07 09:28:18 +10:30
parent 9db0f1ae84
commit c3620d6d56
12 changed files with 132 additions and 119 deletions

View File

@@ -352,7 +352,7 @@ main (int argc, char **argv)
link_info.spare_dynamic_tags = 5;
link_info.path_separator = ':';
#ifdef DEFAULT_FLAG_COMPRESS_DEBUG
link_info.compress_debug = DEFAULT_COMPRESSED_DEBUG_ALGORITHM;
config.compress_debug = DEFAULT_COMPRESSED_DEBUG_ALGORITHM;
#endif
#ifdef DEFAULT_NEW_DTAGS
link_info.new_dtags = DEFAULT_NEW_DTAGS;
@@ -503,16 +503,23 @@ main (int argc, char **argv)
else
link_info.output_bfd->flags |= EXEC_P;
if ((link_info.compress_debug & COMPRESS_DEBUG))
flagword flags = 0;
switch (config.compress_debug)
{
link_info.output_bfd->flags |= BFD_COMPRESS;
if (link_info.compress_debug != COMPRESS_DEBUG_GNU_ZLIB)
{
link_info.output_bfd->flags |= BFD_COMPRESS_GABI;
if (link_info.compress_debug == COMPRESS_DEBUG_ZSTD)
link_info.output_bfd->flags |= BFD_COMPRESS_ZSTD;
}
case COMPRESS_DEBUG_GNU_ZLIB:
flags = BFD_COMPRESS;
break;
case COMPRESS_DEBUG_GABI_ZLIB:
flags = BFD_COMPRESS | BFD_COMPRESS_GABI;
break;
case COMPRESS_DEBUG_ZSTD:
flags = BFD_COMPRESS | BFD_COMPRESS_GABI | BFD_COMPRESS_ZSTD;
break;
default:
break;
}
link_info.output_bfd->flags
|= flags & bfd_applicable_file_flags (link_info.output_bfd);
ldwrite ();