/* objdump.c -- dump information about an object file.
- Copyright (C) 1990-2022 Free Software Foundation, Inc.
+ Copyright (C) 1990-2023 Free Software Foundation, Inc.
This file is part of GNU Binutils.
#include "bfd.h"
#include "elf-bfd.h"
#include "coff-bfd.h"
-#include "progress.h"
#include "bucomm.h"
#include "elfcomm.h"
#include "demanguse.h"
#include "dwarf.h"
#include "ctf-api.h"
+#include "sframe-api.h"
#include "getopt.h"
#include "safe-ctype.h"
#include "dis-asm.h"
static int dump_ctf_section_info; /* --ctf */
static char *dump_ctf_section_name;
static char *dump_ctf_parent_name; /* --ctf-parent */
+static int dump_sframe_section_info; /* --sframe */
+static char *dump_sframe_section_name;
static int do_demangle; /* -C, --demangle */
static bool disassemble; /* -d */
static bool disassemble_all; /* -D */
static int disassemble_zeroes; /* --disassemble-zeroes */
static bool formats_info; /* -i */
-static int wide_output; /* -w */
+int wide_output; /* -w */
static int insn_width; /* --insn-width */
static bfd_vma start_address = (bfd_vma) -1; /* --start-address */
static bfd_vma stop_address = (bfd_vma) -1; /* --stop-address */
static bool color_output = false; /* --visualize-jumps=color. */
static bool extended_color_output = false; /* --visualize-jumps=extended-color. */
static int process_links = false; /* --process-links. */
+static int show_all_symbols; /* --show-all-symbols. */
static enum color_selection
{
on, /* --disassembler-color=color. */
off, /* --disassembler-color=off. */
extended /* --disassembler-color=extended-color. */
- } disassembler_color = on_if_terminal_output;
+ } disassembler_color =
+#if DEFAULT_FOR_COLORED_DISASSEMBLY
+ on_if_terminal_output;
+#else
+ off;
+#endif
static int dump_any_debugging;
static int demangle_flags = DMGL_ANSI | DMGL_PARAMS;
fprintf (stream, _("\
--ctf[=SECTION] Display CTF info from SECTION, (default `.ctf')\n"));
#endif
+ fprintf (stream, _("\
+ --sframe[=SECTION] Display SFrame info from SECTION, (default '.sframe')\n"));
fprintf (stream, _("\
-t, --syms Display the contents of the symbol table(s)\n"));
fprintf (stream, _("\
fprintf (stream, _("\
--adjust-vma=OFFSET Add OFFSET to all displayed section addresses\n"));
fprintf (stream, _("\
+ --show-all-symbols When disassembling, display all symbols at a given address\n"));
+ fprintf (stream, _("\
--special-syms Include special symbols in symbol dumps\n"));
fprintf (stream, _("\
--inlines Print all inlines for source line (with -l)\n"));
--visualize-jumps=extended-color\n\
Use extended 8-bit color codes\n"));
fprintf (stream, _("\
- --visualize-jumps=off Disable jump visualization\n\n"));
+ --visualize-jumps=off Disable jump visualization\n"));
+#if DEFAULT_FOR_COLORED_DISASSEMBLY
+ fprintf (stream, _("\
+ --disassembler-color=off Disable disassembler color output.\n"));
fprintf (stream, _("\
- --disassembler-color=off Disable disassembler color output.\n\n"));
+ --disassembler-color=terminal Enable disassembler color output if displaying on a terminal. (default)\n"));
+#else
+ fprintf (stream, _("\
+ --disassembler-color=off Disable disassembler color output. (default)\n"));
fprintf (stream, _("\
- --disassembler-color=color Use basic colors in disassembler output.\n\n"));
+ --disassembler-color=terminal Enable disassembler color output if displaying on a terminal.\n"));
+#endif
fprintf (stream, _("\
- --disassembler-color=extended-color Use 8-bit colors in disassembler output.\n\n"));
+ --disassembler-color=on Enable disassembler color output.\n"));
+ fprintf (stream, _("\
+ --disassembler-color=extended Use 8-bit colors in disassembler output.\n\n"));
list_supported_targets (program_name, stream);
list_supported_architectures (program_name, stream);
OPTION_CTF,
OPTION_CTF_PARENT,
#endif
+ OPTION_SFRAME,
OPTION_VISUALIZE_JUMPS,
OPTION_DISASSEMBLER_COLOR
};
{"reloc", no_argument, NULL, 'r'},
{"section", required_argument, NULL, 'j'},
{"section-headers", no_argument, NULL, 'h'},
+ {"sframe", optional_argument, NULL, OPTION_SFRAME},
+ {"show-all-symbols", no_argument, &show_all_symbols, 1},
{"show-raw-insn", no_argument, &show_raw_insn, 1},
{"source", no_argument, NULL, 'S'},
{"source-comment", optional_argument, NULL, OPTION_SOURCE_COMMENT},
};
\f
static void
-nonfatal (const char *msg)
+my_bfd_nonfatal (const char *msg)
{
bfd_nonfatal (msg);
exit_status = 1;
static asymbol **
slurp_symtab (bfd *abfd)
{
- asymbol **sy = NULL;
- long storage;
-
+ symcount = 0;
if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
- {
- symcount = 0;
- return NULL;
- }
+ return NULL;
- storage = bfd_get_symtab_upper_bound (abfd);
+ long storage = bfd_get_symtab_upper_bound (abfd);
if (storage < 0)
{
- non_fatal (_("failed to read symbol table from: %s"), bfd_get_filename (abfd));
- bfd_fatal (_("error message was"));
+ non_fatal (_("failed to read symbol table from: %s"),
+ bfd_get_filename (abfd));
+ my_bfd_nonfatal (_("error message was"));
}
- if (storage)
- {
- off_t filesize = bfd_get_file_size (abfd);
-
- /* qv PR 24707. */
- if (filesize > 0
- && filesize < storage
- /* The MMO file format supports its own special compression
- technique, so its sections can be larger than the file size. */
- && bfd_get_flavour (abfd) != bfd_target_mmo_flavour)
- {
- bfd_nonfatal_message (bfd_get_filename (abfd), abfd, NULL,
- _("error: symbol table size (%#lx) "
- "is larger than filesize (%#lx)"),
- storage, (long) filesize);
- exit_status = 1;
- symcount = 0;
- return NULL;
- }
-
- sy = (asymbol **) xmalloc (storage);
- }
+ if (storage <= 0)
+ return NULL;
+ asymbol **sy = (asymbol **) xmalloc (storage);
symcount = bfd_canonicalize_symtab (abfd, sy);
if (symcount < 0)
- bfd_fatal (bfd_get_filename (abfd));
+ {
+ my_bfd_nonfatal (bfd_get_filename (abfd));
+ free (sy);
+ sy = NULL;
+ symcount = 0;
+ }
return sy;
}
static asymbol **
slurp_dynamic_symtab (bfd *abfd)
{
- asymbol **sy = NULL;
- long storage;
-
- storage = bfd_get_dynamic_symtab_upper_bound (abfd);
+ dynsymcount = 0;
+ long storage = bfd_get_dynamic_symtab_upper_bound (abfd);
if (storage < 0)
{
if (!(bfd_get_file_flags (abfd) & DYNAMIC))
{
non_fatal (_("%s: not a dynamic object"), bfd_get_filename (abfd));
exit_status = 1;
- dynsymcount = 0;
return NULL;
}
- bfd_fatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
}
- if (storage)
- sy = (asymbol **) xmalloc (storage);
+ if (storage <= 0)
+ return NULL;
+ asymbol **sy = (asymbol **) xmalloc (storage);
dynsymcount = bfd_canonicalize_dynamic_symtab (abfd, sy);
if (dynsymcount < 0)
- bfd_fatal (bfd_get_filename (abfd));
+ {
+ my_bfd_nonfatal (bfd_get_filename (abfd));
+ free (sy);
+ sy = NULL;
+ dynsymcount = 0;
+ }
return sy;
}
return 1;
}
- if (bfd_get_flavour (bfd_asymbol_bfd (a)) == bfd_target_elf_flavour
+ /* Sort larger size ELF symbols before smaller. See PR20337. */
+ bfd_vma asz = 0;
+ if ((a->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0
+ && bfd_get_flavour (bfd_asymbol_bfd (a)) == bfd_target_elf_flavour)
+ asz = ((elf_symbol_type *) a)->internal_elf_sym.st_size;
+ bfd_vma bsz = 0;
+ if ((b->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0
&& bfd_get_flavour (bfd_asymbol_bfd (b)) == bfd_target_elf_flavour)
- {
- bfd_vma asz, bsz;
-
- asz = 0;
- if ((a->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0)
- asz = ((elf_symbol_type *) a)->internal_elf_sym.st_size;
- bsz = 0;
- if ((b->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0)
- bsz = ((elf_symbol_type *) b)->internal_elf_sym.st_size;
- if (asz != bsz)
- return asz > bsz ? -1 : 1;
- }
+ bsz = ((elf_symbol_type *) b)->internal_elf_sym.st_size;
+ if (asz != bsz)
+ return asz > bsz ? -1 : 1;
/* Symbols that start with '.' might be section names, so sort them
after symbols that don't start with '.'. */
#if HAVE_LIBDEBUGINFOD
if (fd < 0 && use_debuginfod && fn[0] == '/' && abfd != NULL)
{
- unsigned char * build_id;
- debuginfod_client * client;
+ unsigned char *build_id = get_build_id (abfd);
- client = debuginfod_begin ();
- if (client == NULL)
- return NULL;
+ if (build_id)
+ {
+ debuginfod_client *client = debuginfod_begin ();
- build_id = get_build_id (abfd);
- fd = debuginfod_find_source (client, build_id, 0, fn, NULL);
- free (build_id);
- debuginfod_end (client);
+ if (client)
+ {
+ fd = debuginfod_find_source (client, build_id, 0, fn, NULL);
+ debuginfod_end (client);
+ }
+ free (build_id);
+ }
}
#endif
next_sym
} loop_until;
- /* Sections that do not contain machine
- code are not normally disassembled. */
- if (! disassemble_all
- && only_list == NULL
- && ((section->flags & (SEC_CODE | SEC_HAS_CONTENTS))
- != (SEC_CODE | SEC_HAS_CONTENTS)))
- return;
+ if (only_list == NULL)
+ {
+ /* Sections that do not contain machine
+ code are not normally disassembled. */
+ if ((section->flags & SEC_HAS_CONTENTS) == 0)
+ return;
- if (! process_section_p (section))
+ if (! disassemble_all
+ && (section->flags & SEC_CODE) == 0)
+ return;
+ }
+ else if (!process_section_p (section))
return;
datasize = bfd_section_size (section);
relsize = bfd_get_reloc_upper_bound (abfd, section);
if (relsize < 0)
- bfd_fatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
if (relsize > 0)
{
- rel_ppstart = rel_pp = (arelent **) xmalloc (relsize);
+ rel_pp = (arelent **) xmalloc (relsize);
rel_count = bfd_canonicalize_reloc (abfd, section, rel_pp, syms);
if (rel_count < 0)
- bfd_fatal (bfd_get_filename (abfd));
-
- /* Sort the relocs by address. */
- qsort (rel_pp, rel_count, sizeof (arelent *), compare_relocs);
+ {
+ my_bfd_nonfatal (bfd_get_filename (abfd));
+ free (rel_pp);
+ rel_pp = NULL;
+ rel_count = 0;
+ }
+ else if (rel_count > 1)
+ /* Sort the relocs by address. */
+ qsort (rel_pp, rel_count, sizeof (arelent *), compare_relocs);
+ rel_ppstart = rel_pp;
}
}
}
{
do_print = true;
+ /* Skip over the relocs belonging to addresses below the
+ symbol address. */
+ const bfd_vma sym_offset = bfd_asymbol_value (sym) - section->vma;
+ while (rel_pp < rel_ppend &&
+ (*rel_pp)->address - rel_offset < sym_offset)
+ ++rel_pp;
+
if (sym->flags & BSF_FUNCTION)
{
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
objdump_print_addr_with_sym (abfd, section, sym, addr,
pinfo, false);
pinfo->fprintf_func (pinfo->stream, ":\n");
+
+ if (sym != NULL && show_all_symbols)
+ {
+ for (++place; place < sorted_symcount; place++)
+ {
+ sym = sorted_syms[place];
+
+ if (bfd_asymbol_value (sym) != addr)
+ break;
+ if (! pinfo->symbol_is_valid (sym, pinfo))
+ continue;
+ if (strcmp (bfd_section_name (sym->section), bfd_section_name (section)) != 0)
+ break;
+
+ objdump_print_addr_with_sym (abfd, section, sym, addr, pinfo, false);
+ pinfo->fprintf_func (pinfo->stream, ":\n");
+ }
+ }
}
if (sym != NULL && bfd_asymbol_value (sym) > addr)
const bfd_arch_info_type *inf = bfd_scan_arch (machine);
if (inf == NULL)
- fatal (_("can't use supplied machine %s"), machine);
-
- abfd->arch_info = inf;
+ {
+ non_fatal (_("can't use supplied machine %s"), machine);
+ exit_status = 1;
+ }
+ else
+ abfd->arch_info = inf;
}
if (endian != BFD_ENDIAN_UNKNOWN)
/* Pre-load the dynamic relocs as we may need them during the disassembly. */
long relsize = bfd_get_dynamic_reloc_upper_bound (abfd);
- if (relsize < 0 && dump_dynamic_reloc_info)
- bfd_fatal (bfd_get_filename (abfd));
-
if (relsize > 0)
{
disasm_info.dynrelbuf = (arelent **) xmalloc (relsize);
disasm_info.dynrelcount
= bfd_canonicalize_dynamic_reloc (abfd, disasm_info.dynrelbuf, dynsyms);
if (disasm_info.dynrelcount < 0)
- bfd_fatal (bfd_get_filename (abfd));
-
- /* Sort the relocs by address. */
- qsort (disasm_info.dynrelbuf, disasm_info.dynrelcount, sizeof (arelent *),
- compare_relocs);
+ {
+ my_bfd_nonfatal (bfd_get_filename (abfd));
+ free (disasm_info.dynrelbuf);
+ disasm_info.dynrelbuf = NULL;
+ disasm_info.dynrelcount = 0;
+ }
+ else if (disasm_info.dynrelcount > 1)
+ /* Sort the relocs by address. */
+ qsort (disasm_info.dynrelbuf, disasm_info.dynrelcount,
+ sizeof (arelent *), compare_relocs);
}
disasm_info.symtab = sorted_syms;
section->size = bfd_section_size (sec);
/* PR 24360: On 32-bit hosts sizeof (size_t) < sizeof (bfd_size_type). */
alloced = amt = section->size + 1;
- if (alloced != amt || alloced == 0)
+ if (alloced != amt
+ || alloced == 0
+ || (bfd_get_size (abfd) != 0 && alloced >= bfd_get_size (abfd)))
{
section->start = NULL;
free_debug_section (debug);
- printf (_("\nSection '%s' has an invalid size: %#llx.\n"),
+ printf (_("\nSection '%s' has an invalid size: %#" PRIx64 ".\n"),
sanitize_string (section->name),
- (unsigned long long) section->size);
+ section->size);
return false;
}
if (reloc_size > 0)
{
- unsigned long reloc_count;
+ long reloc_count;
arelent **relocs;
relocs = (arelent **) xmalloc (reloc_size);
- reloc_count = bfd_canonicalize_reloc (abfd, sec, relocs, NULL);
- if (reloc_count == 0)
+ reloc_count = bfd_canonicalize_reloc (abfd, sec, relocs, syms);
+ if (reloc_count <= 0)
free (relocs);
else
{
bfd_map_over_sections (abfd, dump_dwarf_section, (void *) &is_mainfile);
}
\f
-/* Read ABFD's stabs section STABSECT_NAME, and return a pointer to
- it. Return NULL on failure. */
+/* Read ABFD's section SECT_NAME into *CONTENTS, and return a pointer to
+ the section. Return NULL on failure. */
-static bfd_byte *
-read_section_stabs (bfd *abfd, const char *sect_name, bfd_size_type *size_ptr,
- bfd_size_type *entsize_ptr)
+static asection *
+read_section (bfd *abfd, const char *sect_name, bfd_byte **contents)
{
- asection *stabsect;
- bfd_byte *contents;
-
- stabsect = bfd_get_section_by_name (abfd, sect_name);
- if (stabsect == NULL)
- {
- printf (_("No %s section present\n\n"),
- sanitize_string (sect_name));
- return false;
- }
+ asection *sec;
- if (!bfd_malloc_and_get_section (abfd, stabsect, &contents))
+ *contents = NULL;
+ sec = bfd_get_section_by_name (abfd, sect_name);
+ if (sec == NULL)
{
- non_fatal (_("reading %s section of %s failed: %s"),
- sect_name, bfd_get_filename (abfd),
- bfd_errmsg (bfd_get_error ()));
- exit_status = 1;
- free (contents);
+ printf (_("No %s section present\n\n"), sanitize_string (sect_name));
return NULL;
}
- *size_ptr = bfd_section_size (stabsect);
- if (entsize_ptr)
- *entsize_ptr = stabsect->entsize;
+ if ((bfd_section_flags (sec) & SEC_HAS_CONTENTS) == 0)
+ bfd_set_error (bfd_error_no_contents);
+ else if (bfd_malloc_and_get_section (abfd, sec, contents))
+ return sec;
- return contents;
+ non_fatal (_("reading %s section of %s failed: %s"),
+ sect_name, bfd_get_filename (abfd),
+ bfd_errmsg (bfd_get_error ()));
+ exit_status = 1;
+ return NULL;
}
/* Stabs entries use a 12 byte format:
bfd_byte *stabp, *stabs_end;
stabp = stabs;
- stabs_end = stabp + stab_size;
+ stabs_end = PTR_ADD (stabp, stab_size);
printf (_("Contents of %s section:\n\n"), sanitize_string (stabsect_name));
printf ("Symnum n_type n_othr n_desc n_value n_strx String\n");
We start the index at -1 because there is a dummy symbol on
the front of stabs-in-{coff,elf} sections that supplies sizes. */
- for (i = -1; stabp <= stabs_end - STABSIZE; stabp += STABSIZE, i++)
+ for (i = -1; (size_t) (stabs_end - stabp) >= STABSIZE; stabp += STABSIZE, i++)
{
const char *name;
unsigned long strx;
&& (section->name[len] == 0
|| (section->name[len] == '.' && ISDIGIT (section->name[len + 1]))))
{
+ asection *s;
if (strtab == NULL)
- strtab = read_section_stabs (abfd, sought->string_section_name,
- &stabstr_size, NULL);
+ {
+ s = read_section (abfd, sought->string_section_name, &strtab);
+ if (s != NULL)
+ stabstr_size = bfd_section_size (s);
+ }
if (strtab)
{
- stabs = read_section_stabs (abfd, section->name, &stab_size, NULL);
- if (stabs)
- print_section_stabs (abfd, section->name, &sought->string_offset);
+ s = read_section (abfd, section->name, &stabs);
+ if (s != NULL)
+ {
+ stab_size = bfd_section_size (s);
+ print_section_stabs (abfd, section->name, &sought->string_offset);
+ free (stabs);
+ }
}
}
}
static void
dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
{
+ asection *sec;
ctf_archive_t *ctfa = NULL;
- bfd_byte *ctfdata = NULL;
- bfd_size_type ctfsize;
+ bfd_byte *ctfdata;
ctf_sect_t ctfsect;
ctf_dict_t *parent;
ctf_dict_t *fp;
if (sect_name == NULL)
sect_name = ".ctf";
- if ((ctfdata = read_section_stabs (abfd, sect_name, &ctfsize, NULL)) == NULL)
- bfd_fatal (bfd_get_filename (abfd));
+ sec = read_section (abfd, sect_name, &ctfdata);
+ if (sec == NULL)
+ {
+ my_bfd_nonfatal (bfd_get_filename (abfd));
+ return;
+ }
/* Load the CTF file and dump it. Preload the parent dict, since it will
need to be imported into every child in turn. */
- ctfsect = make_ctfsect (sect_name, ctfdata, ctfsize);
+ ctfsect = make_ctfsect (sect_name, ctfdata, bfd_section_size (sec));
if ((ctfa = ctf_bfdopen_ctfsect (abfd, &ctfsect, &err)) == NULL)
{
dump_ctf_errs (NULL);
non_fatal (_("CTF open failure: %s"), ctf_errmsg (err));
- bfd_fatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
+ free (ctfdata);
+ return;
}
if ((parent = ctf_dict_open (ctfa, parent_name, &err)) == NULL)
{
dump_ctf_errs (NULL);
non_fatal (_("CTF open failure: %s"), ctf_errmsg (err));
- bfd_fatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
+ ctf_close (ctfa);
+ free (ctfdata);
+ return;
}
printf (_("Contents of CTF section %s:\n"), sanitize_string (sect_name));
{
dump_ctf_errs (NULL);
non_fatal (_("CTF archive member open failure: %s"), ctf_errmsg (err));
- bfd_fatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
}
ctf_dict_close (parent);
ctf_close (ctfa);
const char *parent_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);
+
+ /* Decode the contents of the section. */
+ sfd_ctx = sframe_decode ((const char*)sframe_data, sf_size, &err);
+ if (!sfd_ctx)
+ {
+ my_bfd_nonfatal (bfd_get_filename (abfd));
+ free (sframe_data);
+ 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);
+}
+
\f
static void
dump_bfd_private_header (bfd *abfd)
int count;
int width;
- if (! process_section_p (section))
- return;
-
- if ((section->flags & SEC_HAS_CONTENTS) == 0)
+ if (only_list == NULL)
+ {
+ if ((section->flags & SEC_HAS_CONTENTS) == 0)
+ return;
+ }
+ else if (!process_section_p (section))
return;
if ((datasize = bfd_section_size (section)) == 0)
asection *section,
void *dummy ATTRIBUTE_UNUSED)
{
- arelent **relpp = NULL;
+ arelent **relpp;
long relcount;
long relsize;
}
if (relsize < 0)
- relcount = relsize;
+ {
+ relpp = NULL;
+ relcount = relsize;
+ }
else
{
relpp = (arelent **) xmalloc (relsize);
printf ("\n");
non_fatal (_("failed to read relocs in: %s"),
sanitize_string (bfd_get_filename (abfd)));
- bfd_fatal (_("error message was"));
+ my_bfd_nonfatal (_("error message was"));
}
else if (relcount == 0)
printf (" (none)\n\n");
long relcount;
relsize = bfd_get_dynamic_reloc_upper_bound (abfd);
- if (relsize < 0)
- bfd_fatal (bfd_get_filename (abfd));
printf ("DYNAMIC RELOCATION RECORDS");
if (relsize == 0)
- printf (" (none)\n\n");
+ {
+ printf (" (none)\n\n");
+ return;
+ }
+
+ if (relsize < 0)
+ {
+ relpp = NULL;
+ relcount = relsize;
+ }
else
{
relpp = (arelent **) xmalloc (relsize);
relcount = bfd_canonicalize_dynamic_reloc (abfd, relpp, dynsyms);
+ }
- if (relcount < 0)
- bfd_fatal (bfd_get_filename (abfd));
- else if (relcount == 0)
- printf (" (none)\n\n");
- else
- {
- printf ("\n");
- dump_reloc_set (abfd, NULL, relpp, relcount);
- printf ("\n\n");
- }
- free (relpp);
+ if (relcount < 0)
+ {
+ printf ("\n");
+ non_fatal (_("failed to read relocs in: %s"),
+ sanitize_string (bfd_get_filename (abfd)));
+ my_bfd_nonfatal (_("error message was"));
+ }
+ else if (relcount == 0)
+ printf (" (none)\n\n");
+ else
+ {
+ printf ("\n");
+ dump_reloc_set (abfd, NULL, relpp, relcount);
+ printf ("\n\n");
}
+ free (relpp);
}
/* Creates a table of paths, to search for source files. */
{
if (dump_ctf_section_info)
dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name);
+ if (dump_sframe_section_info)
+ dump_section_sframe (abfd, dump_sframe_section_name);
if (dump_stab_section_info)
dump_stabs (abfd);
if (dump_reloc_info && ! disassemble)
bfd_get_filename (abfd));
exit_status = 1;
}
-
- free (dhandle);
}
/* PR 6483: If there was no STABS debug info in the file, try
DWARF instead. */
if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
{
- nonfatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
list_matching_formats (matching);
return;
}
if (bfd_get_error () != bfd_error_file_not_recognized)
{
- nonfatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
return;
}
return;
}
- nonfatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
list_matching_formats (matching);
{
/* Prevent corrupted files from spinning us into an
infinite loop. 100 is an arbitrary heuristic. */
- fatal (_("Archive nesting is too deep"));
+ non_fatal (_("Archive nesting is too deep"));
+ exit_status = 1;
return;
}
else
if (arfile == NULL)
{
if (bfd_get_error () != bfd_error_no_more_archived_files)
- nonfatal (bfd_get_filename (file));
+ my_bfd_nonfatal (bfd_get_filename (file));
break;
}
file = bfd_openr (filename, target);
if (file == NULL)
{
- nonfatal (filename);
+ my_bfd_nonfatal (filename);
return;
}
xmalloc_set_program_name (program_name);
bfd_set_error_program_name (program_name);
- START_PROGRESS (program_name, 0);
-
expandargv (&argc, &argv);
if (bfd_init () != BFD_INIT_MAGIC)
else if (streq (optarg, "off"))
visualize_jumps = false;
else
- nonfatal (_("unrecognized argument to --visualize-option"));
+ {
+ non_fatal (_("unrecognized argument to --visualize-option"));
+ usage (stderr, 1);
+ }
}
break;
case OPTION_DISASSEMBLER_COLOR:
if (streq (optarg, "off"))
disassembler_color = off;
- else if (streq (optarg, "color"))
+ else if (streq (optarg, "terminal"))
+ disassembler_color = on_if_terminal_output;
+ else if (streq (optarg, "color")
+ || streq (optarg, "colour")
+ || streq (optarg, "on"))
disassembler_color = on;
- else if (streq (optarg, "extended-color"))
+ else if (streq (optarg, "extended")
+ || streq (optarg, "extended-color")
+ || streq (optarg, "extended-colour"))
disassembler_color = extended;
else
- nonfatal (_("unrecognized argument to --disassembler-color"));
+ {
+ non_fatal (_("unrecognized argument to --disassembler-color"));
+ usage (stderr, 1);
+ }
break;
case 'E':
if (strcmp (optarg, "B") == 0)
endian = BFD_ENDIAN_LITTLE;
else
{
- nonfatal (_("unrecognized -E option"));
+ non_fatal (_("unrecognized -E option"));
usage (stderr, 1);
}
break;
else
{
non_fatal (_("unrecognized --endian type `%s'"), optarg);
- exit_status = 1;
usage (stderr, 1);
}
break;
dump_ctf_parent_name = xstrdup (optarg);
break;
#endif
+ case OPTION_SFRAME:
+ dump_sframe_section_info = true;
+ if (optarg)
+ dump_sframe_section_name = xstrdup (optarg);
+ seenflag = true;
+ break;
case 'G':
dump_stab_section_info = true;
seenflag = true;
free (dump_ctf_parent_name);
free ((void *) source_comment);
- END_PROGRESS (program_name);
-
return exit_status;
}