* dwarf2.c (find_line): Don't trust debug information after an

unparseable compilation unit.
This commit is contained in:
Nathan Sidwell 2008-02-16 10:51:38 +00:00
parent 819da74e19
commit d74e4b29eb
2 changed files with 40 additions and 34 deletions

View file

@ -1,3 +1,8 @@
2008-02-16 Nathan Sidwell <nathan@codesourcery.com>
* dwarf2.c (find_line): Don't trust debug information after an
unparseable compilation unit.
2008-02-15 Alan Modra <amodra@bigpond.net.au> 2008-02-15 Alan Modra <amodra@bigpond.net.au>
PR 5765 PR 5765

View file

@ -3068,6 +3068,10 @@ find_line (bfd *abfd,
{ {
each = parse_comp_unit (stash, length, info_ptr_unit, each = parse_comp_unit (stash, length, info_ptr_unit,
offset_size); offset_size);
if (!each)
/* The dwarf information is damaged, don't trust it any
more. */
break;
stash->info_ptr += length; stash->info_ptr += length;
if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr) if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr)
@ -3077,40 +3081,37 @@ find_line (bfd *abfd,
stash->sec_info_ptr = stash->info_ptr; stash->sec_info_ptr = stash->info_ptr;
} }
if (each) if (stash->all_comp_units)
{ stash->all_comp_units->prev_unit = each;
if (stash->all_comp_units) else
stash->all_comp_units->prev_unit = each; stash->last_comp_unit = each;
else
stash->last_comp_unit = each; each->next_unit = stash->all_comp_units;
stash->all_comp_units = each;
each->next_unit = stash->all_comp_units;
stash->all_comp_units = each; /* DW_AT_low_pc and DW_AT_high_pc are optional for
compilation units. If we don't have them (i.e.,
/* DW_AT_low_pc and DW_AT_high_pc are optional for unit->high == 0), we need to consult the line info table
compilation units. If we don't have them (i.e., to see if a compilation unit contains the given
unit->high == 0), we need to consult the line info address. */
table to see if a compilation unit contains the given if (do_line)
address. */ found = (((symbol->flags & BSF_FUNCTION) == 0
if (do_line) || each->arange.high == 0
found = (((symbol->flags & BSF_FUNCTION) == 0 || comp_unit_contains_address (each, addr))
|| each->arange.high == 0 && comp_unit_find_line (each, symbol, addr,
|| comp_unit_contains_address (each, addr)) filename_ptr,
&& comp_unit_find_line (each, symbol, addr, linenumber_ptr,
filename_ptr, stash));
linenumber_ptr, else
stash)); found = ((each->arange.high == 0
else || comp_unit_contains_address (each, addr))
found = ((each->arange.high == 0 && comp_unit_find_nearest_line (each, addr,
|| comp_unit_contains_address (each, addr)) filename_ptr,
&& comp_unit_find_nearest_line (each, addr, functionname_ptr,
filename_ptr, linenumber_ptr,
functionname_ptr, stash));
linenumber_ptr, if (found)
stash)); goto done;
if (found)
goto done;
}
} }
} }