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]

pr13839 fix


This fixes the PR by silencing an error when in mark phase.  It also
fixes a couple of other problems I noticed when looking at this code.

	PR ld/13839
	* ldexp.c (fold_name): Ignore undefined symbols when assigning to
	dot in mark phase.
	(exp_fold_tree_1): Evaluate assignment to dot expressions even when
	discarding result, for side effects.  Fix typo in error message.

Index: ld/ldexp.c
===================================================================
RCS file: /cvs/src/src/ld/ldexp.c,v
retrieving revision 1.98
diff -u -p -r1.98 ldexp.c
--- ld/ldexp.c	8 Mar 2012 13:53:03 -0000	1.98
+++ ld/ldexp.c	14 Mar 2012 03:59:32 -0000
@@ -606,7 +606,8 @@ fold_name (etree_type *tree)
 			 output_section);
 	    }
 	  else if (expld.phase == lang_final_phase_enum
-		   || expld.assigning_to_dot)
+		   || (expld.phase != lang_mark_phase_enum
+		       && expld.assigning_to_dot))
 	    einfo (_("%F%S: undefined symbol `%s'"
 		     " referenced in expression\n"),
 		   tree, tree->name.name);
@@ -797,14 +798,7 @@ exp_fold_tree_1 (etree_type *tree)
 	  if (tree->type.node_class != etree_assign)
 	    einfo (_("%F%S can not PROVIDE assignment to"
 		     " location counter\n"), tree);
-	  /* After allocation, assignment to dot should not be done inside
-	     an output section since allocation adds a padding statement
-	     that effectively duplicates the assignment.  */
-	  if (expld.phase == lang_mark_phase_enum
-	      || expld.phase == lang_allocating_phase_enum
-	      || ((expld.phase == lang_assigning_phase_enum
-		   || expld.phase == lang_final_phase_enum)
-		  && expld.section == bfd_abs_section_ptr))
+	  if (expld.phase != lang_first_phase_enum)
 	    {
 	      /* Notify the folder that this is an assignment to dot.  */
 	      expld.assigning_to_dot = TRUE;
@@ -819,8 +813,13 @@ exp_fold_tree_1 (etree_type *tree)
 		}
 	      else if (expld.dotp == NULL)
 		einfo (_("%F%S assignment to location counter"
-			 " invalid outside of SECTION\n"), tree);
-	      else
+			 " invalid outside of SECTIONS\n"), tree);
+	      /* After allocation, assignment to dot should not be
+		 done inside an output section since allocation adds a
+		 padding statement that effectively duplicates the
+		 assignment.  */
+	      else if (expld.phase <= lang_allocating_phase_enum
+		       || expld.section == bfd_abs_section_ptr)
 		{
 		  bfd_vma nextdot;
 

-- 
Alan Modra
Australia Development Lab, IBM


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