This is the mail archive of the 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]

[RFC] handling of forward references in expressions

I ran into a problem with code that I was able to simplify to


	.long T0 + (D2 - D1)
	.long X0 + (D2 - D1)
	.long T0 + (D2 - D1)

Here, the first of the three expressions triggers "operation combines
symbols in different segments", but the second and third don't. This
clearly is wrong - either all or none of them should work. The problem
is that expr() treats the result of (D2 - D1), when D2 isn't defined
yet, as living in the section of D1 rather than in expr_section (and
similarly for operations other than subtraction). I was about to submit
the following patch, when I found that a few targets can't deal with
expressions in expr_section. My question hence is - can someone see
another solution to the original problem, or do I need to go through all
affected targets and find where they make those incorrect assumptions?

Thanks, Jan

--- 2006-07-31/gas/expr.c	2006-07-31 15:54:13.000000000 +0200
+++ 2006-07-31/gas/expr.c	2006-07-31 16:17:55.000000000 +0200
@@ -1839,7 +1839,11 @@ expr (int rankarg,		/* Larger # is
 		  retval = absolute_section;
 		  rightseg = absolute_section;
+	      else
+		retval = expr_section;
+	  else
+	    retval = expr_section;
@@ -1849,13 +1853,16 @@ expr (int rankarg,		/* Larger # is
 	  resultP->X_op = op_left;
 	  resultP->X_add_number = 0;
 	  resultP->X_unsigned = 1;
+	  retval = expr_section;
       if (retval != rightseg)
 	  if (! SEG_NORMAL (retval))
-	      if (retval != undefined_section || SEG_NORMAL (rightseg))
+	      if (retval == expr_section)
+		;
+	      else if (retval != undefined_section || SEG_NORMAL
 		retval = rightseg;
 	  else if (SEG_NORMAL (rightseg)

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