PATCH: readelf: Print sh_flags in hex

Nick Clifton nickc@redhat.com
Tue Aug 9 09:21:00 GMT 2005


Hi H. J.

> 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.

There are a couple of problems with this patch:

> +  if (do_full_section_flags)
> +    {
> +      sprintf (buff, "%08x", (int) sh_flags);
> +      return buff;
> +    }

This means that the decoded values of the flags will not be shown.  If 
this is the intended purpose then the description displayed by --help 
ought to explicitly say that.  ie change:

      "Display the full section flags"
to:
      "Display the section flags as a hexadecimal value"

Presumably the --section-flags switch implies the --section switch, so 
the code in parse_args() to handle case 'f' ought to include a 
"do_sections++".  The other, minor problem with the value displayed by 
this new switch is that it is not prefixed by "0x" so that the reader 
knows that it is a hexadecimal value.

In my opinion however I think that it would be more useful if the 
--section-flags switch not only displayed the hex value of the flags 
field, but it also provided a more verbose decoding of these flags.  ie 
"Write" instead of "W", "TLS instead of "T", and so on.  It could also 
specifically show which bits of the OS and PROC specific flags are set. 
  (This could be deduced from the full hex display, but it makes it 
easier for the user).  This would however probably require displaying 
the flags on a line of their own.  eg:

   [Nr] Name    Type            Addr     Off    Size   ES Lk Inf Al
   [ 0] .text   PROGBITS        00001010 001010 000011 00  0   0  4
        Flags [0x10000006]: Allocate, Executable, PROC Specific (1 << 28)


The other problem with the patch is that you did not include 
documentation for the
-f/--section-flags switch in the binutils.texi file.

Cheers
   Nick



More information about the Binutils mailing list