Improves the detection of partial .debug_line sections.

* dwarf.c (read_debug_line_header): Use reloc_at to detect
	incomplete .debug_line headers
This commit is contained in:
Nick Clifton
2015-06-05 16:58:35 +01:00
parent e00a2fbc24
commit 8fcc61b42b
2 changed files with 15 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2015-06-05 Nick Clifton <nickc@redhat.com>
* dwarf.c (read_debug_line_header): Use reloc_at to detect
incomplete .debug_line headers
2015-05-29 Roland McGrath <mcgrathr@google.com> 2015-05-29 Roland McGrath <mcgrathr@google.com>
* readelf.c (print_gnu_note: NT_GNU_ABI_TAG): Recognize * readelf.c (print_gnu_note: NT_GNU_ABI_TAG): Recognize

View File

@ -2761,18 +2761,20 @@ read_debug_line_header (struct dwarf_section * section,
if (linfo->li_length + initial_length_size > section->size) if (linfo->li_length + initial_length_size > section->size)
{ {
/* If the length is just a bias against the initial_length_size then /* If the length field has a relocation against it, then we should
this means that the field has a relocation against it which has not not complain if it is inaccurate (and probably negative). This
been applied. (Ie we are dealing with an object file, not a linked happens in object files when the .debug_line section is actually
binary). Do not complain but instead assume that the rest of the comprised of several different .debug_line.* sections, (some of
section applies to this particular header. */ which may be removed by linker garbage collection), and a relocation
if (linfo->li_length == - initial_length_size) is used to compute the correct length once that is done. */
if (reloc_at (section, (hdrptr - section->start) - offset_size))
{ {
linfo->li_length = section->size - initial_length_size; linfo->li_length = (end - data) - initial_length_size;
} }
else else
{ {
warn (_("The line info appears to be corrupt - the section is too small\n")); warn (_("The length field (0x%lx) in the debug_line header is wrong - the section is too small\n"),
(long) linfo->li_length);
return NULL; return NULL;
} }
} }