diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2003-04-01 00:32:47 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2003-04-01 00:32:47 +0000 |
commit | 335a1869163d3ef8c488b9815663a683387f9d9a (patch) | |
tree | 7936c8034f0b1d33eb1d1a8422ae562dc71f7532 /binutils/objdump.c | |
parent | 6e84a9068469403a0a2280e705cf3cef334afd45 (diff) | |
download | gdb-335a1869163d3ef8c488b9815663a683387f9d9a.zip gdb-335a1869163d3ef8c488b9815663a683387f9d9a.tar.gz gdb-335a1869163d3ef8c488b9815663a683387f9d9a.tar.bz2 |
* objdump.c (dump_data): Don't truncate the address to long; make
the width large enough, and uniform for all entries in a section.
Diffstat (limited to 'binutils/objdump.c')
-rw-r--r-- | binutils/objdump.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c index b641fde..3c927bd 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -2227,6 +2227,9 @@ dump_data (abfd) { if (section->flags & SEC_HAS_CONTENTS) { + char buf[64]; + int count, width; + printf (_("Contents of section %s:\n"), section->name); if (bfd_section_size (abfd, section) == 0) @@ -2253,13 +2256,47 @@ dump_data (abfd) if (stop_offset > bfd_section_size (abfd, section) / opb) stop_offset = bfd_section_size (abfd, section) / opb; } + + width = 4; + + bfd_sprintf_vma (abfd, buf, start_offset + section->vma); + if (strlen (buf) >= sizeof (buf)) + abort (); + count = 0; + while (buf[count] == '0' && buf[count+1] != '\0') + count++; + count = strlen (buf) - count; + if (count > width) + width = count; + + bfd_sprintf_vma (abfd, buf, stop_offset + section->vma - 1); + if (strlen (buf) >= sizeof (buf)) + abort (); + count = 0; + while (buf[count] == '0' && buf[count+1] != '\0') + count++; + count = strlen (buf) - count; + if (count > width) + width = count; + for (addr_offset = start_offset; addr_offset < stop_offset; addr_offset += onaline / opb) { bfd_size_type j; - printf (" %04lx ", (unsigned long int) - (addr_offset + section->vma)); + bfd_sprintf_vma (abfd, buf, (addr_offset + section->vma)); + count = strlen (buf); + if (count >= sizeof (buf)) + abort (); + putchar (' '); + while (count < width) + { + putchar ('0'); + count++; + } + fputs (buf + count - width, stdout); + putchar (' '); + for (j = addr_offset * opb; j < addr_offset * opb + onaline; j++) { |