From: Ian Lance Taylor Date: Wed, 13 Sep 1995 22:38:55 +0000 (+0000) Subject: * objdump.c (start_address): New variable. X-Git-Tag: gdb-4_18~10858 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa21a2a9ecd87339695d80826e629a7e96506249;p=platform%2Fupstream%2Fbinutils.git * objdump.c (start_address): New variable. (stop_address): New variable. (usage): Mention --start-address and --stop-address. (OPTION_START_ADDRESS, OPTION_STOP_ADDRESS): Define. (long_options): Add "start-address" and "stop-address". (disassemble_data): Handle start_address and stop_address. (dump_data, dump_reloc_set): Likewise. (main): Don't set seenflag for -l. Handle OPTION_START_ADDRESS and OPTION_STOP_ADDRESS. * objcopy.c (parse_vma): Move to bucomm.c. * bucomm.c (parse_vma): New function, moved in from objcopy.c. * bucomm.h (parse_vma): Declare. * binutils.texi, objdump.1: Document new objdump options. PR 7983. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 0623bf6..53cd85b 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,19 @@ +Wed Sep 13 18:33:44 1995 Ian Lance Taylor + + * objdump.c (start_address): New variable. + (stop_address): New variable. + (usage): Mention --start-address and --stop-address. + (OPTION_START_ADDRESS, OPTION_STOP_ADDRESS): Define. + (long_options): Add "start-address" and "stop-address". + (disassemble_data): Handle start_address and stop_address. + (dump_data, dump_reloc_set): Likewise. + (main): Don't set seenflag for -l. Handle OPTION_START_ADDRESS + and OPTION_STOP_ADDRESS. + * objcopy.c (parse_vma): Move to bucomm.c. + * bucomm.c (parse_vma): New function, moved in from objcopy.c. + * bucomm.h (parse_vma): Declare. + * binutils.texi, objdump.1: Document new objdump options. + Tue Sep 12 12:37:39 1995 Ian Lance Taylor * Makefile.in (maintainer-clean): New target. diff --git a/binutils/binutils.texi b/binutils/binutils.texi index fef8401..4dba4f5 100644 --- a/binutils/binutils.texi +++ b/binutils/binutils.texi @@ -959,7 +959,9 @@ objdump [ -a | --archive-headers ] [ -r | --reloc ] [ -R | --dynamic-reloc ] [ -s | --full-contents ] [ --stabs ] [ -t | --syms ] [ -T | --dynamic-syms ] [ -x | --all-headers ] - [ -w | --wide ] [ --version ] [ --help ] @var{objfile}@dots{} + [ -w | --wide ] [ --start-address=@var{address} ] + [ --stop-address=@var{address} ] [ --version ] [ --help ] + @var{objfile}@dots{} @end smallexample @code{objdump} displays information about one or more object files. @@ -1106,6 +1108,16 @@ section. In most other file formats, debugging symbol-table entries are interleaved with linkage symbols, and are visible in the @samp{--syms} output. +@item --start-address=@var{address} +@cindex start-address +Start displaying data at the specified address. This affects the output +of the @code{-d}, @code{-r} and @code{-s} options. + +@item --stop-address=@var{address} +@cindex stop-address +Stop displaying data at the specified address. This affects the output +of the @code{-d}, @code{-r} and @code{-s} options. + @item -t @itemx --syms @cindex symbol table entries, printing diff --git a/binutils/objdump.1 b/binutils/objdump.1 index f5beb33..6b73cb9d 100644 --- a/binutils/objdump.1 +++ b/binutils/objdump.1 @@ -46,6 +46,12 @@ objdump \- display information from object files. .RB "[\|" \-t | \-\-syms "\|]" .RB "[\|" \-T | \-\-dynamic\-syms "\|]" .RB "[\|" \-x | \-\-all\-headers "\|]" +.RB "[\|" "\-\-start\-address="\c +.I address\c +\&\|] +.RB "[\|" "\-\-stop\-address="\c +.I address\c +\&\|] .RB "[\|" \-\-version "\|]" .RB "[\|" \-\-help "\|]" .I objfile\c @@ -245,6 +251,28 @@ entries are interleaved with linkage symbols, and are visible in the \-\-syms output. .TP +.BI "\-\-start\-address=" "address" +Start displaying data at the specified address. This affects the output +of the +.B \-d\c +, +.B \-r +and +.B \-s +options. + +.TP +.BI "\-\-stop\-address=" "address" +Stop displaying data at the specified address. This affects the output +of the +.B \-d\c +, +.B \-r +and +.B \-s +options. + +.TP .B \-t .TP .B \-\-syms diff --git a/binutils/objdump.c b/binutils/objdump.c index 64cba47..e760a54 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -57,6 +57,8 @@ boolean disassemble_all; /* -D */ boolean formats_info; /* -i */ char *only; /* -j secname */ int wide_output; /* -w */ +bfd_vma start_address = (bfd_vma) -1; /* --start-address */ +bfd_vma stop_address = (bfd_vma) -1; /* --stop-address */ /* Extra info to pass to the disassembler address printing function. */ struct objdump_disasm_info { @@ -129,12 +131,18 @@ Usage: %s [-ahifdDprRtTxsSlw] [-b bfdname] [-m machine] [-j section-name]\n\ fprintf (stream, "\ [--architecture=machine] [--reloc] [--full-contents] [--stabs]\n\ [--syms] [--all-headers] [--dynamic-syms] [--dynamic-reloc]\n\ - [--wide] [--version] [--help] [--private-headers] objfile...\n\ + [--wide] [--version] [--help] [--private-headers]\n\ + [--start-address=addr] [--stop-address=addr] objfile...\n\ at least one option besides -l (--line-numbers) must be given\n"); list_supported_targets (program_name, stream); exit (status); } +/* 150 isn't special; it's just an arbitrary non-ASCII char value. */ + +#define OPTION_START_ADDRESS (150) +#define OPTION_STOP_ADDRESS (OPTION_START_ADDRESS + 1) + static struct option long_options[]= { {"all-headers", no_argument, NULL, 'x'}, @@ -156,9 +164,11 @@ static struct option long_options[]= {"section-headers", no_argument, NULL, 'h'}, {"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}, + {"version", no_argument, &show_version, 1}, {"wide", no_argument, &wide_output, 'w'}, {0, no_argument, 0, 0} }; @@ -773,6 +783,7 @@ disassemble_data (abfd) arelent **relbuf = NULL; arelent **relpp = NULL; arelent **relppend = NULL; + long stop; if ((section->flags & SEC_LOAD) == 0 || (! disassemble_all @@ -822,8 +833,23 @@ disassemble_data (abfd) disasm_info.buffer = data; disasm_info.buffer_vma = section->vma; disasm_info.buffer_length = datasize; - i = 0; - while (i < disasm_info.buffer_length) + if (start_address == (bfd_vma) -1 + || start_address < disasm_info.buffer_vma) + i = 0; + else + i = start_address - disasm_info.buffer_vma; + if (stop_address == (bfd_vma) -1) + stop = datasize; + else + { + if (stop_address < disasm_info.buffer_vma) + stop = 0; + else + stop = stop_address - disasm_info.buffer_vma; + if (stop > disasm_info.buffer_length) + stop = disasm_info.buffer_length; + } + while (i < stop) { int bytes; boolean need_nl = false; @@ -1280,6 +1306,7 @@ dump_data (abfd) bfd_byte *data = 0; bfd_size_type datasize = 0; bfd_size_type i; + bfd_size_type start, stop; for (section = abfd->sections; section != NULL; section = section->next) @@ -1301,14 +1328,30 @@ dump_data (abfd) bfd_get_section_contents (abfd, section, (PTR) data, 0, bfd_section_size (abfd, section)); - for (i = 0; i < bfd_section_size (abfd, section); i += onaline) + if (start_address == (bfd_vma) -1 + || start_address < section->vma) + start = 0; + else + start = start_address - section->vma; + if (stop_address == (bfd_vma) -1) + stop = bfd_section_size (abfd, section); + else + { + if (stop_address < section->vma) + stop = 0; + else + stop = stop_address - section->vma; + if (stop > bfd_section_size (abfd, section)) + stop = bfd_section_size (abfd, section); + } + for (i = start; i < stop; i += onaline) { bfd_size_type j; printf (" %04lx ", (unsigned long int) (i + section->vma)); for (j = i; j < i + onaline; j++) { - if (j < bfd_section_size (abfd, section)) + if (j < stop) printf ("%02x", (unsigned) (data[j])); else printf (" "); @@ -1319,7 +1362,7 @@ dump_data (abfd) printf (" "); for (j = i; j < i + onaline; j++) { - if (j >= bfd_section_size (abfd, section)) + if (j >= stop) printf (" "); else printf ("%c", isprint (data[j]) ? data[j] : '.'); @@ -1500,6 +1543,13 @@ dump_reloc_set (abfd, relpp, relcount) CONST char *sym_name; CONST char *section_name; + if (start_address != (bfd_vma) -1 + && q->address < start_address) + continue; + if (stop_address != (bfd_vma) -1 + && q->address > stop_address) + continue; + if (q->sym_ptr_ptr && *q->sym_ptr_ptr) { sym_name = (*(q->sym_ptr_ptr))->name; @@ -1723,7 +1773,8 @@ main (argc, argv) (int *) 0)) != EOF) { - seenflag = true; + if (c != 'l' && c != OPTION_START_ADDRESS && c != OPTION_STOP_ADDRESS) + seenflag = true; switch (c) { case 0: @@ -1796,6 +1847,12 @@ main (argc, argv) case 'w': wide_output = 1; 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; default: usage (stderr, 1); }