This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
fix gas abort on lone .loc_mark_labels
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Date: Tue, 8 Apr 2008 09:26:41 +0930
- Subject: fix gas abort on lone .loc_mark_labels
Two bug fixes and some tidying, prompted by
http://sourceware.org/ml/gdb-patches/2008-04/msg00130.html
* dwarf2dbg.c (dwarf2_emit_insn): Simplify test before dwarf2_where
call. Delete out of date comment.
No functional change here.
(dwarf2_consume_line_info): Always clear dwarf2_loc_directive_seen.
All uses of this flag are with a test of debug_type, so keeping the flag
when DEBUG_DWARF2 is unnecessary.
(dwarf2_emit_label): Don't emit unless there has been a previous
.file or we are outputting assembler generated debug.
This fixes a later abort in out_debug_info.
dwarf2_consume_line_info after emitting line info, not before.
Fixes loss of basic block flag.
(out_debug_info): Simplify files_in_use test.
Index: gas/dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.95
diff -u -p -r1.95 dwarf2dbg.c
--- gas/dwarf2dbg.c 9 Jan 2008 17:30:58 -0000 1.95
+++ gas/dwarf2dbg.c 7 Apr 2008 23:30:11 -0000
@@ -365,19 +365,10 @@ dwarf2_emit_insn (int size)
{
struct dwarf2_line_info loc;
- if (dwarf2_loc_directive_seen)
- {
- /* Use the last location established by a .loc directive, not
- the value returned by dwarf2_where(). That calls as_where()
- which will return either the logical input file name (foo.c)
- or the physical input file name (foo.s) and not the file name
- specified in the most recent .loc directive (eg foo.h). */
- loc = current;
- }
- else if (debug_type != DEBUG_DWARF2)
+ if (!dwarf2_loc_directive_seen && debug_type != DEBUG_DWARF2)
return;
- else
- dwarf2_where (&loc);
+
+ dwarf2_where (&loc);
dwarf2_gen_line_info (frag_now_fix () - size, &loc);
dwarf2_consume_line_info ();
@@ -393,8 +384,7 @@ dwarf2_consume_line_info (void)
{
/* Unless we generate DWARF2 debugging information for each
assembler line, we only emit one line symbol for one LOC. */
- if (debug_type != DEBUG_DWARF2)
- dwarf2_loc_directive_seen = FALSE;
+ dwarf2_loc_directive_seen = FALSE;
current.flags &= ~(DWARF2_FLAG_BASIC_BLOCK
| DWARF2_FLAG_PROLOGUE_END
@@ -415,16 +405,15 @@ dwarf2_emit_label (symbolS *label)
return;
if (!(bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE))
return;
-
- if (debug_type == DEBUG_DWARF2)
- dwarf2_where (&loc);
- else
- loc = current;
+ if (files_in_use == 0 && debug_type != DEBUG_DWARF2)
+ return;
+
+ dwarf2_where (&loc);
loc.flags |= DWARF2_FLAG_BASIC_BLOCK;
- dwarf2_consume_line_info ();
dwarf2_gen_line_info_1 (label, &loc);
+ dwarf2_consume_line_info ();
}
/* Get a .debug_line file number for FILENAME. If NUM is nonzero,
@@ -1671,7 +1660,7 @@ out_debug_info (segT info_seg, segT abbr
on the command line, so assume files[1] is the main input file.
We're not supposed to get called unless at least one line number
entry was emitted, so this should always be defined. */
- if (!files || files_in_use < 1)
+ if (files_in_use == 0)
abort ();
if (files[1].dir)
{
--
Alan Modra
Australia Development Lab, IBM