diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/emultempl/elf.em | 6 | ||||
-rw-r--r-- | ld/ld.h | 3 | ||||
-rw-r--r-- | ld/ldmain.c | 25 | ||||
-rw-r--r-- | ld/lexsup.c | 2 |
4 files changed, 23 insertions, 13 deletions
diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em index 5dfc03a..5e96335 100644 --- a/ld/emultempl/elf.em +++ b/ld/emultempl/elf.em @@ -660,16 +660,16 @@ gld${EMULATION_NAME}_handle_option (int optc) break; case OPTION_COMPRESS_DEBUG: - link_info.compress_debug = bfd_get_compression_algorithm (optarg); + config.compress_debug = bfd_get_compression_algorithm (optarg); if (strcasecmp (optarg, "zstd") == 0) { #ifndef HAVE_ZSTD - if (link_info.compress_debug == COMPRESS_DEBUG_ZSTD) + if (config.compress_debug == COMPRESS_DEBUG_ZSTD) einfo (_ ("%F%P: --compress-debug-sections=zstd: ld is not built " "with zstd support\n")); #endif } - if (link_info.compress_debug == COMPRESS_UNKNOWN) + if (config.compress_debug == COMPRESS_UNKNOWN) einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"), optarg); break; @@ -304,6 +304,9 @@ typedef struct /* If set, share only duplicated types in CTF, rather than sharing all types that are not in conflict. */ bool ctf_share_duplicated; + + /* Compress DWARF debug sections. */ + enum compressed_debug_section_type compress_debug; } ld_config_type; extern ld_config_type config; diff --git a/ld/ldmain.c b/ld/ldmain.c index 10f7a05..a28f341 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -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 (); diff --git a/ld/lexsup.c b/ld/lexsup.c index d107bd7..673b62e 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -2163,7 +2163,7 @@ elf_static_list_options (FILE *file) Compress DWARF debug sections\n")); fprintf (file, _("\ Default: %s\n"), - bfd_get_compression_algorithm_name (link_info.compress_debug)); + bfd_get_compression_algorithm_name (config.compress_debug)); fprintf (file, _("\ -z common-page-size=SIZE Set common page size to SIZE\n")); fprintf (file, _("\ |