Upload Tizen:Base source
[external/binutils.git] / packaging / 163_pr12726.diff
1 ld/
2
3 2011-05-04  Alan Modra  <amodra@gmail.com>
4
5         PR ld/12726
6         * ldexp.h (lang_phase_type): Add lang_assigning_phase_enum.
7         * ldexp.c (exp_fold_tree_1): Correct assign to dot comment.  Don't
8         assign to dot when lang_assigning_phase_enum.
9         * ldlang.h (lang_do_assignments): Update prototype.
10         * ldlang.c (lang_do_assignments): Add phase parameter.  Update all
11         callers.
12         * pe-dll.c (pe_dll_fill_sections, pe_exe_fill_sections): Update
13         lang_do_assignments calls.
14  
15         PR ld/12614
16 diff --git a/ld/ldexp.c b/ld/ldexp.c
17 index fc18601..f70634c 100644
18 --- a/ld/ldexp.c
19 +++ b/ld/ldexp.c
20 @@ -783,12 +783,15 @@ exp_fold_tree_1 (etree_type *tree)
21      case etree_provided:
22        if (tree->assign.dst[0] == '.' && tree->assign.dst[1] == 0)
23         {
24 -         /* Assignment to dot can only be done during allocation.  */
25           if (tree->type.node_class != etree_assign)
26             einfo (_("%F%S can not PROVIDE assignment to location counter\n"));
27 +         /* After allocation, assignment to dot should not be done inside
28 +            an output section since allocation adds a padding statement
29 +            that effectively duplicates the assignment.  */
30           if (expld.phase == lang_mark_phase_enum
31               || expld.phase == lang_allocating_phase_enum
32 -             || (expld.phase == lang_final_phase_enum
33 +             || ((expld.phase == lang_assigning_phase_enum
34 +                  || expld.phase == lang_final_phase_enum)
35                   && expld.section == bfd_abs_section_ptr))
36             {
37               /* Notify the folder that this is an assignment to dot.  */
38 diff --git a/ld/ldexp.h b/ld/ldexp.h
39 index 6d98e75..4ea13c2 100644
40 --- a/ld/ldexp.h
41 +++ b/ld/ldexp.h
42 @@ -97,6 +97,7 @@ typedef enum {
43    lang_first_phase_enum,
44    lang_mark_phase_enum,
45    lang_allocating_phase_enum,
46 +  lang_assigning_phase_enum,
47    lang_final_phase_enum
48  } lang_phase_type;
49  
50 diff --git a/ld/ldlang.c b/ld/ldlang.c
51 index 2c07fa4..c291fd9 100644
52 --- a/ld/ldlang.c
53 +++ b/ld/ldlang.c
54 @@ -5606,8 +5606,9 @@ lang_do_assignments_1 (lang_statement_union_type *s,
55  }
56  
57  void
58 -lang_do_assignments (void)
59 +lang_do_assignments (lang_phase_type phase)
60  {
61 +  expld.phase = phase;
62    lang_statement_iteration++;
63    lang_do_assignments_1 (statement_list.head, abs_output_section, NULL, 0);
64  }
65 @@ -6403,7 +6404,7 @@ lang_relax_sections (bfd_boolean need_layout)
66  
67               /* Do all the assignments with our current guesses as to
68                  section sizes.  */
69 -             lang_do_assignments ();
70 +             lang_do_assignments (lang_assigning_phase_enum);
71  
72               /* We must do this after lang_do_assignments, because it uses
73                  size.  */
74 @@ -6424,7 +6425,7 @@ lang_relax_sections (bfd_boolean need_layout)
75    if (need_layout)
76      {
77        /* Final extra sizing to report errors.  */
78 -      lang_do_assignments ();
79 +      lang_do_assignments (lang_assigning_phase_enum);
80        lang_reset_memory_regions ();
81        lang_size_sections (NULL, TRUE);
82      }
83 @@ -6666,8 +6667,7 @@ lang_process (void)
84  
85    /* Do all the assignments, now that we know the final resting places
86       of all the symbols.  */
87 -  expld.phase = lang_final_phase_enum;
88 -  lang_do_assignments ();
89 +  lang_do_assignments (lang_final_phase_enum);
90  
91    ldemul_finish ();
92  
93 diff --git a/ld/ldlang.h b/ld/ldlang.h
94 index db47af8..d172c34 100644
95 --- a/ld/ldlang.h
96 +++ b/ld/ldlang.h
97 @@ -543,7 +543,7 @@ extern void lang_for_each_file
98  extern void lang_reset_memory_regions
99    (void);
100  extern void lang_do_assignments
101 -  (void);
102 +  (lang_phase_type);
103  
104  #define LANG_FOR_EACH_INPUT_STATEMENT(statement)                       \
105    lang_input_statement_type *statement;                                        \
106 diff --git a/ld/pe-dll.c b/ld/pe-dll.c
107 index c8abf4d..682ce46 100644
108 --- a/ld/pe-dll.c
109 +++ b/ld/pe-dll.c
110 @@ -1,6 +1,6 @@
111  /* Routines to help build PEI-format DLLs (Win32 etc)
112     Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
113 -   2008, 2009, 2010 Free Software Foundation, Inc.
114 +   2008, 2009, 2010, 2011 Free Software Foundation, Inc.
115     Written by DJ Delorie <dj@cygnus.com>
116  
117     This file is part of the GNU Binutils.
118 @@ -3232,7 +3232,7 @@ pe_dll_fill_sections (bfd *abfd, struct bfd_link_info *info)
119        ldemul_after_allocation ();
120  
121        /* Do the assignments again.  */
122 -      lang_do_assignments ();
123 +      lang_do_assignments (lang_final_phase_enum);
124      }
125  
126    fill_edata (abfd, info);
127 @@ -3264,7 +3264,7 @@ pe_exe_fill_sections (bfd *abfd, struct bfd_link_info *info)
128        ldemul_after_allocation ();
129  
130        /* Do the assignments again.  */
131 -      lang_do_assignments ();
132 +      lang_do_assignments (lang_final_phase_enum);
133      }
134    reloc_s->contents = reloc_d;
135  }