From 40ee5a5b795f4894fbb6605596e56bc7ef3034aa Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Wed, 21 Oct 2009 23:39:09 +0200 Subject: [PATCH] dwarflint: Move ref_record to addr-record.h/.cc --- src/dwarflint/addr-record.cc | 16 +++++++++++ src/dwarflint/addr-record.h | 53 ++++++++++++++++++++++++++---------- src/dwarflint/low.c | 28 ------------------- src/dwarflint/low.h | 13 --------- 4 files changed, 54 insertions(+), 56 deletions(-) diff --git a/src/dwarflint/addr-record.cc b/src/dwarflint/addr-record.cc index 6eb4dac7f..fb8c778a5 100644 --- a/src/dwarflint/addr-record.cc +++ b/src/dwarflint/addr-record.cc @@ -56,3 +56,19 @@ addr_record_free (struct addr_record *ar) if (ar != NULL) free (ar->addrs); } + +void +ref_record_add (struct ref_record *rr, uint64_t addr, struct where *referrer) +{ + REALLOC (rr, refs); + struct ref *ref = rr->refs + rr->size++; + ref->addr = addr; + ref->who = *referrer; +} + +void +ref_record_free (struct ref_record *rr) +{ + if (rr != NULL) + free (rr->refs); +} diff --git a/src/dwarflint/addr-record.h b/src/dwarflint/addr-record.h index 95185ffd2..042af2a5d 100644 --- a/src/dwarflint/addr-record.h +++ b/src/dwarflint/addr-record.h @@ -3,6 +3,7 @@ #include #include +#include "where.h" #ifdef __cplusplus extern "C" { @@ -10,22 +11,44 @@ extern "C" # include #endif -/* Functions and data structures for address record handling. We use - that to check that all DIE references actually point to an existing - die, not somewhere mid-DIE, where it just happens to be - interpretable as a DIE. */ + /* Functions and data structures for address record handling. We + use that to check that all DIE references actually point to an + existing die, not somewhere mid-DIE, where it just happens to be + interpretable as a DIE. */ -struct addr_record -{ - size_t size; - size_t alloc; - uint64_t *addrs; -}; - -size_t addr_record_find_addr (struct addr_record *ar, uint64_t addr); -bool addr_record_has_addr (struct addr_record *ar, uint64_t addr); -void addr_record_add (struct addr_record *ar, uint64_t addr); -void addr_record_free (struct addr_record *ar); + struct addr_record + { + size_t size; + size_t alloc; + uint64_t *addrs; + }; + + size_t addr_record_find_addr (struct addr_record *ar, uint64_t addr); + bool addr_record_has_addr (struct addr_record *ar, uint64_t addr); + void addr_record_add (struct addr_record *ar, uint64_t addr); + void addr_record_free (struct addr_record *ar); + + /* Functions and data structures for reference handling. Just like + the above, we use this to check validity of DIE references. + Unlike the above, this is not stored as sorted set, but simply as + an array of records, because duplicates are unlikely. */ + + struct ref + { + uint64_t addr; // Referree address + struct where who; // Referrer + }; + + struct ref_record + { + size_t size; + size_t alloc; + struct ref *refs; + }; + + void ref_record_add (struct ref_record *rr, uint64_t addr, + struct where *referrer); + void ref_record_free (struct ref_record *rr); #ifdef __cplusplus } diff --git a/src/dwarflint/low.c b/src/dwarflint/low.c index 02a2ee111..0f748232c 100644 --- a/src/dwarflint/low.c +++ b/src/dwarflint/low.c @@ -66,18 +66,6 @@ check_category (enum message_category cat) #define PRI_LACK_RELOCATION ": %s seems to lack a relocation.\n" -/* Functions and data structures related to raw (i.e. unassisted by - libdw) Dwarf abbreviation handling. */ - - -/* Functions and data structures for reference handling. Just like - the above, we use this to check validity of DIE references. Unlike - the above, this is not stored as sorted set, but simply as an array - of records, because duplicates are unlikely. */ - -static void ref_record_add (struct ref_record *rr, uint64_t addr, struct where *referrer); -static void ref_record_free (struct ref_record *rr); - static struct cu *cu_find_cu (struct cu *cu_chain, uint64_t offset); static bool check_location_expression (struct elf_file *file, @@ -600,22 +588,6 @@ abbrev_table_find_abbrev (struct abbrev_table *abbrevs, uint64_t abbrev_code) return NULL; } -static void -ref_record_add (struct ref_record *rr, uint64_t addr, struct where *referrer) -{ - REALLOC (rr, refs); - struct ref *ref = rr->refs + rr->size++; - ref->addr = addr; - ref->who = *referrer; -} - -static void -ref_record_free (struct ref_record *rr) -{ - if (rr != NULL) - free (rr->refs); -} - bool found_hole (uint64_t start, uint64_t length, void *data) { diff --git a/src/dwarflint/low.h b/src/dwarflint/low.h index 5a0f2836e..9a651c339 100644 --- a/src/dwarflint/low.h +++ b/src/dwarflint/low.h @@ -226,19 +226,6 @@ extern "C" abbrevs should be skipped. */ }; - struct ref - { - uint64_t addr; // Referree address - struct where who; // Referrer - }; - - struct ref_record - { - size_t size; - size_t alloc; - struct ref *refs; - }; - struct cu { struct cu *next; -- 2.47.3