public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [RFC] handling of forward references in expressions
@ 2006-08-01  9:11 Jan Beulich
  2006-08-02  3:26 ` Erik Christiansen
  2006-08-07  9:41 ` Nick Clifton
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Beulich @ 2006-08-01  9:11 UTC (permalink / raw)
  To: binutils

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

	.text
T0:

	.data
D1:
	.long T0 + (D2 - D1)
	.long X0 + (D2 - D1)
D2:
	.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
highe
 		  retval = absolute_section;
 		  rightseg = absolute_section;
 		}
+	      else
+		retval = expr_section;
 	    }
+	  else
+	    retval = expr_section;
 	}
       else
 	{
@@ -1849,13 +1853,16 @@ expr (int rankarg,		/* Larger # is
highe
 	  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
(rightseg))
 		retval = rightseg;
 	    }
 	  else if (SEG_NORMAL (rightseg)

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

end of thread, other threads:[~2006-08-07 14:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-01  9:11 [RFC] handling of forward references in expressions Jan Beulich
2006-08-02  3:26 ` Erik Christiansen
2006-08-07  9:41 ` Nick Clifton
2006-08-07 12:37   ` Jan Beulich
2006-08-07 14:11     ` Nick Clifton
2006-08-07 14:55       ` Jan Beulich

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