summaryrefslogtreecommitdiffstats
path: root/binutils/objdump.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2008-02-22 09:42:58 +0000
committerNick Clifton <nickc@redhat.com>2008-02-22 09:42:58 +0000
commit98ec6e726638cb708f0e818c747883fd840b8d1b (patch)
tree152c644938eea560f167576d4efa5edc07a4a157 /binutils/objdump.c
parentf736769e93726370a5158d22b8e421b6d0374153 (diff)
downloadppe42-binutils-98ec6e726638cb708f0e818c747883fd840b8d1b.tar.gz
ppe42-binutils-98ec6e726638cb708f0e818c747883fd840b8d1b.zip
* objdump.c (display_file_offsets): New variable.
(long_options): Add -F/--file-offsets. (objdump_print_addr_with_sym): If displaying file offsets, print the offset of the given address. (disassemble_bytes): If displaying file offsets, tell the user how many zeroes are skipped and the file offset of the point where dumping resumes. (disassemble_section): Only display the name of the section if data is going to be dumped from it. (main): Handle new option. Produce error messages if the start or stop addresses do not make sense. * doc/binutils.texi: Document the new feature. * NEWS: Mention the new feature.
Diffstat (limited to 'binutils/objdump.c')
-rw-r--r--binutils/objdump.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 83361331cc..6f178177dc 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -110,6 +110,7 @@ static int dump_debugging_tags; /* --debugging-tags */
static int dump_special_syms = 0; /* --special-syms */
static bfd_vma adjust_section_vma = 0; /* --adjust-vma */
static int file_start_context = 0; /* --file-start-context */
+static bfd_boolean display_file_offsets;/* -F */
/* Pointer to an array of section names provided by
one or more "-j secname" command line options. */
@@ -217,6 +218,7 @@ usage (FILE *stream, int status)
--file-start-context Include context from start of file (with -S)\n\
-I, --include=DIR Add DIR to search list for source files\n\
-l, --line-numbers Include line numbers and filenames in output\n\
+ -F, --file-offsets Include file offsets when displaying information\n\
-C, --demangle[=STYLE] Decode mangled/processed symbol names\n\
The STYLE, if specified, can be `auto', `gnu',\n\
`lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\
@@ -267,6 +269,7 @@ static struct option long_options[]=
{"dynamic-syms", no_argument, NULL, 'T'},
{"endian", required_argument, NULL, OPTION_ENDIAN},
{"file-headers", no_argument, NULL, 'f'},
+ {"file-offsets", no_argument, NULL, 'F'},
{"file-start-context", no_argument, &file_start_context, 1},
{"full-contents", no_argument, NULL, 's'},
{"headers", no_argument, NULL, 'h'},
@@ -859,6 +862,10 @@ objdump_print_addr_with_sym (bfd *abfd, asection *sec, asymbol *sym,
}
(*info->fprintf_func) (info->stream, ">");
}
+
+ if (display_file_offsets)
+ info->fprintf_func (info->stream, " (File Offset: 0x%lx)",
+ (long int)(sec->filepos + (vma - sec->vma)));
}
/* Print an address (VMA), symbolically if possible.
@@ -1391,8 +1398,6 @@ disassemble_bytes (struct disassemble_info * info,
|| (z == stop_offset * opb &&
z - addr_offset * opb < skip_zeroes_at_end)))
{
- printf ("\t...\n");
-
/* If there are more nonzero octets to follow, we only skip
zeroes in multiples of 4, to try to avoid running over
the start of an instruction which happens to start with
@@ -1401,6 +1406,16 @@ disassemble_bytes (struct disassemble_info * info,
z = addr_offset * opb + ((z - addr_offset * opb) &~ 3);
octets = z - addr_offset * opb;
+
+ /* If we are going to display more data, and we are displaying
+ file offsets, then tell the user how many zeroes we skip
+ and the file offset from where we resume dumping. */
+ if (display_file_offsets && ((addr_offset + (octets / opb)) < stop_offset))
+ printf ("\t... (skipping %d zeroes, resuming at file offset: 0x%lx)\n",
+ octets / opb,
+ (long int)(section->filepos + (addr_offset + (octets / opb))));
+ else
+ printf ("\t...\n");
}
else
{
@@ -1783,7 +1798,8 @@ disassemble_section (bfd *abfd, asection *section, void *info)
&& (*rel_pp)->address < rel_offset + addr_offset)
++rel_pp;
- printf (_("Disassembly of section %s:\n"), section->name);
+ if (addr_offset < stop_offset)
+ printf (_("\nDisassembly of section %s:\n"), section->name);
/* Find the nearest symbol forwards from our current position. */
paux->require_sec = TRUE;
@@ -3068,7 +3084,7 @@ main (int argc, char **argv)
bfd_init ();
set_default_bfd_target ();
- while ((c = getopt_long (argc, argv, "pib:m:M:VvCdDlfaHhrRtTxsSI:j:wE:zgeGW",
+ while ((c = getopt_long (argc, argv, "pib:m:M:VvCdDlfFaHhrRtTxsSI:j:wE:zgeGW",
long_options, (int *) 0))
!= EOF)
{
@@ -3095,6 +3111,9 @@ main (int argc, char **argv)
}
only [only_used++] = optarg;
break;
+ case 'F':
+ display_file_offsets = TRUE;
+ break;
case 'l':
with_line_numbers = TRUE;
break;
@@ -3123,9 +3142,13 @@ main (int argc, char **argv)
break;
case OPTION_START_ADDRESS:
start_address = parse_vma (optarg, "--start-address");
+ if ((stop_address != (bfd_vma) -1) && stop_address <= start_address)
+ fatal (_("error: the start address should be before the end address"));
break;
case OPTION_STOP_ADDRESS:
stop_address = parse_vma (optarg, "--stop-address");
+ if ((start_address != (bfd_vma) -1) && stop_address <= start_address)
+ fatal (_("error: the stop address should be after the start address"));
break;
case 'E':
if (strcmp (optarg, "B") == 0)
OpenPOWER on IntegriCloud