*/
int
read_die_chain (dwarf_version_h ver,
- struct elf_file *file,
+ elf_file const &file,
struct read_ctx *ctx,
struct cu *cu,
struct abbrev_table const *abbrevs,
enum message_category extra_mc = mc_none;
uint64_t ctx_offset = read_ctx_get_offset (ctx) + cu->head->offset;
- bool type_is_rel = file->ehdr.e_type == ET_REL;
+ bool type_is_rel = file.ehdr.e_type == ET_REL;
/* Attribute value. */
uint64_t value = 0;
<< "unexpected relocation of " << pri::form (form) << '.'
<< std::endl;
- relocate_one (file, reloc, rel, width, &value, &where,
+ relocate_one (&file, reloc, rel, width, &value, &where,
reloc_target (form, it), symbolp);
if (relocatedp != NULL)
<< std::endl;
else
check_range_relocations (mc_die_other, &where,
- file,
+ &file,
low_pc_symbol, high_pc_symbol,
"DW_AT_low_pc and DW_AT_high_pc");
}
}
}
+read_cu_headers::read_cu_headers (dwarflint &lint)
+ : _m_sec_info (lint.check (_m_sec_info))
+ , cu_headers (read_info_headers (&_m_sec_info->file,
+ &_m_sec_info->sect,
+ _m_sec_info->reldata ()))
+{
+}
+
bool
-check_debug_info::check_cu_structural (struct elf_file *file,
- struct read_ctx *ctx,
+check_debug_info::check_cu_structural (struct read_ctx *ctx,
struct cu *const cu,
Elf_Data *strings,
struct coverage *strings_coverage,
- struct relocation_data *reloc,
- struct cu_coverage *cu_coverage)
+ struct relocation_data *reloc)
{
check_debug_abbrev::abbrev_map const &abbrev_tables = _m_abbrevs->abbrevs;
WIPE (local_die_refs);
cu->cudie_offset = read_ctx_get_offset (ctx) + cu->head->offset;
- if (read_die_chain (ver, file, ctx, cu, &abbrevs, strings,
+ if (read_die_chain (ver, _m_file, ctx, cu, &abbrevs, strings,
&local_die_refs, strings_coverage,
(reloc != NULL && reloc->size > 0) ? reloc : NULL,
- cu_coverage) < 0)
+ &cu_cov) < 0)
{
_m_abbr_skip.push_back (abbrevs.offset);
retval = false;
return retval;
}
-read_cu_headers::read_cu_headers (dwarflint &lint)
- : _m_sec_info (lint.check (_m_sec_info))
- , cu_headers (read_info_headers (&_m_sec_info->file,
- &_m_sec_info->sect,
- _m_sec_info->reldata ()))
-{
-}
-
void
-check_debug_info::check_info_structural (struct elf_file *file,
- Elf_Data *strings)
+check_debug_info::check_info_structural ()
{
std::vector <cu_head> const &cu_headers = _m_cu_headers->cu_headers;
sec &sec = _m_sec_info->sect;
+ Elf_Data *const strings = _m_sec_str->sect.data;
+
struct ref_record die_refs;
WIPE (die_refs);
relocation_reset (reloc);
struct read_ctx ctx;
- read_ctx_init (&ctx, sec.data, file->other_byte_order);
+ read_ctx_init (&ctx, sec.data, _m_file.other_byte_order);
for (std::vector <cu_head>::const_iterator it = cu_headers.begin ();
it != cu_headers.end (); ++it)
{
read_ctx_init_sub (&cu_ctx, &ctx, ctx.ptr, cu_end);
cu_ctx.ptr += head.head_size;
- if (!check_cu_structural (file, &cu_ctx, &cur,
- strings, strings_coverage, reloc,
- &cu_cov))
+ if (!check_cu_structural (&cu_ctx, &cur,
+ strings, strings_coverage, reloc))
{
success = false;
break;
: _m_sec_info (lint.check (_m_sec_info))
, _m_sec_abbrev (lint.check (_m_sec_abbrev))
, _m_sec_str (lint.check (_m_sec_str))
+ , _m_file (_m_sec_info->file)
, _m_abbrevs (lint.check (_m_abbrevs))
, _m_cu_headers (lint.check (_m_cu_headers))
{
memset (&cu_cov, 0, sizeof (cu_cov));
- check_info_structural (&_m_sec_info->file, _m_sec_str->sect.data);
+ check_info_structural ();
// re-link CUs so that they form a chain again. This is to
// interface with C-level code. The last CU's next is NULL, so we
section<sec_info> *_m_sec_info;
section<sec_abbrev> *_m_sec_abbrev;
section<sec_str> *_m_sec_str;
+ elf_file const &_m_file;
check_debug_abbrev *_m_abbrevs;
read_cu_headers *_m_cu_headers;
// validation. Check for unused abbrevs should be skipped.
std::vector< ::Dwarf_Off> _m_abbr_skip;
- bool check_cu_structural (struct elf_file *file,
- struct read_ctx *ctx,
+ bool check_cu_structural (struct read_ctx *ctx,
struct cu *const cu,
Elf_Data *strings,
struct coverage *strings_coverage,
- struct relocation_data *reloc,
- struct cu_coverage *cu_coverage);
+ struct relocation_data *reloc);
- void check_info_structural (elf_file *file,
- Elf_Data *strings);
+ void check_info_structural ();
public:
// The check pass adds all low_pc/high_pc ranges loaded from DIE
if (!read_ctx_read_2ubyte (&ctx, &len))
{
- wr_error (&where, ": can't read length of location expression.\n");
+ wr_error (where)
+ << "can't read length of location expression."
+ << std::endl;
return false;
}
/* location expression itself */
uint64_t expr_start = read_ctx_get_offset (&ctx);
- if (!check_location_expression (file, &ctx, cu, expr_start,
+ if (!check_location_expression (*file, &ctx, cu, expr_start,
&sec->rel, len, &where))
return false;
uint64_t expr_end = read_ctx_get_offset (&ctx);
}
bool
- op_read_form (struct elf_file *file,
+ op_read_form (struct elf_file const &file,
struct read_ctx *ctx,
struct cu *cu,
uint64_t init_off,
where, skip_mismatched)))
{
if (!isblock)
- relocate_one (file, reloc, rel,
+ relocate_one (&file, reloc, rel,
cu->head->address_size, valuep, where,
reloc_target_loc (opcode), NULL);
else
}
bool
-check_location_expression (struct elf_file *file,
+check_location_expression (elf_file const &file,
struct read_ctx *parent_ctx,
struct cu *cu,
uint64_t init_off,