This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Improves the detection of partial .debug_line sections.
- From: Nick Clifton <nickc at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 5 Jun 2015 15:59:05 -0000
- Subject: [binutils-gdb] Improves the detection of partial .debug_line sections.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8fcc61b42be7703460dcacf24d97b290f502c23e
commit 8fcc61b42be7703460dcacf24d97b290f502c23e
Author: Nick Clifton <nickc@redhat.com>
Date: Fri Jun 5 16:58:35 2015 +0100
Improves the detection of partial .debug_line sections.
* dwarf.c (read_debug_line_header): Use reloc_at to detect
incomplete .debug_line headers
Diff:
---
binutils/ChangeLog | 5 +++++
binutils/dwarf.c | 18 ++++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 03eb240..63fefc8 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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>
* readelf.c (print_gnu_note: NT_GNU_ABI_TAG): Recognize
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 71b0e97..c3dc814 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -2761,18 +2761,20 @@ read_debug_line_header (struct dwarf_section * section,
if (linfo->li_length + initial_length_size > section->size)
{
- /* If the length is just a bias against the initial_length_size then
- this means that the field has a relocation against it which has not
- been applied. (Ie we are dealing with an object file, not a linked
- binary). Do not complain but instead assume that the rest of the
- section applies to this particular header. */
- if (linfo->li_length == - initial_length_size)
+ /* If the length field has a relocation against it, then we should
+ not complain if it is inaccurate (and probably negative). This
+ happens in object files when the .debug_line section is actually
+ comprised of several different .debug_line.* sections, (some of
+ which may be removed by linker garbage collection), and a relocation
+ 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
{
- 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;
}
}