This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] internal error for backwards .org


The assembler fails to catch some cases where .org directives attempt to move backwards in the output. If you are generating DWARF2 line info, this leads to an internal error. Here is an example:

Contents of test "bkwd.s":
        .org 0x20
        nop
        .org 0x10
        nop

% as -gdwarf2 bkwd.s
bkwd.s: Assembler messages:
bkwd.s:3: Error: attempt to .org/.space backwards? (-17)
bkwd.s:5: Internal error!
Assertion failure in emit_inc_line_addr at ../../gas/dwarf2dbg.c line 894.
Please report this bug.

The following patch fixes the problem, so that the assembler properly reports the backward .org error without the internal error:

% as -gdwarf2 bkwd.s
bkwd.s: Assembler messages:
bkwd.s:3: Error: attempt to move .org backwards

I've tested this by running the binutils testsuites for both a native i686-linux build and a cross xtensa-elf build.

Is this OK?

2008-06-23  Bob Wilson  <bob.wilson@acm.org>
	
	* write.c (relax_segment): Move check for backwards .org after
	subtracting the current stretch value from the growth.
Index: write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.115
diff -u -p -r1.115 write.c
--- write.c	3 Mar 2008 15:28:58 -0000	1.115
+++ write.c	23 Jun 2008 20:34:22 -0000
@@ -2307,6 +2307,10 @@ relax_segment (struct frag *segment_frag
 		  know (fragP->fr_next);
 		  after = fragP->fr_next->fr_address;
 		  growth = target - after;
+
+		  /* This is an absolute growth factor.  */
+		  growth -= stretch;
+
 		  if (growth < 0)
 		    {
 		      growth = 0;
@@ -2343,9 +2347,6 @@ relax_segment (struct frag *segment_frag
 		      fragP->fr_fix = after - was_address;
 		      break;
 		    }
-
-		  /* This is an absolute growth factor  */
-		  growth -= stretch;
 		  break;
 		}
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]