diff options
Diffstat (limited to 'binutils/objdump.c')
-rw-r--r-- | binutils/objdump.c | 79 |
1 files changed, 35 insertions, 44 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c index 8fdbe03..7bb6d76 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -4206,12 +4206,12 @@ disassemble_data (bfd *abfd) abfd->arch_info = inf; } + const struct bfd_target *old_xvec = NULL; if (endian != BFD_ENDIAN_UNKNOWN) { - struct bfd_target *xvec; - - xvec = (struct bfd_target *) xmalloc (sizeof (struct bfd_target)); - memcpy (xvec, abfd->xvec, sizeof (struct bfd_target)); + struct bfd_target *xvec = xmalloc (sizeof (*xvec)); + old_xvec = abfd->xvec; + memcpy (xvec, old_xvec, sizeof (*xvec)); xvec->byteorder = endian; abfd->xvec = xvec; } @@ -4225,8 +4225,7 @@ disassemble_data (bfd *abfd) non_fatal (_("can't disassemble for architecture %s\n"), bfd_printable_arch_mach (bfd_get_arch (abfd), 0)); exit_status = 1; - free (sorted_syms); - return; + goto out; } disasm_info.flavour = bfd_get_flavour (abfd); @@ -4280,8 +4279,15 @@ disassemble_data (bfd *abfd) free (disasm_info.dynrelbuf); disasm_info.dynrelbuf = NULL; - free (sorted_syms); disassemble_free_target (&disasm_info); + out: + free (sorted_syms); + sorted_syms = NULL; + if (old_xvec) + { + free ((void *) abfd->xvec); + abfd->xvec = old_xvec; + } } static bool @@ -4981,44 +4987,20 @@ dump_ctf (bfd *abfd ATTRIBUTE_UNUSED, const char *sect_name ATTRIBUTE_UNUSED, #endif static void -dump_section_sframe (bfd *abfd ATTRIBUTE_UNUSED, - const char * sect_name) -{ - asection *sec; - sframe_decoder_ctx *sfd_ctx = NULL; - bfd_size_type sf_size; - bfd_byte *sframe_data; - bfd_vma sf_vma; - int err = 0; - - if (sect_name == NULL) - sect_name = ".sframe"; - - sec = read_section (abfd, sect_name, &sframe_data); - if (sec == NULL) - { - my_bfd_nonfatal (bfd_get_filename (abfd)); - return; - } - sf_size = bfd_section_size (sec); - sf_vma = bfd_section_vma (sec); +dump_sframe_section (bfd *abfd, const char *sect_name, bool is_mainfile) - /* Decode the contents of the section. */ - sfd_ctx = sframe_decode ((const char*)sframe_data, sf_size, &err); - if (!sfd_ctx) +{ + /* Error checking for user provided SFrame section name, if any. */ + if (sect_name) { - my_bfd_nonfatal (bfd_get_filename (abfd)); - free (sframe_data); - return; + asection *sec = bfd_get_section_by_name (abfd, sect_name); + if (sec == NULL) + { + printf (_("No %s section present\n\n"), sanitize_string (sect_name)); + return; + } } - - printf (_("Contents of the SFrame section %s:"), - sanitize_string (sect_name)); - /* Dump the contents as text. */ - dump_sframe (sfd_ctx, sf_vma); - - sframe_decoder_free (&sfd_ctx); - free (sframe_data); + dump_dwarf (abfd, is_mainfile); } @@ -5840,7 +5822,7 @@ dump_bfd (bfd *abfd, bool is_mainfile) dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name, dump_ctf_parent_section_name); if (dump_sframe_section_info) - dump_section_sframe (abfd, dump_sframe_section_name); + dump_sframe_section (abfd, dump_sframe_section_name, is_mainfile); if (dump_stab_section_info) dump_stabs (abfd); if (dump_reloc_info && ! disassemble) @@ -6304,7 +6286,9 @@ main (int argc, char **argv) seenflag = true; if (optarg) { - if (dwarf_select_sections_by_names (optarg)) + if (strcmp (optarg, "sframe-internal-only") == 0) + warn (_("Unrecognized debug option 'sframe-internal-only'\n")); + else if (dwarf_select_sections_by_names (optarg)) dump_dwarf_section_info = true; } else @@ -6345,8 +6329,15 @@ main (int argc, char **argv) #endif case OPTION_SFRAME: dump_sframe_section_info = true; + if (optarg) dump_sframe_section_name = xstrdup (optarg); + + /* Error checking for user-provided section name is done in + dump_sframe_section (). Initialize for now with the default + internal name: "sframe-internal-only". */ + dwarf_select_sections_by_names ("sframe-internal-only"); + seenflag = true; break; case 'G': |