This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH]: Fix a seg fault in readelf
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Thu, 12 May 2005 10:05:09 +0100
- Subject: Re: [PATCH]: Fix a seg fault in readelf
Hi Guys,
Ooops, I forogot to attach the patch - here it is.
Cheers
Nick
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.289
diff -c -3 -p -r1.289 readelf.c
*** binutils/readelf.c 11 May 2005 14:10:59 -0000 1.289
--- binutils/readelf.c 12 May 2005 08:56:53 -0000
*************** reset_state_machine (int is_stmt)
*** 7166,7173 ****
state_machine_regs.last_file_entry = 0;
}
! /* Handled an extend line op. Returns true if this is the end
! of sequence. */
static int
process_extended_line_op (unsigned char *data, int is_stmt, int pointer_size)
--- 7166,7173 ----
state_machine_regs.last_file_entry = 0;
}
! /* Handled an extend line op.
! Returns the number of bytes read. */
static int
process_extended_line_op (unsigned char *data, int is_stmt, int pointer_size)
*************** display_debug_lines (Elf_Internal_Shdr *
*** 9097,9103 ****
printf (_(" Line Base: %d\n"), info.li_line_base);
printf (_(" Line Range: %d\n"), info.li_line_range);
printf (_(" Opcode Base: %d\n"), info.li_opcode_base);
! printf (_(" (Pointer size: %u)\n"), pointer_size);
end_of_sequence = data + info.li_length + initial_length_size;
--- 9097,9105 ----
printf (_(" Line Base: %d\n"), info.li_line_base);
printf (_(" Line Range: %d\n"), info.li_line_range);
printf (_(" Opcode Base: %d\n"), info.li_opcode_base);
! printf (_(" (Pointer size: %u)%s\n"),
! pointer_size,
! warned_about_missing_comp_units ? " [assumed]" : "" );
end_of_sequence = data + info.li_length + initial_length_size;
*************** display_debug_lines (Elf_Internal_Shdr *
*** 9188,9195 ****
else switch (op_code)
{
case DW_LNS_extended_op:
data += process_extended_line_op (data, info.li_default_is_stmt,
! pointer_size);
break;
case DW_LNS_copy:
--- 9190,9203 ----
else switch (op_code)
{
case DW_LNS_extended_op:
+ if (pointer_size == 0)
+ {
+ warn (_("Extend line ops need a valid pointer size, guessing at 4"));
+ pointer_size = 4;
+ }
+
data += process_extended_line_op (data, info.li_default_is_stmt,
! pointer_size);
break;
case DW_LNS_copy: