tstellar / rpms / binutils

Forked from rpms/binutils 2 years ago
Clone
f466cc5
diff -rup binutils-2.21.51.0.6/ld/ldexp.c binutils-2.21.51.0.6.new/ld/ldexp.c
f466cc5
--- binutils-2.21.51.0.6/ld/ldexp.c	2011-01-18 23:29:28.000000000 +0000
f466cc5
+++ binutils-2.21.51.0.6.new/ld/ldexp.c	2011-07-12 13:52:47.140984706 +0100
f466cc5
@@ -752,12 +752,15 @@ exp_fold_tree_1 (etree_type *tree)
f466cc5
     case etree_provided:
f466cc5
       if (tree->assign.dst[0] == '.' && tree->assign.dst[1] == 0)
f466cc5
 	{
f466cc5
-	  /* Assignment to dot can only be done during allocation.  */
f466cc5
 	  if (tree->type.node_class != etree_assign)
f466cc5
 	    einfo (_("%F%S can not PROVIDE assignment to location counter\n"));
f466cc5
+	  /* After allocation, assignment to dot should not be done inside
f466cc5
+	     an output section since allocation adds a padding statement
f466cc5
+	     that effectively duplicates the assignment.  */
f466cc5
 	  if (expld.phase == lang_mark_phase_enum
f466cc5
 	      || expld.phase == lang_allocating_phase_enum
f466cc5
-	      || (expld.phase == lang_final_phase_enum
f466cc5
+	      || ((expld.phase == lang_assigning_phase_enum
f466cc5
+		   || expld.phase == lang_final_phase_enum)
f466cc5
 		  && expld.section == bfd_abs_section_ptr))
f466cc5
 	    {
f466cc5
 	      /* Notify the folder that this is an assignment to dot.  */
f466cc5
diff -rup binutils-2.21.51.0.6/ld/ldexp.h binutils-2.21.51.0.6.new/ld/ldexp.h
f466cc5
--- binutils-2.21.51.0.6/ld/ldexp.h	2011-01-18 23:29:28.000000000 +0000
f466cc5
+++ binutils-2.21.51.0.6.new/ld/ldexp.h	2011-07-12 13:52:49.804972646 +0100
f466cc5
@@ -97,6 +97,7 @@ typedef enum {
f466cc5
   lang_first_phase_enum,
f466cc5
   lang_mark_phase_enum,
f466cc5
   lang_allocating_phase_enum,
f466cc5
+  lang_assigning_phase_enum,
f466cc5
   lang_final_phase_enum
f466cc5
 } lang_phase_type;
f466cc5
 
f466cc5
diff -rup binutils-2.21.51.0.6/ld/ldlang.c binutils-2.21.51.0.6.new/ld/ldlang.c
f466cc5
--- binutils-2.21.51.0.6/ld/ldlang.c	2011-01-18 23:30:00.000000000 +0000
f466cc5
+++ binutils-2.21.51.0.6.new/ld/ldlang.c	2011-07-12 13:52:53.893954137 +0100
f466cc5
@@ -5610,8 +5610,9 @@ lang_do_assignments_1 (lang_statement_un
f466cc5
 }
f466cc5
 
f466cc5
 void
f466cc5
-lang_do_assignments (void)
f466cc5
+lang_do_assignments (lang_phase_type phase)
f466cc5
 {
f466cc5
+  expld.phase = phase;
f466cc5
   lang_statement_iteration++;
f466cc5
   lang_do_assignments_1 (statement_list.head, abs_output_section, NULL, 0);
f466cc5
 }
f466cc5
@@ -6403,7 +6404,7 @@ lang_relax_sections (bfd_boolean need_la
f466cc5
 
f466cc5
 	      /* Do all the assignments with our current guesses as to
f466cc5
 		 section sizes.  */
f466cc5
-	      lang_do_assignments ();
f466cc5
+	      lang_do_assignments (lang_assigning_phase_enum);
f466cc5
 
f466cc5
 	      /* We must do this after lang_do_assignments, because it uses
f466cc5
 		 size.  */
f466cc5
@@ -6424,7 +6425,7 @@ lang_relax_sections (bfd_boolean need_la
f466cc5
   if (need_layout)
f466cc5
     {
f466cc5
       /* Final extra sizing to report errors.  */
f466cc5
-      lang_do_assignments ();
f466cc5
+      lang_do_assignments (lang_assigning_phase_enum);
f466cc5
       lang_reset_memory_regions ();
f466cc5
       lang_size_sections (NULL, TRUE);
f466cc5
     }
f466cc5
@@ -6652,8 +6653,7 @@ lang_process (void)
f466cc5
 
f466cc5
   /* Do all the assignments, now that we know the final resting places
f466cc5
      of all the symbols.  */
f466cc5
-  expld.phase = lang_final_phase_enum;
f466cc5
-  lang_do_assignments ();
f466cc5
+  lang_do_assignments (lang_final_phase_enum);
f466cc5
 
f466cc5
   ldemul_finish ();
f466cc5
 
f466cc5
diff -rup binutils-2.21.51.0.6/ld/ldlang.h binutils-2.21.51.0.6.new/ld/ldlang.h
f466cc5
--- binutils-2.21.51.0.6/ld/ldlang.h	2011-01-18 23:30:00.000000000 +0000
f466cc5
+++ binutils-2.21.51.0.6.new/ld/ldlang.h	2011-07-12 13:52:56.592941924 +0100
f466cc5
@@ -541,7 +541,7 @@ extern void lang_for_each_file
f466cc5
 extern void lang_reset_memory_regions
f466cc5
   (void);
f466cc5
 extern void lang_do_assignments
f466cc5
-  (void);
f466cc5
+  (lang_phase_type);
f466cc5
 
f466cc5
 #define LANG_FOR_EACH_INPUT_STATEMENT(statement)			\
f466cc5
   lang_input_statement_type *statement;					\
f466cc5
diff -rup binutils-2.21.51.0.6/ld/pe-dll.c binutils-2.21.51.0.6.new/ld/pe-dll.c
f466cc5
--- binutils-2.21.51.0.6/ld/pe-dll.c	2010-07-09 20:35:52.000000000 +0100
f466cc5
+++ binutils-2.21.51.0.6.new/ld/pe-dll.c	2011-07-12 13:53:00.596923809 +0100
f466cc5
@@ -1,6 +1,6 @@
f466cc5
 /* Routines to help build PEI-format DLLs (Win32 etc)
f466cc5
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
f466cc5
-   2008, 2009, 2010 Free Software Foundation, Inc.
f466cc5
+   2008, 2009, 2010, 2011 Free Software Foundation, Inc.
f466cc5
    Written by DJ Delorie <dj@cygnus.com>
f466cc5
 
f466cc5
    This file is part of the GNU Binutils.
f466cc5
@@ -3226,7 +3226,7 @@ pe_dll_fill_sections (bfd *abfd, struct 
f466cc5
       ldemul_after_allocation ();
f466cc5
 
f466cc5
       /* Do the assignments again.  */
f466cc5
-      lang_do_assignments ();
f466cc5
+      lang_do_assignments (lang_final_phase_enum);
f466cc5
     }
f466cc5
 
f466cc5
   fill_edata (abfd, info);
f466cc5
@@ -3258,7 +3258,7 @@ pe_exe_fill_sections (bfd *abfd, struct 
f466cc5
       ldemul_after_allocation ();
f466cc5
 
f466cc5
       /* Do the assignments again.  */
f466cc5
-      lang_do_assignments ();
f466cc5
+      lang_do_assignments (lang_final_phase_enum);
f466cc5
     }
f466cc5
   reloc_s->contents = reloc_d;
f466cc5
 }