aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2001-11-07 16:14:09 +0000
committerJakub Jelinek <jakub@redhat.com>2001-11-07 16:14:09 +0000
commitef5cdfc7ddd53e80fed2c3b6e6ee9c57f7b29c35 (patch)
treeb0084888360047d629c98a04887093e0c8eb0c53 /binutils
parenta4a7d16f8b4f210e0ccfd574c5c44f98953791dd (diff)
downloadgdb-ef5cdfc7ddd53e80fed2c3b6e6ee9c57f7b29c35.zip
gdb-ef5cdfc7ddd53e80fed2c3b6e6ee9c57f7b29c35.tar.gz
gdb-ef5cdfc7ddd53e80fed2c3b6e6ee9c57f7b29c35.tar.bz2
* readelf.c (debug_str, debug_str_size): New.
(display_debug_abbrev): If no abbrevs were read, skip the CU. Call free_abbrevs. (read_and_display_addr): Handle DW_FORM_strp. (display_debug_info): Read .debug_str section if present, so that DW_FORM_strp can be handled. Fix test for non-existant .debug_abbrev section.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog10
-rw-r--r--binutils/readelf.c48
2 files changed, 57 insertions, 1 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index bc8fc57..25eea86 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,13 @@
+2001-11-07 Jakub Jelinek <jakub@redhat.com>
+
+ * readelf.c (debug_str, debug_str_size): New.
+ (display_debug_abbrev): If no abbrevs were read, skip the CU.
+ Call free_abbrevs.
+ (read_and_display_addr): Handle DW_FORM_strp.
+ (display_debug_info): Read .debug_str section if present,
+ so that DW_FORM_strp can be handled.
+ Fix test for non-existant .debug_abbrev section.
+
2001-11-05 Jakub Jelinek <jakub@redhat.com>
* arlex.l: Accept `\' in filenames. Patch by <earl_chew@agilent.com>.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 675912f..5987ca6 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -6278,6 +6278,9 @@ get_FORM_name (form)
}
}
+static const char *debug_str;
+static bfd_vma debug_str_size;
+
/* FIXME: There are better and more effiecint ways to handle
these structures. For now though, I just want something that
is simple to implement. */
@@ -6528,6 +6531,9 @@ display_debug_abbrev (section, start, file)
{
start = process_abbrev_section (start, end);
+ if (first_abbrev == NULL)
+ continue;
+
printf (_(" Number TAG\n"));
for (entry = first_abbrev; entry; entry = entry->next)
@@ -6546,6 +6552,8 @@ display_debug_abbrev (section, start, file)
get_FORM_name (attr->form));
}
}
+
+ free_abbrevs ();
}
while (start);
@@ -6921,6 +6929,11 @@ read_and_display_attr (attribute, form, data, cu_offset, pointer_size)
data += pointer_size;
break;
+ case DW_FORM_strp:
+ uvalue = byte_get (data, /* offset_size */ 4);
+ data += /* offset_size */ 4;
+ break;
+
case DW_FORM_ref1:
case DW_FORM_flag:
case DW_FORM_data1:
@@ -7014,6 +7027,15 @@ read_and_display_attr (attribute, form, data, cu_offset, pointer_size)
break;
case DW_FORM_strp:
+ if (debug_str == NULL)
+ warn (_("DW_FORM_strp used but no .debug_str section"));
+ else if (uvalue >= debug_str_size)
+ warn (_("DW_FORM_strp %lx points outside of .debug_str section"),
+ uvalue);
+ else
+ printf (" %s", debug_str + uvalue);
+ break;
+
case DW_FORM_indirect:
warn (_("Unable to handle FORM: %d"), form);
break;
@@ -7189,6 +7211,24 @@ display_debug_info (section, start, file)
printf (_("The section %s contains:\n\n"), SECTION_NAME (section));
+ {
+ Elf32_Internal_Shdr * sec;
+ int i;
+
+ /* Locate the .debug_str section and read it. */
+ for (i = 0, sec = section_headers;
+ i < elf_header.e_shnum;
+ i ++, sec ++)
+ if (strcmp (SECTION_NAME (sec), ".debug_str") == 0 && sec->sh_size != 0)
+ {
+ debug_str = (const char *)
+ get_data (NULL, file, sec->sh_offset, sec->sh_size,
+ _("debug_str section data"));
+ debug_str_size = sec->sh_size;
+ break;
+ }
+ }
+
while (start < end)
{
DWARF2_External_CompUnit * external;
@@ -7306,7 +7346,7 @@ display_debug_info (section, start, file)
if (strcmp (SECTION_NAME (sec), ".debug_abbrev") == 0)
break;
- if (i == -1 || sec->sh_size == 0)
+ if (i == elf_header.e_shnum || sec->sh_size == 0)
{
warn (_("Unable to locate .debug_abbrev section!\n"));
return 0;
@@ -7373,6 +7413,12 @@ display_debug_info (section, start, file)
}
}
+ if (debug_str != NULL)
+ {
+ free ((char *) debug_str);
+ debug_str = NULL;
+ }
+
printf ("\n");
return 1;