This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: readelf: Print sh_flags in hex


When sh_flags has processor/OS specific bits, there is no way to see
what they really are. This patch adds a -f switch to dump sh_flags in
hex.


H.J.
---
2005-08-08  H.J. Lu  <hongjiu.lu@intel.com>

	* readelf.c (do_full_section_flags): New.
	(option): Add -f/--section-flags.
	(usage): Likewise.
	(parse_args): Likewise.
	(get_elf_section_flags): Print sh_flags in hex if
	do_full_section_flags is 0.

--- binutils/readelf.c.number	2005-08-05 07:14:46.000000000 -0700
+++ binutils/readelf.c	2005-08-08 11:51:38.000000000 -0700
@@ -146,6 +146,7 @@ static int do_dynamic;
 static int do_syms;
 static int do_reloc;
 static int do_sections;
+static int do_full_section_flags;
 static int do_section_groups;
 static int do_full_section_name;
 static int do_segments;
@@ -2714,6 +2715,7 @@ static struct option options[] =
   {"histogram",	       no_argument, 0, 'I'},
   {"segments",	       no_argument, 0, 'l'},
   {"sections",	       no_argument, 0, 'S'},
+  {"section-flags",    no_argument, 0, 'f'},
   {"section-headers",  no_argument, 0, 'S'},
   {"section-groups",   no_argument, 0, 'g'},
   {"full-section-name",no_argument, 0, 'N'},
@@ -2751,6 +2753,7 @@ usage (void)
   -S --section-headers   Display the sections' header\n\
      --sections          An alias for --section-headers\n\
   -g --section-groups    Display the section groups\n\
+  -f --section-flags     Display the full section flags\n\
   -N --full-section-name\n\
                          Display the full section name\n\
   -e --headers           Equivalent to: -h -l -S\n\
@@ -2825,7 +2828,7 @@ parse_args (int argc, char **argv)
     usage ();
 
   while ((c = getopt_long
-	  (argc, argv, "ersuahnldSDAINgw::x:i:vVWH", options, NULL)) != EOF)
+	  (argc, argv, "ersuahnldSfDAINgw::x:i:vVWH", options, NULL)) != EOF)
     {
       char *cp;
       int section;
@@ -2888,6 +2891,9 @@ parse_args (int argc, char **argv)
 	case 'S':
 	  do_sections++;
 	  break;
+	case 'f':
+	  do_full_section_flags++;
+	  break;
 	case 'd':
 	  do_dynamic++;
 	  break;
@@ -3791,6 +3797,12 @@ get_elf_section_flags (bfd_vma sh_flags)
   static char buff[33];
   char *p = buff;
 
+  if (do_full_section_flags)
+    {
+      sprintf (buff, "%08x", (int) sh_flags);
+      return buff;
+    }
+
   while (sh_flags)
     {
       bfd_vma flag;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]