From: Petr Machata Date: Mon, 18 Oct 2010 21:10:51 +0000 (+0200) Subject: dwarflint: Tolerate unknown attribute names X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b587bd8753e63d5463bdcf715819dc31ecb8de01;p=thirdparty%2Felfutils.git dwarflint: Tolerate unknown attribute names --- diff --git a/dwarflint/check_debug_abbrev.cc b/dwarflint/check_debug_abbrev.cc index b7e2f64af..d727328c5 100644 --- a/dwarflint/check_debug_abbrev.cc +++ b/dwarflint/check_debug_abbrev.cc @@ -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) diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index afb8bbf8c..63ea4c43c 100644 --- a/dwarflint/check_debug_info.cc +++ b/dwarflint/check_debug_info.cc @@ -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; diff --git a/dwarflint/tests/run-libdl-2.12.so.debug.sh b/dwarflint/tests/run-libdl-2.12.so.debug.sh index 03838886d..36ab399ae 100755 --- a/dwarflint/tests/run-libdl-2.12.so.debug.sh +++ b/dwarflint/tests/run-libdl-2.12.so.debug.sh @@ -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 <