diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2005-09-07 16:25:35 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2005-09-07 16:25:35 +0000 |
commit | 8d5ff12c8e030489bd57eb02922abbee0300ef1e (patch) | |
tree | bd05a743b2f086e4ef9d548a3b6a31f48861871c /binutils | |
parent | bd0eb99b906bd9e11675cf96a196e4044c39282a (diff) | |
download | gdb-8d5ff12c8e030489bd57eb02922abbee0300ef1e.zip gdb-8d5ff12c8e030489bd57eb02922abbee0300ef1e.tar.gz gdb-8d5ff12c8e030489bd57eb02922abbee0300ef1e.tar.bz2 |
2005-09-07 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (get_elf_section_flags): Handle 64bit sh_flags.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 4 | ||||
-rw-r--r-- | binutils/readelf.c | 96 |
2 files changed, 73 insertions, 27 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index a3f9b0e..8b24182 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2005-09-07 H.J. Lu <hongjiu.lu@intel.com> + + * readelf.c (get_elf_section_flags): Handle 64bit sh_flags. + 2005-09-02 H.J. Lu <hongjiu.lu@intel.com> * readelf.c (debug_abbrev_contents): New. diff --git a/binutils/readelf.c b/binutils/readelf.c index 4f865b0..d3e9457 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -3794,7 +3794,11 @@ get_elf_section_flags (bfd_vma sh_flags) { static char buff[1024]; char *p = buff; - int index, size = sizeof (buff) - (8 + 4 + 1); + int field_size = is_32bit_elf ? 8 : 16; + int index, size = sizeof (buff) - (field_size + 4 + 1); + bfd_vma os_flags = 0; + bfd_vma proc_flags = 0; + bfd_vma unknown_flags = 0; const struct { const char *str; @@ -3816,8 +3820,9 @@ get_elf_section_flags (bfd_vma sh_flags) if (do_section_details) { - sprintf (buff, "[%8.8lx]: ", (unsigned long) sh_flags); - p += 8 + 4; + sprintf (buff, "[%*.*lx]: ", + field_size, field_size, (unsigned long) sh_flags); + p += field_size + 4; } while (sh_flags) @@ -3847,38 +3852,26 @@ get_elf_section_flags (bfd_vma sh_flags) break; } - if (p != buff + 8 + 4) - { - if (size < 10 + 2) - abort (); - size -= 2; - *p++ = ','; - *p++ = ' '; - } - if (index != -1) { + if (p != buff + field_size + 4) + { + if (size < (10 + 2)) + abort (); + size -= 2; + *p++ = ','; + *p++ = ' '; + } + size -= flags [index].len; p = stpcpy (p, flags [index].str); } else if (flag & SHF_MASKOS) - { - size -= 5 + 8; - sprintf (p, "OS (%8.8lx)", (unsigned long) flag); - p += 5 + 8; - } + os_flags |= flag; else if (flag & SHF_MASKPROC) - { - size -= 7 + 8; - sprintf (p, "PROC (%8.8lx)", (unsigned long) flag); - p += 7 + 8; - } + proc_flags |= flag; else - { - size -= 10 + 8; - sprintf (p, "UNKNOWN (%8.8lx)", (unsigned long) flag); - p += 10 + 8; - } + unknown_flags |= flag; } else { @@ -3917,6 +3910,55 @@ get_elf_section_flags (bfd_vma sh_flags) } } + if (do_section_details) + { + if (os_flags) + { + size -= 5 + field_size; + if (p != buff + field_size + 4) + { + if (size < (2 + 1)) + abort (); + size -= 2; + *p++ = ','; + *p++ = ' '; + } + sprintf (p, "OS (%*.*lx)", field_size, field_size, + (unsigned long) os_flags); + p += 5 + field_size; + } + if (proc_flags) + { + size -= 7 + field_size; + if (p != buff + field_size + 4) + { + if (size < (2 + 1)) + abort (); + size -= 2; + *p++ = ','; + *p++ = ' '; + } + sprintf (p, "PROC (%*.*lx)", field_size, field_size, + (unsigned long) proc_flags); + p += 7 + field_size; + } + if (unknown_flags) + { + size -= 10 + field_size; + if (p != buff + field_size + 4) + { + if (size < (2 + 1)) + abort (); + size -= 2; + *p++ = ','; + *p++ = ' '; + } + sprintf (p, "UNKNOWN (%*.*lx)", field_size, field_size, + (unsigned long) unknown_flags); + p += 10 + field_size; + } + } + *p = '\0'; return buff; } |