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 | 632f837855588ed0a978b95d1fbcc3ea44503bd3 (patch) | |
tree | ef3161a0a8e9450cbc8216586376fb7259e48ad6 | |
parent | 128307acfc2c3278dc118d12adf6551d2aadf95c (diff) | |
download | binutils-redhat-632f837855588ed0a978b95d1fbcc3ea44503bd3.tar.gz |
* objdump.c (dump_data): Don't truncate the address to long; make
the width large enough, and uniform for all entries in a section.
-rw-r--r-- | binutils/ChangeLog | 5 | ||||
-rw-r--r-- | binutils/objdump.c | 41 |
2 files changed, 44 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index fe24e9fac2..a37cd1892f 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2003-03-31 Alexandre Oliva <aoliva@redhat.com> + + * objdump.c (dump_data): Don't truncate the address to long; make + the width large enough, and uniform for all entries in a section. + 2003-03-31 H.J. Lu <hjl@gnu.org> * readelf.c: Include "libiberty.h". diff --git a/binutils/objdump.c b/binutils/objdump.c index b641fde803..3c927bd7ae 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++) { |