655e7e
diff -rup ../binutils-2.20.51.0.2.original/gas/ChangeLog gas/ChangeLog
655e7e
--- ../binutils-2.20.51.0.2.original/gas/ChangeLog	2009-12-09 11:46:00.000000000 +0000
655e7e
+++ gas/ChangeLog	2009-12-09 11:48:31.000000000 +0000
655e7e
@@ -1,3 +1,10 @@
655e7e
+2009-10-28  Alan Modra  <amodra@bigpond.net.au>
655e7e
+
655e7e
+	PR gas/10856
655e7e
+	* expr.c (resolve_expression): Only add "left" value to O_symbol
655e7e
+	expression when the symbol is undefined and different from the
655e7e
+	original symbol.  Simplify negative logic.
655e7e
+
655e7e
 2009-10-07  Nathan Sidwell  <nathan@codesourcery.com>
655e7e
 
655e7e
 	* config/tc-arm.c (mapping_state, mapping_state_2): Make dummy
655e7e
Only in ../binutils-2.20.51.0.2.original/gas: .#expr.c
655e7e
Only in ../binutils-2.20.51.0.2.original/gas: #expr.c#
655e7e
diff -rup ../binutils-2.20.51.0.2.original/gas/expr.c gas/expr.c
655e7e
--- ../binutils-2.20.51.0.2.original/gas/expr.c	2009-12-09 11:45:56.000000000 +0000
655e7e
+++ gas/expr.c	2009-12-09 11:48:10.000000000 +0000
655e7e
@@ -1997,6 +1997,7 @@ resolve_expression (expressionS *express
655e7e
   /* Help out with CSE.  */
655e7e
   valueT final_val = expressionP->X_add_number;
655e7e
   symbolS *add_symbol = expressionP->X_add_symbol;
655e7e
+  symbolS *orig_add_symbol = add_symbol;
655e7e
   symbolS *op_symbol = expressionP->X_op_symbol;
655e7e
   operatorT op = expressionP->X_op;
655e7e
   valueT left, right;
655e7e
@@ -2078,6 +2079,7 @@ resolve_expression (expressionS *express
655e7e
 	      left = right;
655e7e
 	      seg_left = seg_right;
655e7e
 	      add_symbol = op_symbol;
655e7e
+	      orig_add_symbol = expressionP->X_op_symbol;
655e7e
 	      op = O_symbol;
655e7e
 	      break;
655e7e
 	    }
655e7e
@@ -2122,18 +2124,19 @@ resolve_expression (expressionS *express
655e7e
 	    {
655e7e
 	      if (op == O_bit_exclusive_or || op == O_bit_inclusive_or)
655e7e
 		{
655e7e
-		  if (seg_right != absolute_section || right != 0)
655e7e
+		  if (!(seg_right == absolute_section && right == 0))
655e7e
 		    {
655e7e
 		      seg_left = seg_right;
655e7e
 		      left = right;
655e7e
 		      add_symbol = op_symbol;
655e7e
+		      orig_add_symbol = expressionP->X_op_symbol;
655e7e
 		    }
655e7e
 		  op = O_symbol;
655e7e
 		  break;
655e7e
 		}
655e7e
 	      else if (op == O_left_shift || op == O_right_shift)
655e7e
 		{
655e7e
-		  if (seg_left != absolute_section || left != 0)
655e7e
+		  if (!(seg_left == absolute_section && left == 0))
655e7e
 		    {
655e7e
 		      op = O_symbol;
655e7e
 		      break;
655e7e
@@ -2150,6 +2153,7 @@ resolve_expression (expressionS *express
655e7e
 	      left = right;
655e7e
 	      add_symbol = op_symbol;
655e7e
 	      op = O_symbol;
655e7e
+	      orig_add_symbol = expressionP->X_op_symbol;
655e7e
 	      break;
655e7e
 	    }
655e7e
 	  else if ((op == O_multiply || op == O_divide)
655e7e
@@ -2158,11 +2162,11 @@ resolve_expression (expressionS *express
655e7e
 	      op = O_symbol;
655e7e
 	      break;
655e7e
 	    }
655e7e
-	  else if (left != right
655e7e
-		   || ((seg_left != reg_section || seg_right != reg_section)
655e7e
-		       && (seg_left != undefined_section
655e7e
-			   || seg_right != undefined_section
655e7e
-			   || add_symbol != op_symbol)))
655e7e
+	  else if (!(left == right
655e7e
+		     && ((seg_left == reg_section && seg_right == reg_section)
655e7e
+			 || (seg_left == undefined_section
655e7e
+			     && seg_right == undefined_section
655e7e
+			     && add_symbol == op_symbol))))
655e7e
 	    return 0;
655e7e
 	  else if (op == O_bit_and || op == O_bit_inclusive_or)
655e7e
 	    {
655e7e
@@ -2233,7 +2237,8 @@ resolve_expression (expressionS *express
655e7e
 	op = O_constant;
655e7e
       else if (seg_left == reg_section && final_val == 0)
655e7e
 	op = O_register;
655e7e
-      else if (add_symbol != expressionP->X_add_symbol)
655e7e
+      else if (seg_left == undefined_section
655e7e
+	       && add_symbol != orig_add_symbol)
655e7e
 	final_val += left;
655e7e
       expressionP->X_add_symbol = add_symbol;
655e7e
     }
655e7e
diff -rup ../binutils-2.20.51.0.2.original/gas/testsuite/ChangeLog gas/testsuite/ChangeLog
655e7e
--- ../binutils-2.20.51.0.2.original/gas/testsuite/ChangeLog	2009-12-09 11:45:56.000000000 +0000
655e7e
+++ gas/testsuite/ChangeLog	2009-12-09 11:50:11.000000000 +0000
655e7e
@@ -1,3 +1,7 @@
655e7e
+2009-10-28  Alan Modra  <amodra@bigpond.net.au>
655e7e
+
655e7e
+	* gas/i386/intelpic.d: Correct.
655e7e
+
655e7e
 2009-10-08  H.J. Lu  <hongjiu.lu@intel.com>
655e7e
 
655e7e
 	PR gas/10704
655e7e
diff -rup ../binutils-2.20.51.0.2.original/gas/testsuite/gas/i386/intelpic.d gas/testsuite/gas/i386/intelpic.d
655e7e
--- ../binutils-2.20.51.0.2.original/gas/testsuite/gas/i386/intelpic.d	2009-12-09 11:45:59.000000000 +0000
655e7e
+++ gas/testsuite/gas/i386/intelpic.d	2009-12-09 11:49:17.000000000 +0000
655e7e
@@ -12,6 +12,6 @@ Disassembly of section .text:
655e7e
 0+1 <bar>:
655e7e
 [ 	]*[a-f0-9]+:	8d 83 14 00 00 00    	lea    0x14\(%ebx\),%eax
655e7e
 [ 	]*[a-f0-9]+:	8b 83 00 00 00 00    	mov    0x0\(%ebx\),%eax
655e7e
-[ 	]*[a-f0-9]+:	ff 24 85 1a 00 00 00 	jmp    \*0x1a\(,%eax,4\)
655e7e
+[ 	]*[a-f0-9]+:	ff 24 85 0d 00 00 00 	jmp    \*0xd\(,%eax,4\)
655e7e
 [ 	]*[a-f0-9]+:	8d 83 14 00 00 00    	lea    0x14\(%ebx\),%eax
655e7e
 #pass
655e7e