From: Petr Machata Date: Tue, 21 Sep 2010 20:47:34 +0000 (+0200) Subject: dwarflint: Move abbrev-related data structures to check_debug_abbrev X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6345d260512d36e99595fddfa0163ae2ae022e72;p=thirdparty%2Felfutils.git dwarflint: Move abbrev-related data structures to check_debug_abbrev --- diff --git a/dwarflint/check_debug_abbrev.cc b/dwarflint/check_debug_abbrev.cc index 8e6da4990..27effb5d3 100644 --- a/dwarflint/check_debug_abbrev.cc +++ b/dwarflint/check_debug_abbrev.cc @@ -77,18 +77,17 @@ check_debug_abbrev::descriptor () return &cd; } -struct abbrev * -abbrev_table_find_abbrev (struct abbrev_table const *abbrevs, - uint64_t abbrev_code) +abbrev * +abbrev_table::find_abbrev (uint64_t abbrev_code) const { size_t a = 0; - size_t b = abbrevs->size; + size_t b = size; struct abbrev *ab = NULL; while (a < b) { size_t i = (a + b) / 2; - ab = abbrevs->abbr + i; + ab = abbr + i; if (ab->code > abbrev_code) b = i; @@ -278,7 +277,7 @@ namespace assert (ver != NULL); } - struct abbrev *original = abbrev_table_find_abbrev (section, abbr_code); + struct abbrev *original = section->find_abbrev (abbr_code); if (unlikely (original != NULL)) wr_error (where) << "duplicate abbrev code " << abbr_code diff --git a/dwarflint/check_debug_abbrev.hh b/dwarflint/check_debug_abbrev.hh index dbd8eff6f..f905bd24f 100644 --- a/dwarflint/check_debug_abbrev.hh +++ b/dwarflint/check_debug_abbrev.hh @@ -26,11 +26,49 @@ #ifndef DWARFLINT_CHECK_DEBUG_ABBREV_HH #define DWARFLINT_CHECK_DEBUG_ABBREV_HH -#include "low.h" #include "checks.hh" #include "sections.ii" #include "check_debug_info.ii" +struct abbrev_attrib +{ + struct where where; + uint16_t name; + uint8_t form; +}; + +struct abbrev +{ + uint64_t code; + struct where where; + + /* Attributes. */ + struct abbrev_attrib *attribs; + size_t size; + size_t alloc; + + /* While ULEB128 can hold numbers > 32bit, these are not legal + values of many enum types. So just use as large type as + necessary to cover valid values. */ + uint16_t tag; + bool has_children; + + /* Whether some DIE uses this abbrev. */ + bool used; +}; + +struct abbrev_table +{ + struct abbrev_table *next; + struct abbrev *abbr; + uint64_t offset; + size_t size; + size_t alloc; + bool used; /* There are CUs using this table. */ + + abbrev *find_abbrev (uint64_t abbrev_code) const; +}; + class check_debug_abbrev : public check { diff --git a/dwarflint/check_debug_info.cc b/dwarflint/check_debug_info.cc index 48f58199a..8489819d8 100644 --- a/dwarflint/check_debug_info.cc +++ b/dwarflint/check_debug_info.cc @@ -597,7 +597,7 @@ namespace /* Find the abbrev matching the code. */ prev_abbrev = abbrev; - abbrev = abbrev_table_find_abbrev (abbrevs, abbr_code); + abbrev = abbrevs->find_abbrev (abbr_code); if (abbrev == NULL) { wr_error (where) diff --git a/dwarflint/low.h b/dwarflint/low.h index 76da44a1e..14728a6b4 100644 --- a/dwarflint/low.h +++ b/dwarflint/low.h @@ -39,8 +39,6 @@ extern "C" # include #endif - struct hl_ctx; - struct sec { GElf_Shdr shdr; @@ -71,22 +69,6 @@ extern "C" different from the host. */ }; - /* Check that .debug_aranges and .debug_ranges match. */ - extern bool elf_file_init (struct elf_file *file, Elf *elf); - - struct abbrev_table - { - struct abbrev_table *next; - struct abbrev *abbr; - uint64_t offset; - size_t size; - size_t alloc; - bool used; /* There are CUs using this table. */ - }; - - // xxx some of that will go away - extern struct abbrev *abbrev_table_find_abbrev (struct abbrev_table const *abbrevs, - uint64_t abbrev_code); extern bool address_aligned (uint64_t addr, uint64_t align); extern bool necessary_alignment (uint64_t start, uint64_t length, uint64_t align); @@ -112,33 +94,6 @@ extern "C" bool allow_overlap; }; - struct abbrev_attrib - { - struct where where; - uint16_t name; - uint8_t form; - }; - - struct abbrev - { - uint64_t code; - struct where where; - - /* Attributes. */ - struct abbrev_attrib *attribs; - size_t size; - size_t alloc; - - /* While ULEB128 can hold numbers > 32bit, these are not legal - values of many enum types. So just use as large type as - necessary to cover valid values. */ - uint16_t tag; - bool has_children; - - /* Whether some DIE uses this abbrev. */ - bool used; - }; - struct cu_head { uint64_t offset;