aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-07-17 12:46:35 +0000
committerDaniel Jacobowitz <drow@false.org>2007-07-17 12:46:35 +0000
commita8c50c1f557c99062f17be4a7b9d1c596771e4c1 (patch)
treeb3ab974a9eeaa6a2eb8be130bbd55ccd6975682b /gdb/dwarf2read.c
parentbd4dd364df08e9dffec83ec7758a0438058714cc (diff)
downloadgdb-a8c50c1f557c99062f17be4a7b9d1c596771e4c1.zip
gdb-a8c50c1f557c99062f17be4a7b9d1c596771e4c1.tar.gz
gdb-a8c50c1f557c99062f17be4a7b9d1c596771e4c1.tar.bz2
* dwarf2read.c (dwarf_decode_lines): Detect address size mismatches.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 32d6f15..c12e3da 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6668,9 +6668,9 @@ static void
dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
struct dwarf2_cu *cu, struct partial_symtab *pst)
{
- gdb_byte *line_ptr;
+ gdb_byte *line_ptr, *extended_end;
gdb_byte *line_end;
- unsigned int bytes_read;
+ unsigned int bytes_read, extended_len;
unsigned char op_code, extended_op, adj_opcode;
CORE_ADDR baseaddr;
struct objfile *objfile = cu->objfile;
@@ -6745,8 +6745,9 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
else switch (op_code)
{
case DW_LNS_extended_op:
- read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ extended_len = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
+ extended_end = line_ptr + extended_len;
extended_op = read_1_byte (abfd, line_ptr);
line_ptr += 1;
switch (extended_op)
@@ -6792,6 +6793,15 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
_("mangled .debug_line section"));
return;
}
+ /* Make sure that we parsed the extended op correctly. If e.g.
+ we expected a different address size than the producer used,
+ we may have read the wrong number of bytes. */
+ if (line_ptr != extended_end)
+ {
+ complaint (&symfile_complaints,
+ _("mangled .debug_line section"));
+ return;
+ }
break;
case DW_LNS_copy:
if (lh->num_file_names < file)