#include <stdlib.h>
#include <stdint.h>
+#include "where.h"
#ifdef __cplusplus
extern "C"
{
# include <stdbool.h>
#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
}
#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,
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)
{