* readelf.c (do_wide): New.
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Sep 2001 16:44:19 +0000 (16:44 +0000)
committerJakub Jelinek <jakub@redhat.com>
Tue, 25 Sep 2001 16:44:19 +0000 (16:44 +0000)
(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.

binutils/ChangeLog
binutils/NEWS
binutils/doc/binutils.texi
binutils/readelf.c

index 2651e31461c59caf99a73b914176f1f2d089790a..1b8b87c42c2678143132035223001ac7070b0959 100644 (file)
@@ -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.
index f4745c0f82465df895a3cb147ccbd3d3e6429555..744b83b06d9005fab50d54b14ad6cd8f50b23a46 100644 (file)
@@ -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.
index 6b6f19ef645edfb4e9f1a339e3de16a800681479..45878cbf304364df2a9218c1aea2f82d96bde5b1 100644 (file)
@@ -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}.
index 42160dcaf4e6f5cf0bb2b49448d9a66a18920948..27c6d289eb9d157d7fe51e53b7505115fa5e384e 100644 (file)
@@ -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 ("  ");