Fixes a problem displaying the contents of a binary containing corrupt debug
authorNick Clifton <nickc@redhat.com>
Thu, 26 Jun 2014 08:12:55 +0000 (09:12 +0100)
committerNick Clifton <nickc@redhat.com>
Thu, 26 Jun 2014 08:12:55 +0000 (09:12 +0100)
information, specifically a DW_AT_MIPS_linkage_name attribute that has a numeric
value rather than a string value.

PR binutils/16949
* dwarf2.c (is_str_attr): New function.
(find_abstract_instance_name): Use it to determine when an
attribute has a string value.

bfd/ChangeLog
bfd/dwarf2.c

index 9cd00df202b75d5dc5753e422f619df2b62f2e4c..ff972a2e920324572eb136224cf3887de07a42ec 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-26  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/16949
+       * dwarf2.c (is_str_attr): New function.
+       (find_abstract_instance_name): Use it to determine when an
+       attribute has a string value.
+
 2014-06-24  Alan Modra  <amodra@gmail.com>
 
        * elf32-ppc.c (ppc_elf_size_dynamic_sections): Arrange to keep
index 5e322ce14c9f1872112917f7600c0bd18a3a1e74..583504bf62344f6951fd1c1c91e6ef33281d55d6 100644 (file)
@@ -911,6 +911,14 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash)
   return abbrevs;
 }
 
+/* Returns true if the form is one which has a string value.  */
+
+static inline bfd_boolean
+is_str_attr (enum dwarf_form form)
+{
+  return form == DW_FORM_string || form == DW_FORM_strp || form == DW_FORM_GNU_strp_alt;
+}
+
 /* Read an attribute value described by an attribute form.  */
 
 static bfd_byte *
@@ -2201,7 +2209,7 @@ find_abstract_instance_name (struct comp_unit *unit,
                case DW_AT_name:
                  /* Prefer DW_AT_MIPS_linkage_name or DW_AT_linkage_name
                     over DW_AT_name.  */
-                 if (name == NULL)
+                 if (name == NULL && is_str_attr (attr.form))
                    name = attr.u.str;
                  break;
                case DW_AT_specification:
@@ -2209,7 +2217,10 @@ find_abstract_instance_name (struct comp_unit *unit,
                  break;
                case DW_AT_linkage_name:
                case DW_AT_MIPS_linkage_name:
-                 name = attr.u.str;
+                 /* PR 16949:  Corrupt debug info can place
+                    non-string forms into these attributes.  */
+                 if (is_str_attr (attr.name))
+                   name = attr.u.str;
                  break;
                default:
                  break;
@@ -2381,13 +2392,16 @@ scan_unit_for_symbols (struct comp_unit *unit)
                case DW_AT_name:
                  /* Prefer DW_AT_MIPS_linkage_name or DW_AT_linkage_name
                     over DW_AT_name.  */
-                 if (func->name == NULL)
+                 if (func->name == NULL && is_str_attr (attr.form))
                    func->name = attr.u.str;
                  break;
 
                case DW_AT_linkage_name:
                case DW_AT_MIPS_linkage_name:
-                 func->name = attr.u.str;
+                 /* PR 16949:  Corrupt debug info can place
+                    non-string forms into these attributes.  */
+                 if (is_str_attr (attr.form))
+                   func->name = attr.u.str;
                  break;
 
                case DW_AT_low_pc:
This page took 0.029157 seconds and 4 git commands to generate.