This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Minor tidyups to readelf.c
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Mon, 23 May 2005 13:12:26 +0100
- Subject: [PATCH] Minor tidyups to readelf.c
Hi Guys,
I am applying the patch below to fix a couple of minor quibbles with
readelf. I have had this patch lying around in my own tree for a
while and I finally decided that I ought to contribute it and be
done. The changes affect the DWARF2 decoding and display and they
are:
* When a corrupt DW_FORM_strp is detected, print a warning message
to stderr as well as in the normal output, I found this very
useful because a) GDB emits such a message and readelf did not
and b) I often filter out and ignore the messages that readelf
sends to stdout and only look at the messages sent to stderr - ie
using readelf to verify the correctness, or otherwise, of the
DWARF debug information in a file.
* When displaying the header for a compilation unit in the
.debug_info section mention that the value is an offset and that
the value is in hexadecimal.
* Correct a typo, the debug line information section is called
.debug_line and not .debug_lines.
Cheers
Nick
binutils/ChangeLog
2005-05-23 Nick Clifton <nickc@redhat.com>
* readelf.c (fetch_indirect_string): Display a warning message
when a corrupt DW_FORM_strp value is encountered.
(process_debug_info): Mention that the compilation unit offset is
being displayed in hexadecimal.
(display_debug_lines): Fix typo in name of .debug_line section.
Index: readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.295
diff -c -3 -p -r1.295 readelf.c
*** readelf.c 18 May 2005 22:42:08 -0000 1.295
--- readelf.c 23 May 2005 12:02:43 -0000
*************** fetch_indirect_string (unsigned long off
*** 7269,7275 ****
return _("<no .debug_str section>");
if (offset > debug_str_size)
! return _("<offset is too big>");
return debug_str_contents + offset;
}
--- 7269,7278 ----
return _("<no .debug_str section>");
if (offset > debug_str_size)
! {
! warn (_("DW_FORM_strp offset too big: %x\n"), offset);
! return _("<offset is too big>");
! }
return debug_str_contents + offset;
}
*************** process_debug_info (Elf_Internal_Shdr *s
*** 8800,8806 ****
if (!do_loc)
{
! printf (_(" Compilation Unit @ %lx:\n"), cu_offset);
printf (_(" Length: %ld\n"), compunit.cu_length);
printf (_(" Version: %d\n"), compunit.cu_version);
printf (_(" Abbrev Offset: %ld\n"), compunit.cu_abbrev_offset);
--- 8803,8809 ----
if (!do_loc)
{
! printf (_(" Compilation Unit @ offset 0x%lx:\n"), cu_offset);
printf (_(" Length: %ld\n"), compunit.cu_length);
printf (_(" Version: %d\n"), compunit.cu_version);
printf (_(" Abbrev Offset: %ld\n"), compunit.cu_abbrev_offset);
*************** display_debug_lines (Elf_Internal_Shdr *
*** 9088,9094 ****
/* Get the pointer size from the comp unit associated
with this block of line number information. */
pointer_size = get_pointer_size_and_offset_of_comp_unit
! (comp_unit, ".debug_lines", NULL);
comp_unit ++;
printf (_(" Length: %ld\n"), info.li_length);
--- 9091,9097 ----
/* Get the pointer size from the comp unit associated
with this block of line number information. */
pointer_size = get_pointer_size_and_offset_of_comp_unit
! (comp_unit, ".debug_line", NULL);
comp_unit ++;
printf (_(" Length: %ld\n"), info.li_length);