This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: objdump: display short option names with --help
- To: ian at zembu dot com
- Subject: Re: objdump: display short option names with --help
- From: Nick Clifton <nickc at cygnus dot com>
- Date: Sat, 20 Nov 1999 15:20:24 GMT
- CC: binutils at sourceware dot cygnus dot com
- Reply-to: nickc at cygnus dot co dot uk
Hi Ian,
: 1999-11-19 Nick Clifton <nickc@cygnus.com>
:
: * objdump.c (usage): Include short options in output.
:
: The short options are listed at the start of the usage string. Moving
: each short option into the corresponding long option is fine with me.
: But please also move each such option out of the list at the start of
: the usage string.
:
: objdump and objcopy have gotten so many options that we may want to go
: to an output format more like that of ld --help.
Actually I quite agree with you. So here is a reworked patch that
totally overhauls the --help output for objdump. With this patch
applied, the output looks like this:
-------------------------------------------------------------------------
Usage: ./objdump <switches> file(s)
At least one of the following switches must be given:
-a --archive-headers Display archive header information
-f --file-headers Display the contents of the overall file header
-p --private-headers Display object format specific file header contents
-h --[section-]headers Display the contents of the section headers
-x --all-headers Display the contents of all headers
-d --disassemble Display assembler contents of executable sections
-D --disassemble-all Display assembler contents of all sections
-S --source Intermix source code with disassembly
-s --full-contents Display the full contents of all sections requested
-g --debugging Display debug information in object file
-G --stabs Display the STABS contents of an ELF format file
-t --syms Display the contents of the symbol table(s)
-T --dynamic-syms Display the contents of the dynamic symbol table
-r --reloc Display the relocation entries in the file
-R --dynamic-reloc Display the dynamic relocation entries in the file
-V --version Display this program's version number
-i --info List object formats and architectures supported
-H --help Display this information
The following switches are optional:
-b --target <bfdname> Specify the target object format as <bfdname>
-m --architecture <machine> Specify the target architecture as <machine>
-j --section <name> Only display information for section <name>
-M --disassembler-options <o> Pass text <o> on to the disassembler
-EB --endian=big Assume big endian format when disassembling
-EL --endian=little Assume little endian format when disassembling
-l --line-numbers Include line numbers and filenames in output
-C --demangle Decode mangled/processed symbol names
-w --wide Format output for more than 80 columns
-z --disassemble-zeroes Do not skip blocks of zeroes when disassembling
--start-address <addr> Only process data whoes address is >= <addr>
--stop-address <addr> Only process data whoes address is <= <addr>
--prefix-addresses Print complete address alongside disassembly
--[no-]show-raw-insn Display hex alongside symbolic disassembly
--adjust-vma <offset> Add <offset> to all displayed section addresses
./objdump: supported targets: elf32-littlearm elf32-bigarm elf32-little elf32-big srec symbolsrec tekhex binary ihex
Report bugs to bug-gnu-utils@gnu.org
-------------------------------------------------------------------------
What do you think - shall I apply this version instead ?
Cheers
Nick
1999-11-20 Nick Clifton <nickc@cygnus.com>
* objdump.c (usage): Overhaul output: One line per switch.
Textual description of each switch. Distinguish between
optional switches and required switches.
(long_options): Add 'g', 'G' and 'z' short options.
(main): Distinguish between optional switches and required
switches.
* binutils.texi: Add -g -G and -z short options for
--debugging, --stabs and --disassemble-zeroes.
Index: objdump.c
===================================================================
RCS file: /cvs/binutils/binutils/binutils/objdump.c,v
retrieving revision 1.13
diff -p -r1.13 objdump.c
*** objdump.c 1999/10/28 03:30:13 1.13
--- objdump.c 1999/11/20 15:15:10
*************** usage (stream, status)
*** 225,247 ****
FILE *stream;
int status;
{
fprintf (stream, _("\
! Usage: %s [-ahifCdDprRtTxsSlw] [-b bfdname] [-m machine] \n\
! [-j section-name] [-M disassembler-options]\n\
! [--archive-headers] [--target=bfdname] [--debugging] [--disassemble]\n\
! [--disassemble-all] [--disassemble-zeroes] [--file-headers]\n\
! [--section-headers] [--headers]\n\
! [--info] [--section=section-name] [--line-numbers] [--source]\n"),
! program_name);
! fprintf (stream, _("\
! [--architecture=machine] [--reloc] [--full-contents] [--stabs]\n\
! [--syms] [--all-headers] [--dynamic-syms] [--dynamic-reloc]\n\
! [--wide] [--version] [--help] [--private-headers]\n\
! [--start-address=addr] [--stop-address=addr]\n\
! [--prefix-addresses] [--[no-]show-raw-insn] [--demangle]\n\
! [--adjust-vma=offset] [-EB|-EL] [--endian={big|little}] objfile...\n\
! at least one option besides -l (--line-numbers) must be given\n"));
! list_supported_targets (program_name, stream);
if (status == 0)
fprintf (stream, _("Report bugs to bug-gnu-utils@gnu.org\n"));
exit (status);
--- 225,274 ----
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, _("\
! -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\
! "));
! 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\
! -EB --endian=big Assume big endian format when disassembling\n\
! -EL --endian=little Assume little endian format when disassembling\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\
! --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\
! \n"));
! list_supported_targets (program_name, stream);
! }
if (status == 0)
fprintf (stream, _("Report bugs to bug-gnu-utils@gnu.org\n"));
exit (status);
*************** static struct option long_options[]=
*** 261,272 ****
{"private-headers", no_argument, NULL, 'p'},
{"architecture", required_argument, NULL, 'm'},
{"archive-headers", no_argument, NULL, 'a'},
! {"debugging", no_argument, &dump_debugging, 1},
! {"demangle", no_argument, &do_demangle, 1},
{"disassemble", no_argument, NULL, 'd'},
{"disassemble-all", no_argument, NULL, 'D'},
{"disassembler-options", required_argument, NULL, 'M'},
! {"disassemble-zeroes", no_argument, &disassemble_zeroes, 1},
{"dynamic-reloc", no_argument, NULL, 'R'},
{"dynamic-syms", no_argument, NULL, 'T'},
{"endian", required_argument, NULL, OPTION_ENDIAN},
--- 288,299 ----
{"private-headers", no_argument, NULL, 'p'},
{"architecture", required_argument, NULL, 'm'},
{"archive-headers", no_argument, NULL, 'a'},
! {"debugging", no_argument, NULL, 'g'},
! {"demangle", no_argument, NULL, 'C'},
{"disassemble", no_argument, NULL, 'd'},
{"disassemble-all", no_argument, NULL, 'D'},
{"disassembler-options", required_argument, NULL, 'M'},
! {"disassemble-zeroes", no_argument, NULL, 'z'},
{"dynamic-reloc", no_argument, NULL, 'R'},
{"dynamic-syms", no_argument, NULL, 'T'},
{"endian", required_argument, NULL, OPTION_ENDIAN},
*************** static struct option long_options[]=
*** 283,295 ****
{"section-headers", no_argument, NULL, 'h'},
{"show-raw-insn", no_argument, &show_raw_insn, 1},
{"source", no_argument, NULL, 'S'},
! {"stabs", no_argument, &dump_stab_section_info, 1},
{"start-address", required_argument, NULL, OPTION_START_ADDRESS},
{"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
{"syms", no_argument, NULL, 't'},
{"target", required_argument, NULL, 'b'},
! {"version", no_argument, &show_version, 1},
! {"wide", no_argument, &wide_output, 'w'},
{0, no_argument, 0, 0}
};
--- 310,322 ----
{"section-headers", no_argument, NULL, 'h'},
{"show-raw-insn", no_argument, &show_raw_insn, 1},
{"source", no_argument, NULL, 'S'},
! {"stabs", no_argument, NULL, 'G'},
{"start-address", required_argument, NULL, OPTION_START_ADDRESS},
{"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
{"syms", no_argument, NULL, 't'},
{"target", required_argument, NULL, 'b'},
! {"version", no_argument, NULL, 'V'},
! {"wide", no_argument, NULL, 'w'},
{0, no_argument, 0, 0}
};
*************** main (argc, argv)
*** 2767,2778 ****
bfd_init ();
set_default_bfd_target ();
! while ((c = getopt_long (argc, argv, "pib:m:M:VCdDlfahrRtTxsSj:wE:",
long_options, (int *) 0))
!= EOF)
{
- if (c != 'l' && c != OPTION_START_ADDRESS && c != OPTION_STOP_ADDRESS)
- seenflag = true;
switch (c)
{
case 0:
--- 2794,2803 ----
bfd_init ();
set_default_bfd_target ();
! while ((c = getopt_long (argc, argv, "pib:m:M:VCdDlfahHrRtTxsSj:wE:zgG",
long_options, (int *) 0))
!= EOF)
{
switch (c)
{
case 0:
*************** main (argc, argv)
*** 2787,2889 ****
only = optarg;
break;
case 'l':
! with_line_numbers = 1;
break;
case 'b':
target = optarg;
break;
case 'f':
dump_file_header = true;
break;
case 'i':
formats_info = true;
break;
case 'p':
! dump_private_headers = 1;
break;
case 'x':
! dump_private_headers = 1;
! dump_symtab = 1;
! dump_reloc_info = 1;
dump_file_header = true;
! dump_ar_hdrs = 1;
! dump_section_headers = 1;
break;
case 't':
! dump_symtab = 1;
break;
case 'T':
! dump_dynamic_symtab = 1;
! break;
! case 'C':
! do_demangle = 1;
break;
case 'd':
disassemble = true;
break;
case 'D':
! disassemble = disassemble_all = true;
break;
case 'S':
disassemble = true;
with_source_code = true;
break;
case 's':
! dump_section_contents = 1;
break;
case 'r':
! dump_reloc_info = 1;
break;
case 'R':
! dump_dynamic_reloc_info = 1;
break;
case 'a':
! dump_ar_hdrs = 1;
break;
case 'h':
! dump_section_headers = 1;
break;
case 'H':
usage (stdout, 0);
case 'V':
! show_version = 1;
! break;
! case 'w':
! wide_output = 1;
! break;
! case OPTION_ADJUST_VMA:
! adjust_section_vma = parse_vma (optarg, "--adjust-vma");
! break;
! case OPTION_START_ADDRESS:
! start_address = parse_vma (optarg, "--start-address");
break;
! case OPTION_STOP_ADDRESS:
! stop_address = parse_vma (optarg, "--stop-address");
! break;
! case 'E':
! if (strcmp (optarg, "B") == 0)
! endian = BFD_ENDIAN_BIG;
! else if (strcmp (optarg, "L") == 0)
! endian = BFD_ENDIAN_LITTLE;
! else
! {
! fprintf (stderr, _("%s: unrecognized -E option\n"),
! program_name);
! usage (stderr, 1);
! }
! break;
! case OPTION_ENDIAN:
! if (strncmp (optarg, "big", strlen (optarg)) == 0)
! endian = BFD_ENDIAN_BIG;
! else if (strncmp (optarg, "little", strlen (optarg)) == 0)
! endian = BFD_ENDIAN_LITTLE;
! else
! {
! fprintf (stderr, _("%s: unrecognized --endian type `%s'\n"),
! program_name, optarg);
! usage (stderr, 1);
! }
! break;
default:
usage (stderr, 1);
}
--- 2812,2944 ----
only = optarg;
break;
case 'l':
! with_line_numbers = true;
break;
case 'b':
target = optarg;
break;
+ case 'C':
+ do_demangle = true;
+ break;
+ case 'w':
+ wide_output = true;
+ break;
+ case OPTION_ADJUST_VMA:
+ adjust_section_vma = parse_vma (optarg, "--adjust-vma");
+ break;
+ case OPTION_START_ADDRESS:
+ start_address = parse_vma (optarg, "--start-address");
+ break;
+ case OPTION_STOP_ADDRESS:
+ stop_address = parse_vma (optarg, "--stop-address");
+ break;
+ case 'E':
+ if (strcmp (optarg, "B") == 0)
+ endian = BFD_ENDIAN_BIG;
+ else if (strcmp (optarg, "L") == 0)
+ endian = BFD_ENDIAN_LITTLE;
+ else
+ {
+ fprintf (stderr, _("%s: unrecognized -E option\n"),
+ program_name);
+ usage (stderr, 1);
+ }
+ break;
+ case OPTION_ENDIAN:
+ if (strncmp (optarg, "big", strlen (optarg)) == 0)
+ endian = BFD_ENDIAN_BIG;
+ else if (strncmp (optarg, "little", strlen (optarg)) == 0)
+ endian = BFD_ENDIAN_LITTLE;
+ else
+ {
+ fprintf (stderr, _("%s: unrecognized --endian type `%s'\n"),
+ program_name, optarg);
+ usage (stderr, 1);
+ }
+ break;
+
case 'f':
dump_file_header = true;
+ seenflag = true;
break;
case 'i':
formats_info = true;
+ seenflag = true;
break;
case 'p':
! dump_private_headers = true;
! seenflag = true;
break;
case 'x':
! dump_private_headers = true;
! dump_symtab = true;
! dump_reloc_info = true;
dump_file_header = true;
! dump_ar_hdrs = true;
! dump_section_headers = true;
! seenflag = true;
break;
case 't':
! dump_symtab = true;
! seenflag = true;
break;
case 'T':
! dump_dynamic_symtab = true;
! seenflag = true;
break;
case 'd':
disassemble = true;
+ seenflag = true;
break;
+ case 'z':
+ disassemble_zeroes = true;
+ break;
case 'D':
! disassemble = true;
! disassemble_all = true;
! seenflag = true;
break;
case 'S':
disassemble = true;
with_source_code = true;
+ seenflag = true;
+ break;
+ case 'g':
+ dump_debugging = 1;
+ seenflag = true;
+ break;
+ case 'G':
+ dump_stab_section_info = true;
+ seenflag = true;
break;
case 's':
! dump_section_contents = true;
! seenflag = true;
break;
case 'r':
! dump_reloc_info = true;
! seenflag = true;
break;
case 'R':
! dump_dynamic_reloc_info = true;
! seenflag = true;
break;
case 'a':
! dump_ar_hdrs = true;
! seenflag = true;
break;
case 'h':
! dump_section_headers = true;
! seenflag = true;
break;
case 'H':
usage (stdout, 0);
+ seenflag = true;
case 'V':
! show_version = true;
! seenflag = true;
break;
!
default:
usage (stderr, 1);
}
*************** main (argc, argv)
*** 2893,2904 ****
print_version ("objdump");
if (seenflag == false)
! usage (stderr, 1);
if (formats_info)
! {
! display_info ();
! }
else
{
if (optind == argc)
--- 2948,2957 ----
print_version ("objdump");
if (seenflag == false)
! usage (stderr, 2);
if (formats_info)
! display_info ();
else
{
if (optind == argc)
Index: binutils.texi
===================================================================
RCS file: /cvs/binutils/binutils/binutils/binutils.texi,v
retrieving revision 1.13
diff -p -r1.13 binutils.texi
*** binutils.texi 1999/10/08 13:56:33 1.13
--- binutils.texi 1999/11/20 15:15:11
*************** Show a summary of the options to @code{o
*** 1157,1181 ****
@smallexample
objdump [ -a | --archive-headers ]
! [ -b @var{bfdname} | --target=@var{bfdname} ] [ --debugging ]
! [ -C | --demangle ] [ -d | --disassemble ]
! [ -D | --disassemble-all ] [ --disassemble-zeroes ]
[ -EB | -EL | --endian=@{big | little @} ]
[ -f | --file-headers ]
! [ -h | --section-headers | --headers ] [ -i | --info ]
[ -j @var{section} | --section=@var{section} ]
! [ -l | --line-numbers ] [ -S | --source ]
[ -m @var{machine} | --architecture=@var{machine} ]
[ -M @var{options} | --disassembler-options=@var{options}]
[ -p | --private-headers ]
! [ -r | --reloc ] [ -R | --dynamic-reloc ]
! [ -s | --full-contents ] [ --stabs ]
! [ -t | --syms ] [ -T | --dynamic-syms ] [ -x | --all-headers ]
! [ -w | --wide ] [ --start-address=@var{address} ]
[ --stop-address=@var{address} ]
! [ --prefix-addresses] [ --[no-]show-raw-insn ]
[ --adjust-vma=@var{offset} ]
! [ --version ] [ --help ]
@var{objfile}@dots{}
@end smallexample
--- 1157,1193 ----
@smallexample
objdump [ -a | --archive-headers ]
! [ -b @var{bfdname} | --target=@var{bfdname} ]
! [ -C | --demangle ]
! [ -d | --disassemble ]
! [ -D | --disassemble-all ]
! [ -z | --disassemble-zeroes ]
[ -EB | -EL | --endian=@{big | little @} ]
[ -f | --file-headers ]
! [ -g | --debugging ]
! [ -h | --section-headers | --headers ]
! [ -i | --info ]
[ -j @var{section} | --section=@var{section} ]
! [ -l | --line-numbers ]
! [ -S | --source ]
[ -m @var{machine} | --architecture=@var{machine} ]
[ -M @var{options} | --disassembler-options=@var{options}]
[ -p | --private-headers ]
! [ -r | --reloc ]
! [ -R | --dynamic-reloc ]
! [ -s | --full-contents ]
! [ -G | --stabs ]
! [ -t | --syms ]
! [ -T | --dynamic-syms ]
! [ -x | --all-headers ]
! [ -w | --wide ]
! [ --start-address=@var{address} ]
[ --stop-address=@var{address} ]
! [ --prefix-addresses]
! [ --[no-]show-raw-insn ]
[ --adjust-vma=@var{offset} ]
! [ -V | --version ]
! [ -H | --help ]
@var{objfile}@dots{}
@end smallexample
*************** specify archives, @code{objdump} shows i
*** 1190,1196 ****
object files.
The long and short forms of options, shown here as alternatives, are
! equivalent. At least one option besides @samp{-l} must be given.
@table @code
@item -a
--- 1202,1209 ----
object files.
The long and short forms of options, shown here as alternatives, are
! equivalent. At least one option from the list
! @samp{-a,-d,-D,-f,-g,-G,-h,-H,-p,-r,-R,-S,-t,-T,-V,-x} must be given.
@table @code
@item -a
*************** Besides removing any initial underscore
*** 1236,1241 ****
--- 1249,1255 ----
makes C++ function names readable. @xref{c++filt}, for more information
on demangling.
+ @item -G
@item --debugging
Display debugging information. This attempts to parse debugging
information stored in the file and print it out using a C like syntax.
*************** in symbolic form. This is the default e
*** 1382,1387 ****
--- 1396,1402 ----
When disassembling instructions, do not print the instruction bytes.
This is the default when @code{--prefix-addresses} is used.
+ @item -G
@item --stabs
@cindex stab
@cindex .stab