diff options
author | Martin Liska <mliska@suse.cz> | 2022-10-03 09:11:00 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-10-11 14:13:26 +0200 |
commit | 857bddbe737bc963bd9e5a3b24743a9bba5d2d7b (patch) | |
tree | 487913f1480b0ace5fa040e07f2b839c9eb00175 /bfd/libbfd.c | |
parent | c6422d7be70f14bf7140085f2fc7a592737f5df5 (diff) | |
download | gdb-857bddbe737bc963bd9e5a3b24743a9bba5d2d7b.zip gdb-857bddbe737bc963bd9e5a3b24743a9bba5d2d7b.tar.gz gdb-857bddbe737bc963bd9e5a3b24743a9bba5d2d7b.tar.bz2 |
refactor usage of compressed_debug_section_type
bfd/ChangeLog:
* bfd-in.h (bfd_hash_set_default_size): Add COMPRESS_UNKNOWN
enum value.
(struct compressed_type_tuple): New.
* bfd-in2.h (bfd_hash_set_default_size): Regenerate.
(struct compressed_type_tuple): Likewise.
* libbfd.c (ARRAY_SIZE): New macro.
(bfd_get_compression_algorithm): New function.
(bfd_get_compression_algorithm_name): Likewise.
gas/ChangeLog:
* as.c: Do not special-case, use the new functions.
ld/ChangeLog:
* emultempl/elf.em: Do not special-case, use the new functions.
* lexsup.c (elf_static_list_options): Likewise.
Diffstat (limited to 'bfd/libbfd.c')
-rw-r--r-- | bfd/libbfd.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c index d33f341..14e7d8e 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -1244,3 +1244,39 @@ _bfd_generic_init_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, { return true; } + +/* Display texts for type of compressed DWARF debug sections. */ +static const struct compressed_type_tuple compressed_debug_section_names[] = +{ + { COMPRESS_DEBUG_NONE, "none" }, + { COMPRESS_DEBUG, "zlib" }, + { COMPRESS_DEBUG_GNU_ZLIB, "zlib-gnu" }, + { COMPRESS_DEBUG_GABI_ZLIB, "zlib-gabi" }, + { COMPRESS_DEBUG_ZSTD, "zstd" }, +}; + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) +#endif + +/* Return compressed_debug_section_type from a string representation. */ +enum compressed_debug_section_type +bfd_get_compression_algorithm (const char *name) +{ + for (unsigned i = 0; i < ARRAY_SIZE (compressed_debug_section_names); ++i) + if (strcasecmp (compressed_debug_section_names[i].name, name) == 0) + return compressed_debug_section_names[i].type; + + return COMPRESS_UNKNOWN; +} + +/* Return compression algorithm name based on the type. */ +const char * +bfd_get_compression_algorithm_name (enum compressed_debug_section_type type) +{ + for (unsigned i = 0; i < ARRAY_SIZE (compressed_debug_section_names); ++i) + if (type == compressed_debug_section_names[i].type) + return compressed_debug_section_names[i].name; + + return NULL; +} |