3 2011-05-04 Alan Modra <amodra@gmail.com>
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
12 * pe-dll.c (pe_dll_fill_sections, pe_exe_fill_sections): Update
13 lang_do_assignments calls.
16 diff --git a/ld/ldexp.c b/ld/ldexp.c
17 index fc18601..f70634c 100644
20 @@ -783,12 +783,15 @@ exp_fold_tree_1 (etree_type *tree)
22 if (tree->assign.dst[0] == '.' && tree->assign.dst[1] == 0)
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))
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
42 @@ -97,6 +97,7 @@ typedef enum {
43 lang_first_phase_enum,
45 lang_allocating_phase_enum,
46 + lang_assigning_phase_enum,
50 diff --git a/ld/ldlang.c b/ld/ldlang.c
51 index 2c07fa4..c291fd9 100644
54 @@ -5606,8 +5606,9 @@ lang_do_assignments_1 (lang_statement_union_type *s,
58 -lang_do_assignments (void)
59 +lang_do_assignments (lang_phase_type phase)
61 + expld.phase = phase;
62 lang_statement_iteration++;
63 lang_do_assignments_1 (statement_list.head, abs_output_section, NULL, 0);
65 @@ -6403,7 +6404,7 @@ lang_relax_sections (bfd_boolean need_layout)
67 /* Do all the assignments with our current guesses as to
69 - lang_do_assignments ();
70 + lang_do_assignments (lang_assigning_phase_enum);
72 /* We must do this after lang_do_assignments, because it uses
74 @@ -6424,7 +6425,7 @@ lang_relax_sections (bfd_boolean need_layout)
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);
83 @@ -6666,8 +6667,7 @@ lang_process (void)
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);
93 diff --git a/ld/ldlang.h b/ld/ldlang.h
94 index db47af8..d172c34 100644
97 @@ -543,7 +543,7 @@ extern void lang_for_each_file
98 extern void lang_reset_memory_regions
100 extern void lang_do_assignments
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
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>
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 ();
121 /* Do the assignments again. */
122 - lang_do_assignments ();
123 + lang_do_assignments (lang_final_phase_enum);
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 ();
130 /* Do the assignments again. */
131 - lang_do_assignments ();
132 + lang_do_assignments (lang_final_phase_enum);
134 reloc_s->contents = reloc_d;