This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[GAS] fix crash on erroneous directive
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: binutils <binutils at sourceware dot org>
- Date: Wed, 27 Jul 2011 12:42:06 +0100
- Subject: [GAS] fix crash on erroneous directive
If one uses --gdwarf2 to emit line number directives, and write code to the
*ABS* section, dwarf2bdg crashes with:
/home/nathan/binutils/src/gas/testsuite/gas/all//warn-2.s: Assembler messages:
/home/nathan/binutils/src/gas/testsuite/gas/all//warn-2.s: Internal error!
Assertion failure in emit_inc_line_addr at ../../src/gas/dwarf2dbg.c line 926.
Please report this bug.
Why would someone write code to *ABS*? well, the undocumented .offset directive
switches to that section, and furthermore, some other assemblers use .offset to
do what gas uses .org to do, which is unfortunate.
This patch (a) documents the .offset directive, pointing out not to confuse it
with .org, and (b) stops dwarf2dbg from crashing, instead emitting a warning.
tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell
2011-07-27 Nathan Sidwell <nathan@codesourcery.com>
* dwarf2dbg.c (out_debug_line): Ignore non-normal segments, with a
warning.
* doc/as.texinfo (Offset): Document .offset directive.
* gas/all/warn-2.s: New.
Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.111
diff -c -3 -p -r1.111 dwarf2dbg.c
*** dwarf2dbg.c 31 Mar 2011 08:02:41 -0000 1.111
--- dwarf2dbg.c 27 Jul 2011 11:40:28 -0000
*************** out_debug_line (segT line_seg)
*** 1459,1465 ****
/* For each section, emit a statement program. */
for (s = all_segs; s; s = s->next)
! process_entries (s->seg, s->head->head);
symbol_set_value_now (line_end);
}
--- 1459,1469 ----
/* For each section, emit a statement program. */
for (s = all_segs; s; s = s->next)
! if (SEG_NORMAL (s->seg))
! process_entries (s->seg, s->head->head);
! else
! as_warn ("dwarf line number information for %s ignored",
! segment_name (s->seg));
symbol_set_value_now (line_end);
}
Index: doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.238
diff -c -3 -p -r1.238 as.texinfo
*** doc/as.texinfo 24 Jul 2011 14:20:09 -0000 1.238
--- doc/as.texinfo 27 Jul 2011 11:40:31 -0000
*************** Some machine configurations provide addi
*** 4017,4022 ****
--- 4017,4023 ----
* Noaltmacro:: @code{.noaltmacro}
* Nolist:: @code{.nolist}
* Octa:: @code{.octa @var{bignums}}
+ * Offset:: @code{.offset @var{loc}}
* Org:: @code{.org @var{new-lc}, @var{fill}}
* P2align:: @code{.p2align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
@ifset ELF
*************** bignum, it emits a 16-byte integer.
*** 5480,5485 ****
--- 5481,5495 ----
The term ``octa'' comes from contexts in which a ``word'' is two bytes;
hence @emph{octa}-word for 16 bytes.
+ @node Offset
+ @section @code{.offset @var{loc}}
+
+ @cindex @code{offset} directive
+ Set the location counter to @var{loc} in the absolute section. @var{loc} must
+ be an absolute expression. This directive may be useful for defining
+ symbols with absolute values. Do not confuse it with the @code{.org}
+ directive.
+
@node Org
@section @code{.org @var{new-lc} , @var{fill}}
Index: testsuite/gas/all/warn-2.s
===================================================================
RCS file: testsuite/gas/all/warn-2.s
diff -N testsuite/gas/all/warn-2.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gas/all/warn-2.s 27 Jul 2011 11:40:32 -0000
***************
*** 0 ****
--- 1,5 ----
+ ;# { dg-do assemble }
+ ;# { dg-options "--gdwarf2" }
+ .offset 40
+ nop
+ ;# { dg-warning "Warning: dwarf line number information for .* ignored" "" { target *-*-* } 0 }