diff options
Diffstat (limited to 'binutils/dwarf.c')
-rw-r--r-- | binutils/dwarf.c | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 5b3ece5..f4bcb67 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -30,6 +30,7 @@ #include "gdb/gdb-index.h" #include "filenames.h" #include "safe-ctype.h" +#include "sframe-api.h" #include <assert.h> #ifdef HAVE_LIBDEBUGINFOD @@ -102,6 +103,7 @@ int do_debug_str; int do_debug_str_offsets; int do_debug_loc; int do_gdb_index; +int do_sframe; int do_trace_info; int do_trace_abbrevs; int do_trace_aranges; @@ -7689,6 +7691,37 @@ display_trace_info (struct dwarf_section *section, void *file) } static int +display_sframe (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) +{ + sframe_decoder_ctx *sfd_ctx = NULL; + unsigned char *data = section->start; + size_t sf_size = section->size; + int err = 0; + + if (strcmp (section->name, "") == 0) + { + error (_("Section name must be provided \n")); + return false; + } + + /* Decode the contents of the section. */ + sfd_ctx = sframe_decode ((const char*)data, sf_size, &err); + if (!sfd_ctx || err) + { + error (_("SFrame decode failure: %s\n"), sframe_errmsg (err)); + return false; + } + + printf (_("Contents of the SFrame section %s:"), section->name); + /* Dump the contents as text. */ + dump_sframe (sfd_ctx, section->address); + + sframe_decoder_free (&sfd_ctx); + + return true; +} + +static int display_debug_aranges (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) { @@ -8549,6 +8582,8 @@ typedef struct Frame_Chunk } Frame_Chunk; +typedef bool (*is_mach_augmentation_ftype) (char c); +static is_mach_augmentation_ftype is_mach_augmentation; typedef const char *(*dwarf_regname_lookup_ftype) (unsigned int); static dwarf_regname_lookup_ftype dwarf_regnames_lookup_func; static const char *const *dwarf_regnames; @@ -8861,9 +8896,22 @@ init_dwarf_regnames_loongarch (void) dwarf_regnames_lookup_func = regname_internal_by_table_only; } +static bool +is_nomach_augmentation (char c ATTRIBUTE_UNUSED) +{ + return false; +} + +static bool +is_aarch64_augmentation (char c) +{ + return (c == 'B' || c == 'G'); +} + void -init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine) +init_dwarf_by_elf_machine_code (unsigned int e_machine) { + is_mach_augmentation = is_nomach_augmentation; dwarf_regnames_lookup_func = NULL; is_aarch64 = false; @@ -8885,6 +8933,7 @@ init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine) case EM_AARCH64: init_dwarf_regnames_aarch64 (); + is_mach_augmentation = is_aarch64_augmentation; break; case EM_S390: @@ -8908,9 +8957,10 @@ init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine) architecture and specific machine type of a BFD. */ void -init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch, - unsigned long mach) +init_dwarf_by_bfd_arch_and_mach (enum bfd_architecture arch, + unsigned long mach) { + is_mach_augmentation = is_nomach_augmentation; dwarf_regnames_lookup_func = NULL; is_aarch64 = false; @@ -8938,6 +8988,7 @@ init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch, case bfd_arch_aarch64: init_dwarf_regnames_aarch64(); + is_mach_augmentation = is_aarch64_augmentation; break; case bfd_arch_s390: @@ -9183,7 +9234,7 @@ read_cie (unsigned char *start, unsigned char *end, fc->fde_encoding = *q++; else if (*p == 'S') ; - else if (*p == 'B') + else if (is_mach_augmentation (*p)) ; else break; @@ -10930,7 +10981,7 @@ display_debug_links (struct dwarf_section * section, (padding) If needed to reach a 4 byte boundary. (uint32_t) CRC32 value. - The .gun_debugaltlink section is formatted as: + The .gnu_debugaltlink section is formatted as: (c-string) Filename. (binary) Build-ID. */ @@ -12330,7 +12381,7 @@ load_build_id_debug_file (const char * main_filename ATTRIBUTE_UNUSED, void * ma + strlen (".debug") /* The next string should be the same as the longest name found in the prefixes[] array below. */ - + strlen ("/usrlib64/debug/usr") + + strlen ("/usr/lib64/debug/usr/") + 1); void * handle; @@ -12341,7 +12392,7 @@ load_build_id_debug_file (const char * main_filename ATTRIBUTE_UNUSED, void * ma "/usr/lib/debug/", "/usr/lib/debug/usr/", "/usr/lib64/debug/", - "/usr/lib64/debug/usr" + "/usr/lib64/debug/usr/" }; long unsigned int i; @@ -12671,6 +12722,7 @@ static const debug_dump_long_opts debug_option_table[] = /* For compatibility with earlier versions of readelf. */ { 'r', "ranges", &do_debug_aranges, 1 }, { 's', "str", &do_debug_str, 1 }, + { '\0', "sframe-internal-only", &do_sframe, 1 }, { 'T', "trace_aranges", &do_trace_aranges, 1 }, { 't', "pubtypes", &do_debug_pubtypes, 1 }, { 'U', "trace_info", &do_trace_info, 1 }, @@ -12829,6 +12881,7 @@ struct dwarf_section_display debug_displays[] = { { ".debug_weaknames", ".zdebug_weaknames", "", NO_ABBREVS }, display_debug_not_supported, NULL, false }, { { ".gdb_index", "", "", NO_ABBREVS }, display_gdb_index, &do_gdb_index, false }, { { ".debug_names", "", "", NO_ABBREVS }, display_debug_names, &do_gdb_index, false }, + { { ".sframe", "", "", NO_ABBREVS }, display_sframe, &do_sframe, true }, { { ".trace_info", "", "", ABBREV (trace_abbrev) }, display_trace_info, &do_trace_info, true }, { { ".trace_abbrev", "", "", NO_ABBREVS }, display_debug_abbrev, &do_trace_abbrevs, false }, { { ".trace_aranges", "", "", NO_ABBREVS }, display_debug_aranges, &do_trace_aranges, false }, |