/* objdump.c -- dump information about an object file.
- Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
This file is part of GNU Binutils.
#include "debug.h"
#include "budbg.h"
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
/* Internal headers for the ELF .stab-dump code - sorry. */
#define BYTES_IN_WORD 32
#include "aout/aout64.h"
FILE *stream;
int status;
{
- fprintf (stream, _("Usage: %s <switches> file(s)\n"), program_name);
- fprintf (stream, _(" At least one of the following switches must be given:\n"));
+ fprintf (stream, _("Usage: %s OPTION... FILE...\n"), program_name);
+ fprintf (stream, _("Display information from object FILE.\n"));
+ fprintf (stream, _("\n At least one of the following switches must be given:\n"));
fprintf (stream, _("\
- -a --archive-headers Display archive header information\n\
- -f --file-headers Display the contents of the overall file header\n\
- -p --private-headers Display object format specific file header contents\n\
- -h --[section-]headers Display the contents of the section headers\n\
- -x --all-headers Display the contents of all headers\n\
- -d --disassemble Display assembler contents of executable sections\n\
- -D --disassemble-all Display assembler contents of all sections\n\
- -S --source Intermix source code with disassembly\n\
- -s --full-contents Display the full contents of all sections requested\n\
- -g --debugging Display debug information in object file\n\
- -G --stabs Display the STABS contents of an ELF format file\n\
- -t --syms Display the contents of the symbol table(s)\n\
- -T --dynamic-syms Display the contents of the dynamic symbol table\n\
- -r --reloc Display the relocation entries in the file\n\
- -R --dynamic-reloc Display the dynamic relocation entries in the file\n\
- -V --version Display this program's version number\n\
- -i --info List object formats and architectures supported\n\
- -H --help Display this information\n\
+ -a, --archive-headers Display archive header information\n\
+ -f, --file-headers Display the contents of the overall file header\n\
+ -p, --private-headers Display object format specific file header contents\n\
+ -h, --[section-]headers Display the contents of the section headers\n\
+ -x, --all-headers Display the contents of all headers\n\
+ -d, --disassemble Display assembler contents of executable sections\n\
+ -D, --disassemble-all Display assembler contents of all sections\n\
+ -S, --source Intermix source code with disassembly\n\
+ -s, --full-contents Display the full contents of all sections requested\n\
+ -g, --debugging Display debug information in object file\n\
+ -G, --stabs Display (in raw form) any STABS info in the file\n\
+ -t, --syms Display the contents of the symbol table(s)\n\
+ -T, --dynamic-syms Display the contents of the dynamic symbol table\n\
+ -r, --reloc Display the relocation entries in the file\n\
+ -R, --dynamic-reloc Display the dynamic relocation entries in the file\n\
+ -V, --version Display this program's version number\n\
+ -i, --info List object formats and architectures supported\n\
+ -H, --help Display this information\n\
"));
if (status != 2)
{
fprintf (stream, _("\n The following switches are optional:\n"));
fprintf (stream, _("\
- -b --target <bfdname> Specify the target object format as <bfdname>\n\
- -m --architecture <machine> Specify the target architecture as <machine>\n\
- -j --section <name> Only display information for section <name>\n\
- -M --disassembler-options <o> Pass text <o> on to the disassembler\n\
+ -b, --target=BFDNAME Specify the target object format as BFDNAME\n\
+ -m, --architecture=MACHINE Specify the target architecture as MACHINE\n\
+ -j, --section=NAME Only display information for section NAME\n\
+ -M, --disassembler-options=OPT Pass text OPT on to the disassembler\n\
-EB --endian=big Assume big endian format when disassembling\n\
-EL --endian=little Assume little endian format when disassembling\n\
--file-start-context Include context from start of file (with -S)\n\
- -l --line-numbers Include line numbers and filenames in output\n\
- -C --demangle Decode mangled/processed symbol names\n\
- -w --wide Format output for more than 80 columns\n\
- -z --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\
- --start-address <addr> Only process data whoes address is >= <addr>\n\
- --stop-address <addr> Only process data whoes address is <= <addr>\n\
+ -l, --line-numbers Include line numbers and filenames in output\n\
+ -C, --demangle[=STYLE] Decode mangled/processed symbol names\n\
+ The STYLE, if specified, can be `auto', 'gnu',\n\
+ 'lucid', 'arm', 'hp', 'edg', or 'gnu-new-abi'\n\
+ -w, --wide Format output for more than 80 columns\n\
+ -z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\
+ --start-address=ADDR Only process data whoes address is >= ADDR\n\
+ --stop-address=ADDR Only process data whoes address is <= ADDR\n\
--prefix-addresses Print complete address alongside disassembly\n\
--[no-]show-raw-insn Display hex alongside symbolic disassembly\n\
- --adjust-vma <offset> Add <offset> to all displayed section addresses\n\
+ --adjust-vma=OFFSET Add OFFSET to all displayed section addresses\n\
\n"));
list_supported_targets (program_name, stream);
-
+
disassembler_usage (stream);
}
if (status == 0)
- fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO);
+ fprintf (stream, _("Report bugs to %s.\n"), REPORT_BUGS_TO);
exit (status);
}
{"architecture", required_argument, NULL, 'm'},
{"archive-headers", no_argument, NULL, 'a'},
{"debugging", no_argument, NULL, 'g'},
- {"demangle", no_argument, NULL, 'C'},
+ {"demangle", optional_argument, NULL, 'C'},
{"disassemble", no_argument, NULL, 'd'},
{"disassemble-all", no_argument, NULL, 'D'},
{"disassembler-options", required_argument, NULL, 'M'},
if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
{
- fprintf (stderr, _("%s: no symbols\n"), bfd_get_filename (abfd));
+ non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
symcount = 0;
return NULL;
}
if (symcount < 0)
bfd_fatal (bfd_get_filename (abfd));
if (symcount == 0)
- fprintf (stderr, _("%s: no symbols\n"), bfd_get_filename (abfd));
+ non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
return sy;
}
{
if (!(bfd_get_file_flags (abfd) & DYNAMIC))
{
- fprintf (stderr, _("%s: %s: not a dynamic object\n"),
- program_name, bfd_get_filename (abfd));
+ non_fatal (_("%s: not a dynamic object"), bfd_get_filename (abfd));
dynsymcount = 0;
return NULL;
}
if (dynsymcount < 0)
bfd_fatal (bfd_get_filename (abfd));
if (dynsymcount == 0)
- fprintf (stderr, _("%s: %s: No dynamic symbols\n"),
- program_name, bfd_get_filename (abfd));
+ non_fatal (_("%s: No dynamic symbols"), bfd_get_filename (abfd));
return sy;
}
if (buf == NULL)
{
- fprintf (stderr, _("Out of virtual memory\n"));
- exit (1);
+ fatal (_("Out of virtual memory"));
}
n = strlen (buf);
struct disassemble_info disasm_info;
struct objdump_disasm_info aux;
asection *section;
- unsigned int opb = bfd_octets_per_byte (abfd);
+ unsigned int opb;
print_files = NULL;
prev_functionname = NULL;
aux.require_sec = false;
disasm_info.print_address_func = objdump_print_address;
disasm_info.symbol_at_address_func = objdump_symbol_at_address;
- disasm_info.octets_per_byte = opb;
if (machine != (char *) NULL)
{
const bfd_arch_info_type *info = bfd_scan_arch (machine);
if (info == NULL)
{
- fprintf (stderr, _("%s: Can't use supplied machine %s\n"),
- program_name,
- machine);
- exit (1);
+ fatal (_("Can't use supplied machine %s"), machine);
}
abfd->arch_info = info;
}
disassemble_fn = disassembler (abfd);
if (!disassemble_fn)
{
- fprintf (stderr, _("%s: Can't disassemble for architecture %s\n"),
- program_name,
- bfd_printable_arch_mach (bfd_get_arch (abfd), 0));
+ non_fatal (_("Can't disassemble for architecture %s\n"),
+ bfd_printable_arch_mach (bfd_get_arch (abfd), 0));
exit_status = 1;
return;
}
+ opb = bfd_octets_per_byte (abfd);
+
disasm_info.flavour = bfd_get_flavour (abfd);
disasm_info.arch = bfd_get_arch (abfd);
disasm_info.mach = bfd_get_mach (abfd);
disasm_info.disassembler_options = disassembler_options;
+ disasm_info.octets_per_byte = opb;
if (bfd_big_endian (abfd))
disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_BIG;
stabstrsect = bfd_get_section_by_name (abfd, strsect_name);
if (0 == stabstrsect)
{
- fprintf (stderr, _("%s: %s has no %s section\n"), program_name,
- bfd_get_filename (abfd), strsect_name);
+ non_fatal (_("%s has no %s section"),
+ bfd_get_filename (abfd), strsect_name);
exit_status = 1;
return false;
}
if (! bfd_get_section_contents (abfd, stabsect, (PTR) stabs, 0, stab_size))
{
- fprintf (stderr, _("%s: Reading %s section of %s failed: %s\n"),
- program_name, stabsect_name, bfd_get_filename (abfd),
- bfd_errmsg (bfd_get_error ()));
+ non_fatal (_("Reading %s section of %s failed: %s"),
+ stabsect_name, bfd_get_filename (abfd),
+ bfd_errmsg (bfd_get_error ()));
free (stabs);
free (strtab);
exit_status = 1;
if (! bfd_get_section_contents (abfd, stabstrsect, (PTR) strtab, 0,
stabstr_size))
{
- fprintf (stderr, _("%s: Reading %s section of %s failed: %s\n"),
- program_name, strsect_name, bfd_get_filename (abfd),
- bfd_errmsg (bfd_get_error ()));
+ non_fatal (_("Reading %s section of %s failed: %s\n"),
+ strsect_name, bfd_get_filename (abfd),
+ bfd_errmsg (bfd_get_error ()));
free (stabs);
free (strtab);
exit_status = 1;
{
if (! print_debugging_info (stdout, dhandle))
{
- fprintf (stderr,
- _("%s: printing debugging information failed\n"),
- bfd_get_filename (abfd));
+ non_fatal (_("%s: printing debugging information failed"),
+ bfd_get_filename (abfd));
exit_status = 1;
}
}
char *dummy_name;
int t;
- dummy_name = choose_temp_base ();
+ dummy_name = make_temp_file (NULL);
for (t = 0; bfd_target_vector[t]; t++)
{
bfd_target *p = bfd_target_vector[t];
{
if (bfd_get_error () != bfd_error_invalid_operation)
nonfatal (p->name);
+ bfd_close_all_done (abfd);
continue;
}
if (bfd_set_arch_mach (abfd, (enum bfd_architecture) a, 0))
printf (" %s\n",
bfd_printable_arch_mach ((enum bfd_architecture) a, 0));
+ bfd_close_all_done (abfd);
}
unlink (dummy_name);
free (dummy_name);
printf ("%s ", bfd_target_vector[t]->name);
putchar ('\n');
- dummy_name = choose_temp_base ();
+ dummy_name = make_temp_file (NULL);
for (a = (int) bfd_arch_obscure + 1; a < (int) bfd_arch_last; a++)
if (strcmp (bfd_printable_arch_mach (a, 0), "UNKNOWN!") != 0)
{
putchar ('-');
putchar (' ');
}
+ if (abfd != NULL)
+ bfd_close_all_done (abfd);
}
putchar ('\n');
}
break;
case 'C':
do_demangle = true;
+ if (optarg != NULL)
+ {
+ enum demangling_styles style;
+
+ style = cplus_demangle_name_to_style (optarg);
+ if (style == unknown_demangling)
+ fatal (_("unknown demangling style `%s'"),
+ optarg);
+
+ cplus_demangle_set_style (style);
+ }
break;
case 'w':
wide_output = true;
endian = BFD_ENDIAN_LITTLE;
else
{
- fprintf (stderr, _("%s: unrecognized -E option\n"),
- program_name);
+ non_fatal (_("unrecognized -E option"));
usage (stderr, 1);
}
break;
endian = BFD_ENDIAN_LITTLE;
else
{
- fprintf (stderr, _("%s: unrecognized --endian type `%s'\n"),
- program_name, optarg);
+ non_fatal (_("unrecognized --endian type `%s'"), optarg);
usage (stderr, 1);
}
break;