* dwarf2read.c (get_cu_length): New function.
(offset_in_cu_p, error_check_comp_unit_head): Call it. (create_debug_types_hash_table): Ditto. (init_cutu_and_read_dies): Ditto. (init_cutu_and_read_dies_no_follow): Ditto.
This commit is contained in:
parent
3b80fe9b75
commit
1ce1cefd3d
|
@ -1,5 +1,11 @@
|
||||||
2012-06-28 Doug Evans <dje@google.com>
|
2012-06-28 Doug Evans <dje@google.com>
|
||||||
|
|
||||||
|
* dwarf2read.c (get_cu_length): New function.
|
||||||
|
(offset_in_cu_p, error_check_comp_unit_head): Call it.
|
||||||
|
(create_debug_types_hash_table): Ditto.
|
||||||
|
(init_cutu_and_read_dies): Ditto.
|
||||||
|
(init_cutu_and_read_dies_no_follow): Ditto.
|
||||||
|
|
||||||
* dwarf2read.c (dwarf2_find_base_address): Move definition.
|
* dwarf2read.c (dwarf2_find_base_address): Move definition.
|
||||||
|
|
||||||
* dwarf2read.c (ABBREV_HASH_SIZE): Remove enclosing #ifndef/#endif.
|
* dwarf2read.c (ABBREV_HASH_SIZE): Remove enclosing #ifndef/#endif.
|
||||||
|
|
|
@ -3359,14 +3359,21 @@ dwarf2_build_psymtabs (struct objfile *objfile)
|
||||||
dwarf2_build_psymtabs_hard (objfile);
|
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. */
|
/* Return TRUE if OFFSET is within CU_HEADER. */
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
offset_in_cu_p (const struct comp_unit_head *cu_header, sect_offset offset)
|
offset_in_cu_p (const struct comp_unit_head *cu_header, sect_offset offset)
|
||||||
{
|
{
|
||||||
sect_offset bottom = { cu_header->offset.sect_off };
|
sect_offset bottom = { cu_header->offset.sect_off };
|
||||||
sect_offset top = { (cu_header->offset.sect_off + cu_header->length
|
sect_offset top = { cu_header->offset.sect_off + get_cu_length (cu_header) };
|
||||||
+ cu_header->initial_length_size) };
|
|
||||||
|
|
||||||
return (offset.sect_off >= bottom.sect_off && offset.sect_off < top.sect_off);
|
return (offset.sect_off >= bottom.sect_off && offset.sect_off < top.sect_off);
|
||||||
}
|
}
|
||||||
|
@ -3460,8 +3467,7 @@ error_check_comp_unit_head (struct comp_unit_head *header,
|
||||||
|
|
||||||
/* Cast to unsigned long to use 64-bit arithmetic when possible to
|
/* Cast to unsigned long to use 64-bit arithmetic when possible to
|
||||||
avoid potential 32-bit overflow. */
|
avoid potential 32-bit overflow. */
|
||||||
if (((unsigned long) header->offset.sect_off
|
if (((unsigned long) header->offset.sect_off + get_cu_length (header))
|
||||||
+ header->length + header->initial_length_size)
|
|
||||||
> section->size)
|
> section->size)
|
||||||
error (_("Dwarf Error: bad length (0x%lx) in compilation unit header "
|
error (_("Dwarf Error: bad length (0x%lx) in compilation unit header "
|
||||||
"(offset 0x%lx + 0) [in module %s]"),
|
"(offset 0x%lx + 0) [in module %s]"),
|
||||||
|
@ -3714,13 +3720,13 @@ create_debug_types_hash_table (struct dwo_file *dwo_file,
|
||||||
abbrev_section, ptr,
|
abbrev_section, ptr,
|
||||||
&signature, &type_offset_in_tu);
|
&signature, &type_offset_in_tu);
|
||||||
|
|
||||||
length = header.initial_length_size + header.length;
|
length = get_cu_length (&header);
|
||||||
|
|
||||||
/* Skip dummy type units. */
|
/* Skip dummy type units. */
|
||||||
if (ptr >= info_ptr + length
|
if (ptr >= info_ptr + length
|
||||||
|| peek_abbrev_code (abfd, ptr) == 0)
|
|| peek_abbrev_code (abfd, ptr) == 0)
|
||||||
{
|
{
|
||||||
info_ptr += header.initial_length_size + header.length;
|
info_ptr += length;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3940,7 +3946,7 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
|
||||||
gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
|
gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
|
||||||
|
|
||||||
/* LENGTH has not been set yet for type units. */
|
/* 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. */
|
/* Establish the type offset that can be used to lookup the type. */
|
||||||
sig_type->type_offset_in_section.sect_off =
|
sig_type->type_offset_in_section.sect_off =
|
||||||
|
@ -3953,8 +3959,7 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
|
||||||
info_ptr, 0);
|
info_ptr, 0);
|
||||||
|
|
||||||
gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
|
gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
|
||||||
gdb_assert (this_cu->length
|
gdb_assert (this_cu->length == get_cu_length (&cu->header));
|
||||||
== cu->header.length + cu->header.initial_length_size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4079,8 +4084,7 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
|
||||||
&signature, NULL);
|
&signature, NULL);
|
||||||
gdb_assert (sig_type->signature == signature);
|
gdb_assert (sig_type->signature == signature);
|
||||||
gdb_assert (dwo_unit->offset.sect_off == cu->header.offset.sect_off);
|
gdb_assert (dwo_unit->offset.sect_off == cu->header.offset.sect_off);
|
||||||
gdb_assert (dwo_unit->length
|
gdb_assert (dwo_unit->length == get_cu_length (&cu->header));
|
||||||
== cu->header.length + cu->header.initial_length_size);
|
|
||||||
|
|
||||||
/* Establish the type offset that can be used to lookup the type.
|
/* Establish the type offset that can be used to lookup the type.
|
||||||
For DWO files, we don't know it until now. */
|
For DWO files, we don't know it until now. */
|
||||||
|
@ -4093,8 +4097,7 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
|
||||||
dwo_abbrev_section,
|
dwo_abbrev_section,
|
||||||
info_ptr, 0);
|
info_ptr, 0);
|
||||||
gdb_assert (dwo_unit->offset.sect_off == cu->header.offset.sect_off);
|
gdb_assert (dwo_unit->offset.sect_off == cu->header.offset.sect_off);
|
||||||
gdb_assert (dwo_unit->length
|
gdb_assert (dwo_unit->length == get_cu_length (&cu->header));
|
||||||
== cu->header.length + cu->header.initial_length_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Discard the original CU's abbrev table, and read the DWO's. */
|
/* Discard the original CU's abbrev table, and read the DWO's. */
|
||||||
|
@ -4205,7 +4208,7 @@ init_cutu_and_read_dies_no_follow (struct dwarf2_per_cu_data *this_cu,
|
||||||
abbrev_section, info_ptr,
|
abbrev_section, info_ptr,
|
||||||
this_cu->is_debug_types);
|
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. */
|
/* Skip dummy compilation units. */
|
||||||
if (info_ptr >= begin_info_ptr + this_cu->length
|
if (info_ptr >= begin_info_ptr + this_cu->length
|
||||||
|
|
Loading…
Reference in New Issue