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

* Re: [GAS] fix crash on erroneous directive
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2011-07-27 13:20 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: binutils

Nathan Sidwell <nathan@codesourcery.com> writes:

> 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

In the ia64 assembler nop requires an argument, so this will fail to
assemble.

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

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

* Re: [GAS] fix crash on erroneous directive
  2011-07-27 13:20 ` Andreas Schwab
@ 2011-07-27 14:05   ` Nathan Sidwell
  2011-07-27 16:26     ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Nathan Sidwell @ 2011-07-27 14:05 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: binutils

On 07/27/11 13:30, Andreas Schwab wrote:
> Nathan Sidwell<nathan@codesourcery.com>  writes:

>> + 	.offset 40
>> + 	nop
>
> In the ia64 assembler nop requires an argument, so this will fail to
> assemble.

that's unfortunate, i'd guessed every assembler has a plain nop. What do you 
suggest -- skipping for ia64?

nathan

-- 
Nathan Sidwell

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

* Re: [GAS] fix crash on erroneous directive
  2011-07-27 14:05   ` Nathan Sidwell
@ 2011-07-27 16:26     ` Andreas Schwab
  2011-07-28 14:03       ` Nathan Sidwell
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2011-07-27 16:26 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: binutils

Nathan Sidwell <nathan@codesourcery.com> writes:

> On 07/27/11 13:30, Andreas Schwab wrote:
>> Nathan Sidwell<nathan@codesourcery.com>  writes:
>
>>> + 	.offset 40
>>> + 	nop
>>
>> In the ia64 assembler nop requires an argument, so this will fail to
>> assemble.
>
> that's unfortunate, i'd guessed every assembler has a plain nop. What
> do you suggest -- skipping for ia64?

You could define a symbol and then use to the right nop depending on the
symbol's value.

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

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

* Re: [GAS] fix crash on erroneous directive
  2011-07-27 16:26     ` Andreas Schwab
@ 2011-07-28 14:03       ` Nathan Sidwell
  2011-07-28 16:42         ` Nick Clifton
  0 siblings, 1 reply; 9+ messages in thread
From: Nathan Sidwell @ 2011-07-28 14:03 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: binutils

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

On 07/27/11 15:04, Andreas Schwab wrote:

> You could define a symbol and then use to the right nop depending on the
> symbol's value.

like this?

-- 
Nathan Sidwell


[-- Attachment #2: dwarf.patch --]
[-- Type: text/x-patch, Size: 3098 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.

	testsuite/
	* 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	28 Jul 2011 09:14:37 -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	28 Jul 2011 09:14:40 -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	28 Jul 2011 09:14:40 -0000
***************
*** 0 ****
--- 1,10 ----
+ ;# { dg-do assemble }
+ ;# { dg-options "--gdwarf2 --defsym ia64=0" }
+ ;# { dg-options "--gdwarf2 --defsym ia64=1" { target ia64-*-* } }
+ 	.offset 40
+ .ifeq ia64 - 1
+ 	nop 0
+ .else
+ 	nop
+ .endif
+ ;# { dg-warning "Warning: dwarf line number information for .* ignored" "" { target *-*-* } 0 }

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

* Re: [GAS] fix crash on erroneous directive
  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
  0 siblings, 2 replies; 9+ messages in thread
From: Nick Clifton @ 2011-07-28 16:42 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: Andreas Schwab, binutils

Hi Nathan,

>> You could define a symbol and then use to the right nop depending on the
>> symbol's value.
>
> like this?

Yes - although it turns out that there are other targets that have nops 
that take arguments, do not have a nop instruction at all, or do not 
generate dwarf2 debug information, so the test as you had it needed a 
little more tweaking.  I have taken care of this however, and checked 
the result in.

Cheers
   Nick


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

* Re: [GAS] fix crash on erroneous directive
  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
  1 sibling, 0 replies; 9+ messages in thread
From: Nathan Sidwell @ 2011-07-28 16:58 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Andreas Schwab, binutils

On 07/28/11 17:40, Nick Clifton wrote:

> Yes - although it turns out that there are other targets that have nops that
> take arguments, do not have a nop instruction at all, or do not generate dwarf2
> debug information, so the test as you had it needed a little more tweaking. I
> have taken care of this however, and checked the result in.

thanks!

nathan

-- 
Nathan Sidwell

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

* New gas testsuite errors (was Re: [GAS] fix crash on erroneous directive)
  2011-07-28 16:42         ` Nick Clifton
  2011-07-28 16:58           ` Nathan Sidwell
@ 2011-07-29  3:11           ` Hans-Peter Nilsson
  2011-07-29 12:10             ` Nick Clifton
  1 sibling, 1 reply; 9+ messages in thread
From: Hans-Peter Nilsson @ 2011-07-29  3:11 UTC (permalink / raw)
  To: nickc; +Cc: binutils

> Date: Thu, 28 Jul 2011 17:40:01 +0100
> From: Nick Clifton <nickc@redhat.com>

> >> You could define a symbol and then use to the right nop depending on the
> >> symbol's value.
> >
> > like this?
> 
> Yes - although it turns out that there are other targets that have nops 
> that take arguments, do not have a nop instruction at all, or do not 
> generate dwarf2 debug information, so the test as you had it needed a 
> little more tweaking.  I have taken care of this however, and checked 
> the result in.

Not sure why you didn't see this when you tested your changes
(for cris-elf but the target seems unimportant):

Running /tmp/hpautotest-binutils/bsrc/src/gas/testsuite/gas/elf/elf.exp ...
ERROR: gas/elf/warn-2.s: unknown dg option: dg-skip-if 2 {DWARF2 output not supported} { mcore-*-* mn10*-*-* moxie-*-* v850-*-* } for " dg-skip-if 2 "DWARF2 output not supported" { mcore-*-* mn10*-*-* moxie-*-* v850-*-* } "

There's no dg-skip-if in binutils (and none in dejagnu-1.4.4.),
that's just in the gcc testsuite...  No obvious patch,
unfortunately.

brgds, H-P

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

* Re: New gas testsuite errors (was Re: [GAS] fix crash on erroneous directive)
  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
  0 siblings, 0 replies; 9+ messages in thread
From: Nick Clifton @ 2011-07-29 12:10 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

Hi Hans-Peter,

> Not sure why you didn't see this when you tested your changes
>
> Running /tmp/hpautotest-binutils/bsrc/src/gas/testsuite/gas/elf/elf.exp ...
> ERROR: gas/elf/warn-2.s: unknown dg option: dg-skip-if 2 {DWARF2 output not supported} { mcore-*-* mn10*-*-* moxie-*-* v850-*-* } for " dg-skip-if 2 "DWARF2 output not supported" { mcore-*-* mn10*-*-* moxie-*-* v850-*-* } "

Snafu - I use a script to parse for testsuite regressions.  It was 
looking for new FAIL messages, but it omitted to check for new ERROR 
messages.  I have fixed this now.

> There's no dg-skip-if in binutils (and none in dejagnu-1.4.4.),
> that's just in the gcc testsuite...  No obvious patch,
> unfortunately.

I have fixed warn-2.s so that the test for the warning message is 
xfailed on those targets that will not produce it, and the nop 
instruction for the OpenRisc targets is encoded as "l.no 0".  With these 
changes the test now works for all of the targets that I checked.

Cheers
   Nick


^ 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).