dwarf2_build_psymtabs_hard (objfile);
}
+/* Return the total length of the CU described by HEADER. */
+
+static unsigned int
+get_cu_length (const struct comp_unit_head *header)
+{
+ return header->initial_length_size + header->length;
+}
+
/* Return TRUE if OFFSET is within CU_HEADER. */
static inline int
offset_in_cu_p (const struct comp_unit_head *cu_header, sect_offset offset)
{
sect_offset bottom = { cu_header->offset.sect_off };
- sect_offset top = { (cu_header->offset.sect_off + cu_header->length
- + cu_header->initial_length_size) };
+ sect_offset top = { cu_header->offset.sect_off + get_cu_length (cu_header) };
return (offset.sect_off >= bottom.sect_off && offset.sect_off < top.sect_off);
}
/* Cast to unsigned long to use 64-bit arithmetic when possible to
avoid potential 32-bit overflow. */
- if (((unsigned long) header->offset.sect_off
- + header->length + header->initial_length_size)
+ if (((unsigned long) header->offset.sect_off + get_cu_length (header))
> section->size)
error (_("Dwarf Error: bad length (0x%lx) in compilation unit header "
"(offset 0x%lx + 0) [in module %s]"),
abbrev_section, ptr,
&signature, &type_offset_in_tu);
- length = header.initial_length_size + header.length;
+ length = get_cu_length (&header);
/* Skip dummy type units. */
if (ptr >= info_ptr + length
|| peek_abbrev_code (abfd, ptr) == 0)
{
- info_ptr += header.initial_length_size + header.length;
+ info_ptr += length;
continue;
}
gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
/* LENGTH has not been set yet for type units. */
- this_cu->length = cu->header.length + cu->header.initial_length_size;
+ this_cu->length = get_cu_length (&cu->header);
/* Establish the type offset that can be used to lookup the type. */
sig_type->type_offset_in_section.sect_off =
info_ptr, 0);
gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
- gdb_assert (this_cu->length
- == cu->header.length + cu->header.initial_length_size);
+ gdb_assert (this_cu->length == get_cu_length (&cu->header));
}
}
&signature, NULL);
gdb_assert (sig_type->signature == signature);
gdb_assert (dwo_unit->offset.sect_off == cu->header.offset.sect_off);
- gdb_assert (dwo_unit->length
- == cu->header.length + cu->header.initial_length_size);
+ gdb_assert (dwo_unit->length == get_cu_length (&cu->header));
/* Establish the type offset that can be used to lookup the type.
For DWO files, we don't know it until now. */
dwo_abbrev_section,
info_ptr, 0);
gdb_assert (dwo_unit->offset.sect_off == cu->header.offset.sect_off);
- gdb_assert (dwo_unit->length
- == cu->header.length + cu->header.initial_length_size);
+ gdb_assert (dwo_unit->length == get_cu_length (&cu->header));
}
/* Discard the original CU's abbrev table, and read the DWO's. */
abbrev_section, info_ptr,
this_cu->is_debug_types);
- this_cu->length = cu.header.length + cu.header.initial_length_size;
+ this_cu->length = get_cu_length (&cu.header);
/* Skip dummy compilation units. */
if (info_ptr >= begin_info_ptr + this_cu->length