public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [GAS] fix crash on erroneous directive
@ 2011-07-27 12:33 Nathan Sidwell
  2011-07-27 13:20 ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Nathan Sidwell @ 2011-07-27 12:33 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 811 bytes --]

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


[-- Attachment #2: dwarf.patch --]
[-- Type: text/x-patch, Size: 2958 bytes --]

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 }

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-07-29 11:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-27 12:33 [GAS] fix crash on erroneous directive Nathan Sidwell
2011-07-27 13:20 ` Andreas Schwab
2011-07-27 14:05   ` Nathan Sidwell
2011-07-27 16:26     ` Andreas Schwab
2011-07-28 14:03       ` Nathan Sidwell
2011-07-28 16:42         ` Nick Clifton
2011-07-28 16:58           ` Nathan Sidwell
2011-07-29  3:11           ` New gas testsuite errors (was Re: [GAS] fix crash on erroneous directive) Hans-Peter Nilsson
2011-07-29 12:10             ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).