PROVIDE in linker script broken for expressions with more than two references

Alan Modra amodra@bigpond.net.au
Thu Sep 25 02:34:00 GMT 2008


On Thu, Sep 25, 2008 at 12:34:59AM +0930, Alan Modra wrote:
> The problem is that fold_binary doesn't evaluate rhs if the lhs is
> invalid.  I have a patch I'll commit in the morning after some
> testing.

Like so.  Note -w diff.  The actual patch committed reformats the
function properly.

	* ldexp.c (fold_binary): Evaluate rhs when lhs not valid.

Index: ld/ldexp.c
===================================================================
RCS file: /cvs/src/src/ld/ldexp.c,v
retrieving revision 1.75
diff -u -p -u -w -r1.75 ldexp.c
--- ld/ldexp.c	21 Aug 2008 13:10:54 -0000	1.75
+++ ld/ldexp.c	25 Sep 2008 02:17:58 -0000
@@ -282,6 +282,7 @@ fold_unary (etree_type *tree)
 static void
 fold_binary (etree_type *tree)
 {
+  etree_value_type lhs;
   exp_fold_tree_1 (tree->binary.lhs);
 
   /* The SEGMENT_START operator is special because its first
@@ -304,12 +305,13 @@ fold_binary (etree_type *tree)
 	    expld.result.section = expld.section;
 	    break;
 	  }
+      return;
     }
-  else if (expld.result.valid_p)
-    {
-      etree_value_type lhs = expld.result;
 
+  lhs = expld.result;
       exp_fold_tree_1 (tree->binary.rhs);
+  expld.result.valid_p &= lhs.valid_p;
+
       if (expld.result.valid_p)
 	{
 	  /* If the values are from different sections, or this is an
@@ -465,9 +467,6 @@ fold_binary (etree_type *tree)
 	      FAIL ();
 	    }
 	}
-      else
-	expld.result.valid_p = FALSE;
-    }
 }
 
 static void

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list