diff options
author | Petr Machata <pmachata@redhat.com> | 2011-02-23 20:44:34 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2011-02-23 20:44:34 +0100 |
commit | c9ce330e45f7ff68658f67abd57103ead8bb2f55 (patch) | |
tree | dc6c5a2eb76f322955e5dd0f23bbeff6c8aed4d8 | |
parent | 89d49fd98e52938636e23dbfc4b709d40e83a0d2 (diff) | |
download | elfutils-c9ce330e45f7ff68658f67abd57103ead8bb2f55.tar.gz |
dwarflint: form::width takes cu_head, not cu argument
- also the argument may be NULL, in which case the width may end up being
fw_unknown
-rw-r--r-- | dwarflint/check_debug_info.cc | 11 | ||||
-rw-r--r-- | dwarflint/check_debug_loc_range.cc | 4 | ||||
-rw-r--r-- | dwarflint/dwarf_version.cc | 28 | ||||
-rw-r--r-- | dwarflint/dwarf_version.hh | 6 |
4 files changed, 31 insertions, 18 deletions
diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index 63ea4c43..a89d90d2 100644 --- a/dwarflint/check_debug_info.cc +++ b/dwarflint/check_debug_info.cc @@ -1,6 +1,6 @@ /* Routines related to .debug_info. - Copyright (C) 2009, 2010 Red Hat, Inc. + Copyright (C) 2009, 2010, 2011 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -629,7 +629,8 @@ namespace && ver->form_class (form, attribute) == cl_indirect) { uint64_t value; - if (!read_sc_value (&value, form->width (cu), ctx, &where)) + if (!read_sc_value (&value, form->width (cu->head), + ctx, &where)) return -1; form_name = value; form = check_debug_abbrev::check_form @@ -684,7 +685,7 @@ namespace cl_rangelistptr); if (cls != max_dw_class && ref_classes.test (cls)) - if (form->width (cu) == fw_8 + if (form->width (cu->head) == fw_8 && cu->head->offset_size == 4) wr_error (where) << "reference attribute with form \"" @@ -773,7 +774,7 @@ namespace read_ctx block; storage_class_t storclass = form->storage_class (); - if (!read_generic_value (ctx, form->width (cu), storclass, + if (!read_generic_value (ctx, form->width (cu->head), storclass, &where, &value, &block)) { // Note that for fw_uleb and fw_sleb we report the @@ -814,7 +815,7 @@ namespace if (attribute != NULL) { - form_width_t width = form->width (cu); + form_width_t width = form->width (cu->head); relocate_one (&file, reloc, rel, width, &value, &where, reloc_target (form, attribute), symbolp); } diff --git a/dwarflint/check_debug_loc_range.cc b/dwarflint/check_debug_loc_range.cc index f3b5f5a4..e64b07c9 100644 --- a/dwarflint/check_debug_loc_range.cc +++ b/dwarflint/check_debug_loc_range.cc @@ -1,6 +1,6 @@ /* Routines related to .debug_loc and .debug_range. - Copyright (C) 2009, 2010 Red Hat, Inc. + Copyright (C) 2009, 2010, 2011 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -791,7 +791,7 @@ namespace storage_class_t storclass = form->storage_class (); assert (storclass != sc_string); - if (!read_generic_value (ctx, form->width (cu), storclass, + if (!read_generic_value (ctx, form->width (cu->head), storclass, where, valuep, NULL)) { wr_error (*where) diff --git a/dwarflint/dwarf_version.cc b/dwarflint/dwarf_version.cc index 9b4ebaaf..e611a833 100644 --- a/dwarflint/dwarf_version.cc +++ b/dwarflint/dwarf_version.cc @@ -1,5 +1,5 @@ /* Pedantic checking of DWARF files - Copyright (C) 2009,2010 Red Hat, Inc. + Copyright (C) 2009,2010,2011 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -27,6 +27,10 @@ // version. Apart from standardized DWARF formats, e.g. DWARF3+GNU is // a version of its own. +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include "dwarf_version.hh" #include "dwarf_2.hh" #include "dwarf_3.hh" @@ -89,14 +93,22 @@ dwarf_version::form_class (form const *form, attribute const *attribute) const } form_width_t -form::width (cu const *cu) const +form::width (cu_head const *cu_head) const { - if (_m_width == fw_offset) - return static_cast<form_width_t> (cu->head->offset_size); - else if (_m_width == fw_address) - return static_cast<form_width_t> (cu->head->address_size); - else - return static_cast<form_width_t> (_m_width); + switch (_m_width) + { + case fw_offset: + case fw_address: + if (unlikely (cu_head == NULL)) + return fw_unknown; + if (_m_width == fw_offset) + return static_cast<form_width_t> (cu_head->offset_size); + else + return static_cast<form_width_t> (cu_head->address_size); + + default: + return static_cast<form_width_t> (_m_width); + } } std::ostream & diff --git a/dwarflint/dwarf_version.hh b/dwarflint/dwarf_version.hh index f3bee10b..1d397817 100644 --- a/dwarflint/dwarf_version.hh +++ b/dwarflint/dwarf_version.hh @@ -1,6 +1,6 @@ /* Dwarf version tables. - Copyright (C) 2009, 2010 Red Hat, Inc. + Copyright (C) 2009, 2010, 2011 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -122,8 +122,8 @@ public: /// /// Return value is never fw_offset or fw_address. These get /// resolved to fw_4 or fw_8 depending on corresponding value in - /// CU->head. - form_width_t width (cu const *cu) const; + /// CU_HEAD. + form_width_t width (cu_head const *cu_head) const; /// Return storage class of given form. Closely related to width. storage_class_t |