summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2001-09-25 16:44:19 +0000
committerJakub Jelinek <jakub@redhat.com>2001-09-25 16:44:19 +0000
commitb9c6372a37f488c02fb99b8eca4190aaa58cc3ee (patch)
treedd302f0078a46caaa0a1288dfc8b5bccef35efa6
parent351746afcd0d163e6d67e8ea08120157f394e9ec (diff)
downloadbinutils-redhat-b9c6372a37f488c02fb99b8eca4190aaa58cc3ee.tar.gz
* readelf.c (do_wide): New.
(options): Add --wide. (usage, parse_args): Likewise. (process_program_headers): Put each segment on a single line if --wide is given. (process_section_headers): Put each section on a single line if --wide is given. * doc/binutils.texi: Document it. * NEWS: Likewise.
-rw-r--r--binutils/ChangeLog12
-rw-r--r--binutils/NEWS3
-rw-r--r--binutils/doc/binutils.texi9
-rw-r--r--binutils/readelf.c106
4 files changed, 128 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 2651e31461..1b8b87c42c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,15 @@
+2001-09-25 Jakub Jelinek <jakub@redhat.com>
+
+ * readelf.c (do_wide): New.
+ (options): Add --wide.
+ (usage, parse_args): Likewise.
+ (process_program_headers): Put each segment on a single line if
+ --wide is given.
+ (process_section_headers): Put each section on a single line if
+ --wide is given.
+ * doc/binutils.texi: Document it.
+ * NEWS: Likewise.
+
2001-09-25 Alan Modra <amodra@bigpond.net.au>
* readelf.c (print_vma): Print 8 digits of low hex value.
diff --git a/binutils/NEWS b/binutils/NEWS
index f4745c0f82..744b83b06d 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -1,5 +1,8 @@
-*- text -*-
+* readelf: Add --wide option to not break section header or segment listing
+ lines to fit into 80 columns.
+
* strings: Add --encoding to display wide character strings. By Markus Kuhn.
* objcopy: Add --rename-section to change section names.
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 6b6f19ef64..45878cbf30 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -2837,6 +2837,7 @@ readelf [@option{-a}|@option{--all}]
[@option{-w[liaprmf]}|@option{--debug-dump}[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames]]
[@option{-histogram}]
[@option{-v}|@option{--version}]
+ [@option{-W}|@option{--wide}]
[@option{-H}|@option{--help}]
@var{elffile}@dots{}
@c man end
@@ -2949,6 +2950,14 @@ of the symbol tables.
@itemx --version
Display the version number of readelf.
+@item -W
+@itemx --wide
+Don't break output lines to fit into 80 columns. By default
+@command{readelf} breaks section header and segment listing lines for
+64-bit ELF files, so that they fit into 80 columns. This option causes
+@command{readelf} to print each section header resp. each segment one a
+single line, which is far more readable on terminals wider than 80 columns.
+
@item -H
@itemx --help
Display the command line options understood by @command{readelf}.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 42160dcaf4..27c6d289eb 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -111,6 +111,7 @@ int do_using_dynamic;
int do_header;
int do_dump;
int do_version;
+int do_wide;
int do_histogram;
int do_debugging;
int do_debug_info;
@@ -2071,6 +2072,7 @@ struct option options [] =
#endif
{"version", no_argument, 0, 'v'},
+ {"wide", no_argument, 0, 'W'},
{"help", no_argument, 0, 'H'},
{0, no_argument, 0, 0}
};
@@ -2105,6 +2107,7 @@ usage ()
#endif
fprintf (stdout, _(" -I or --histogram Display histogram of bucket list lengths\n"));
fprintf (stdout, _(" -v or --version Display the version number of readelf\n"));
+ fprintf (stdout, _(" -W or --wide Don't split lines to fit into 80 columns\n"));
fprintf (stdout, _(" -H or --help Display this information\n"));
fprintf (stdout, _("Report bugs to %s\n"), REPORT_BUGS_TO);
@@ -2153,7 +2156,7 @@ parse_args (argc, argv)
usage ();
while ((c = getopt_long
- (argc, argv, "ersuahnldSDAIw::x:i:vV", options, NULL)) != EOF)
+ (argc, argv, "ersuahnldSDAIw::x:i:vVW", options, NULL)) != EOF)
{
char * cp;
int section;
@@ -2295,6 +2298,9 @@ parse_args (argc, argv)
case 'V':
do_version ++;
break;
+ case 'W':
+ do_wide ++;
+ break;
default:
oops:
/* xgettext:c-format */
@@ -2578,6 +2584,9 @@ process_program_headers (file)
if (is_32bit_elf)
printf
(_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
+ else if (do_wide)
+ printf
+ (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
else
{
printf
@@ -2612,6 +2621,48 @@ process_program_headers (file)
(segment->p_flags & PF_X ? 'E' : ' '));
printf ("%#lx", (unsigned long) segment->p_align);
}
+ else if (do_wide)
+ {
+ if ((unsigned long) segment->p_offset == segment->p_offset)
+ printf ("0x%6.6lx ", (unsigned long) segment->p_offset);
+ else
+ {
+ print_vma (segment->p_offset, FULL_HEX);
+ putchar (' ');
+ }
+
+ print_vma (segment->p_vaddr, FULL_HEX);
+ putchar (' ');
+ print_vma (segment->p_paddr, FULL_HEX);
+ putchar (' ');
+
+ if ((unsigned long) segment->p_filesz == segment->p_filesz)
+ printf ("0x%6.6lx ", (unsigned long) segment->p_filesz);
+ else
+ {
+ print_vma (segment->p_filesz, FULL_HEX);
+ putchar (' ');
+ }
+
+ if ((unsigned long) segment->p_memsz == segment->p_memsz)
+ printf ("0x%6.6lx", (unsigned long) segment->p_memsz);
+ else
+ {
+ print_vma (segment->p_offset, FULL_HEX);
+ }
+
+ printf (" %c%c%c ",
+ (segment->p_flags & PF_R ? 'R' : ' '),
+ (segment->p_flags & PF_W ? 'W' : ' '),
+ (segment->p_flags & PF_X ? 'E' : ' '));
+
+ if ((unsigned long) segment->p_align == segment->p_align)
+ printf ("%#lx", (unsigned long) segment->p_align);
+ else
+ {
+ print_vma (segment->p_align, PREFIX_HEX);
+ }
+ }
else
{
print_vma (segment->p_offset, FULL_HEX);
@@ -3050,6 +3101,9 @@ process_section_headers (file)
if (is_32bit_elf)
printf
(_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
+ else if (do_wide)
+ printf
+ (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
else
{
printf (_(" [Nr] Name Type Address Offset\n"));
@@ -3081,11 +3135,59 @@ process_section_headers (file)
(unsigned long) section->sh_info,
(unsigned long) section->sh_addralign);
}
+ else if (do_wide)
+ {
+ print_vma (section->sh_addr, LONG_HEX);
+
+ if ((long) section->sh_offset == section->sh_offset)
+ printf (" %6.6lx", (unsigned long) section->sh_offset);
+ else
+ {
+ putchar (' ');
+ print_vma (section->sh_offset, LONG_HEX);
+ }
+
+ if ((unsigned long) section->sh_size == section->sh_size)
+ printf (" %6.6lx", (unsigned long) section->sh_size);
+ else
+ {
+ putchar (' ');
+ print_vma (section->sh_size, LONG_HEX);
+ }
+
+ if ((unsigned long) section->sh_entsize == section->sh_entsize)
+ printf (" %2.2lx", (unsigned long) section->sh_entsize);
+ else
+ {
+ putchar (' ');
+ print_vma (section->sh_entsize, LONG_HEX);
+ }
+
+ printf (" %3s ", get_elf_section_flags (section->sh_flags));
+
+ printf ("%2ld %3lx ",
+ (unsigned long) section->sh_link,
+ (unsigned long) section->sh_info);
+
+ if ((unsigned long) section->sh_addralign == section->sh_addralign)
+ printf ("%2ld\n", (unsigned long) section->sh_addralign);
+ else
+ {
+ print_vma (section->sh_addralign, DEC);
+ putchar ('\n');
+ }
+ }
else
{
putchar (' ');
print_vma (section->sh_addr, LONG_HEX);
- printf (" %8.8lx", (unsigned long) section->sh_offset);
+ if ((long) section->sh_offset == section->sh_offset)
+ printf (" %8.8lx", (unsigned long) section->sh_offset);
+ else
+ {
+ printf (" ");
+ print_vma (section->sh_offset, LONG_HEX);
+ }
printf ("\n ");
print_vma (section->sh_size, LONG_HEX);
printf (" ");