]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Tolerate unknown attribute names
authorPetr Machata <pmachata@redhat.com>
Mon, 18 Oct 2010 21:10:51 +0000 (23:10 +0200)
committerPetr Machata <pmachata@redhat.com>
Mon, 18 Oct 2010 21:10:51 +0000 (23:10 +0200)
dwarflint/check_debug_abbrev.cc
dwarflint/check_debug_info.cc
dwarflint/tests/run-libdl-2.12.so.debug.sh

index b7e2f64af7b8b023ccba166a7ae723e0a4c52a00..d727328c58bd6c1769f5d9ae4cd783ac12e5817f 100644 (file)
@@ -381,7 +381,8 @@ namespace
                wr_error (where)
                  << "invalid or unknown name " << pri::hex (attrib_name)
                  << '.' << std::endl;
-               failed = true;
+               // libdw should handle unknown attribute, as long as
+               // the form is kosher.
                continue;
              }
 
@@ -390,7 +391,7 @@ namespace
            if (!inserted.second)
              {
                wr_error (where)
-                 << "duplicate attribute " << pri::attr (attrib_name)
+                 << "duplicate attribute " << *attribute
                  << " (first was at " << pri::hex (inserted.first->second)
                  << ")." << std::endl;
                // I think we may allow such files for high-level
@@ -416,7 +417,7 @@ namespace
                if (!cur->has_children)
                  wr_message (where,
                              cat (mc_die_rel, mc_acc_bloat, mc_impact_1))
-                   << "excessive DW_AT_sibling attribute at childless abbrev."
+                   << "superfluous DW_AT_sibling attribute at childless abbrev."
                    << std::endl;
              }
            if (attrib_name == DW_AT_ranges)
index afb8bbf8c75d90b4536aa15b9d2abd1d3b5e333a..63ea4c43cac227c57be16a2e79f5de611eca5c1d 100644 (file)
@@ -625,7 +625,8 @@ namespace
            attribute const *attribute = ver->get_attribute (it->name);
            int form_name = it->form;
            form const *form = ver->get_form (form_name);
-           if (ver->form_class (form, attribute) == cl_indirect)
+           if (attribute != NULL
+               && ver->form_class (form, attribute) == cl_indirect)
              {
                uint64_t value;
                if (!read_sc_value (&value, form->width (cu), ctx, &where))
@@ -637,7 +638,9 @@ namespace
                  return -1;
              }
 
-           dw_class cls = ver->form_class (form, attribute);
+           dw_class cls = attribute != NULL
+             ? ver->form_class (form, attribute)
+             : max_dw_class;
            if (cls == cl_indirect)
              {
                wr_error (&where, ": indirect form is again indirect.\n");
@@ -676,14 +679,11 @@ namespace
               relocation was made against.  */
            GElf_Sym **symbolp = NULL;
 
-           assert (form);
-           assert (attribute);
-
            static dw_class_set ref_classes
              (cl_reference, cl_loclistptr, cl_lineptr, cl_macptr,
               cl_rangelistptr);
 
-           if (ref_classes.test (cls))
+           if (cls != max_dw_class && ref_classes.test (cls))
              if (form->width (cu) == fw_8
                  && cu->head->offset_size == 4)
                wr_error (where)
@@ -780,7 +780,7 @@ namespace
                // error the second time now.
                wr_error (where)
                  << "can't read value of attribute "
-                 << *attribute << '.' << std::endl;
+                 << pri::attr (it->name) << '.' << std::endl;
                return -1;
              }
            if (storclass == sc_block)
@@ -812,9 +812,12 @@ namespace
                    << "unexpected relocation of " << pri::form (form_name)
                    << '.' << std::endl;
 
-               form_width_t width = form->width (cu);
-               relocate_one (&file, reloc, rel, width, &value, &where,
-                             reloc_target (form, attribute), symbolp);
+               if (attribute != NULL)
+                 {
+                   form_width_t width = form->width (cu);
+                   relocate_one (&file, reloc, rel, width, &value, &where,
+                                 reloc_target (form, attribute), symbolp);
+                 }
 
                if (relocatedp != NULL)
                  *relocatedp = true;
index 03838886d07e927f9085d9523280e9693af3c391..36ab399ae61b4c489606b42c0bd1fc9a2840aa6f 100755 (executable)
@@ -29,14 +29,15 @@ srcdir=$srcdir/tests
 
 testfiles libdl-2.12.so.debug
 
-# Here we test that the user gets all the citations in .debug_abbrev,
-# and that dwarflint doesn't bail out on first failure.
+# Here we test that dwarflint can tolerate invalid attribute name.
 testrun_compare ./dwarflint --check=@low --nognu libdl-2.12.so.debug <<EOF
 error: .debug_abbrev: abbr. attribute 0xbe: invalid or unknown name 0x2107.
 error: .debug_abbrev: abbr. attribute 0x330: invalid or unknown name 0x2107.
 error: .debug_abbrev: abbr. attribute 0xa28: invalid or unknown name 0x2107.
 error: .debug_abbrev: abbr. attribute 0x108e: invalid or unknown name 0x2107.
 error: .debug_abbrev: abbr. attribute 0x1300: invalid or unknown name 0x2107.
+error: .debug_line: table 4508: sequence of opcodes not terminated with DW_LNE_end_sequence.
+error: .debug_line: table 4606: sequence of opcodes not terminated with DW_LNE_end_sequence.
 EOF
 
 # Here we test proper support for DW_AT_GNU_vector