* PATCH: readelf: Handle 64bit sh_flags
@ 2005-09-02 16:43 H. J. Lu
2005-09-07 15:42 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: H. J. Lu @ 2005-09-02 16:43 UTC (permalink / raw)
To: binutils
Some compiler may generate sh_flags==0xffffffffc0000003 in 64bit ELF
object file. The current readelf outputs:
[ 9] .ctors
PROGBITS 0000000000000000 00000000000008ab 0
0000000000000008 0000000000000000 0 8
[ffffffffc00WRITE, ALLOC, PROC (40000000), PROC (80000000),
UNKNOWN (100000000, UNKNOWN (200000000, UNKNOWN (400000000, UNKNOWN
(800000000, UNKNOWN (100000000, UNKNOWN (200000000, UNKNOWN (400000000,
UNKNOWN (800000000, UNKNOWN (100000000, UNKNOWN (200000000, UNKNOWN
(400000000, UNKNOWN (800000000, UNKNOWN (100000000, UNKNOWN (200000000,
UNKNOWN (400000000, UNKNOWN (800000000, UNKNOWN (100000000, UNKNOWN
(200000000, UNKNOWN (400000000, UNKNOWN (800000000, UNKNOWN (100000000,
UNKNOWN (200000000, UNKNOWN (400000000, UNKNOWN (800000000, UNKNOWN
(100000000, UNKNOWN (200000000, UNKNOWN (400000000, UNKNOWN (800000000,
UNKNOWN (100000000, UNKNOWN (200000000, UNKNOWN (400000000, UNKNOWN
(800000000
Also it doesn't provide anything useful to display OS/PROC/unknown
field one bit at a time. This patch changes it to
[ 9] .ctors
PROGBITS 0000000000000000 00000000000008ab 0
0000000000000008 0000000000000000 0 8
[ffffffffc0000003]: WRITE, ALLOC, PROC (00000000c0000000),
UNKNOWN (ffffffff00000000)
H.J.
----
2005-09-02 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (get_elf_section_flags): Handle 64bit sh_flags.
--- binutils/readelf.c.flag 2005-09-02 06:59:00.000000000 -0700
+++ binutils/readelf.c 2005-09-02 08:27:45.000000000 -0700
@@ -3799,7 +3799,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;
@@ -3821,8 +3825,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)
@@ -3852,38 +3857,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
{
@@ -3922,6 +3915,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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: readelf: Handle 64bit sh_flags
2005-09-02 16:43 PATCH: readelf: Handle 64bit sh_flags H. J. Lu
@ 2005-09-07 15:42 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2005-09-07 15:42 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils
Hi H. J.
> 2005-09-02 H.J. Lu <hongjiu.lu@intel.com>
>
> * readelf.c (get_elf_section_flags): Handle 64bit sh_flags.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-07 15:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-02 16:43 PATCH: readelf: Handle 64bit sh_flags H. J. Lu
2005-09-07 15:42 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).