2010-02-08 Doug Kwan <dougkwan@google.com>
[platform/upstream/binutils.git] / gold / ChangeLog
1 2010-02-08  Doug Kwan  <dougkwan@google.com>
2
3         * arm.cc (Arm_relobj::simple_input_section_output_address): New
4         method.
5         (Arm_relobj::section_needs_cortex_a8_stub_scanning,
6         Arm_relobj::scan_section_for_cortex_a8_stubs,
7         Arm_relobj::do_relocation_section): Instead of calling
8         Output_section::output_address, use faster
9         Arm_relobj::simple_input_section_output_address.
10
11 2010-02-08  David S. Miller  <davem@davemloft.net>
12
13         * sparc.cc (Target_sparc::Relocate::relocate): If relocation offset is
14         unaligned for R_SPARC_16, R_SPARC_32, or R_SPARC_64, use the unaligned
15         relocation helper function.
16
17         * sparc.cc (Target_sparc::Scan::local): Handle R_SPARC_GOTDATA_OP*
18         just like R_SPARC_GOT{10,13,22}.
19         (Target_sparc::Scan::local): Likewise.
20         (Target_sparc::Relocate:relocate): Likewise.
21
22 2010-02-06  Ian Lance Taylor  <iant@google.com>
23
24         * configure.ac: Rewrite targetobjs duplicate removal code to use
25         only shell constructs.
26         * configure: Rebuild.
27
28 2010-02-05  Doug Kwan  <dougkwan@google.com>
29
30         PR 11247
31         * arm.cc (Arm_relobj::section_is_scannable): New method.
32         (Arm_relobj::section_needs_reloc_stub_scanning): Use it.
33         (Arm_relobj::section_needs_cortex_a8_stub_scanning): Same.
34
35 2010-02-04  Doug Kwan  <dougkwan@google.com>
36
37         PR 11247
38         * arm-reloc-property.cc (cstdio): Include.
39         * configure.ac (targetobjs): Remove duplicates.
40         * configure: Regenerate.
41         * resolve.cc (Symbol_table::resolve): Explicit instantiate both
42         big and little endian version for a given address size.
43
44 2010-02-03  Doug Kwan  <dougkwan@google.com>
45
46         * arm-reloc-property.cc
47         (Arm_reloc_property_table::reloc_name_in_error_message): New method
48         definition.
49         * arm-reloc-property.h
50         (Arm_reloc_property_table::get_implemented_static_reloc_property):
51         New method definition.
52         (Arm_reloc_property_table::reloc_name_in_error_message): New method
53         declaration.
54         * arm-reloc.def (THM_MOVT_ABS, THM_MOVT_PREL, THM_MOVT_BREL): Change
55         overflow to N.
56         (GOT_PREL): Change implemented to Y.
57         * arm.cc (Target_arm::reloc_uses_thumb_bit): Remove method.
58         (Target_arm::Relocate::reloc_needs_sym_origin): Remove method.
59         (Arm_relocate_functions::movw_abs_nc): Remove method.
60         (Arm_relocate_functions::movt_abs): Ditto.
61         (Arm_relocate_functions::thm_movw_abs_nc): Ditto.
62         (Arm_relocate_functions::thm_movt_abs): Ditto.
63         (Arm_relocate_functions::movw_rel_nc): Ditto.
64         (Arm_relocate_functions::movw_rel): Ditto.
65         (Arm_relocate_functions::movt_rel): Ditto.
66         (Arm_relocate_functions:thm_movw_rel_nc): Ditto.
67         (Arm_relocate_functions:thm_movw_rel): Ditto.
68         (Arm_relocate_functions:thm_movt_rel): Ditto.
69         (Arm_relocate_functions::movw, Arm_relocate_functions::movt,
70         (Arm_relocate_functions::thm_movw, Arm_relocate_functions::thm_movt):
71         New method definitions.
72         (Arm_relocation_functions::arm_grp_alu): Add assertion for group index.
73         (Arm_relocation_functions::arm_grp_ldr): Ditto.
74         (Arm_relocation_functions::arm_grp_ldrs): Ditto.
75         (Arm_relocation_functions::arm_grp_ldc): Ditto.
76         (Target_arm::Relocate::relocate): Check for non-static or
77         unimplemented relocation code and exit early.  Change calls to
78         Target_arm::reloc_uses_thumb_bit and
79         Target_arm::Reloc::reloc_needs_sym_origin to use relocation property
80         instead.  Refactor code to handle similar relocations to increase
81         code sharing.  Remove check for unsupported relocation code in switch
82         statement.
83         (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): Use
84         relocation property table to find out size.  Change error message to
85         print out the name of a relocation code instead of the numeric value.
86         (Target_arm::scan_reloc_for_stub): Use relocation property table
87         instead of calling Target_arm::reloc_uses_thumb_bit().
88
89 2010-02-02  Doug Kwan  <dougkwan@google.com>
90
91         * arm.cc (Target_arm::relocate_section): Do view adjustment for all
92         types of relaxed input section.
93
94 2010-02-02  Doug Kwan  <dougkwan@google.com>
95
96         * Makefile.am (HFILES): Add arm-reloc-property.h.
97         (DEFFILES): New.
98         (TARGETSOURCES): Add arm-reloc-property.cc
99         (ALL_TARGETOBJS): Add arm-reloc-property.$(OBJEXT)
100         (libgold_a_SOURCES): $(DEFFILES)
101         * Makefile.in: Regenerate.
102         * arm-reloc-property.cc: New file.
103         * arm-reloc-property.h: New file.
104         * arm-reloc.def: New file.
105         * arm.cc: Update comments.
106         (arm-reloc-property.h): New included header.
107         (arm_reloc_property_table): New global variable.
108         (Target_arm::do_select_as_default_target): New method definition.
109         * configure.tgt (armeb*-*-*,armbe*-*-*,arm*-*-*): Add
110         arm-reloc-property to targ_extra_obj.
111         * parameters.cc (set_parameters_target): Call
112         Target::select_as_default_target().
113         * target.h (Target::select_as_default_target): New method definition.
114         (Target::do_select_as_default_target): Same.
115
116 2010-02-01  Doug Kwan  <dougkwan@google.com>
117
118         * arm.cc (Arm_exidx_fixup::Arm_exidx_fixup): Initialize
119         first_output_text_section_.
120         (Arm_exidx_fixup::first_output_text_section): New method definition.
121         (Arm_exidx_fixup::first_output_text_section_): New data member.
122         (Arm_exidx_fixup::process_exidx_section): Record the first text
123         output section seen.
124         (Arm_output_section::fix_exidx_coverage): Set correct linked section
125         and entsize in output section header.
126
127 2010-01-29  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
128
129         * gold/arm.cc: Added support for the ARM relocations: R_ARM_THM_PC8,
130         R_ARM_THM_PC12, R_ARM_THM_ALU_PREL_11_0.
131         (Arm_relocate_functions::thm_alu11): New Method.
132         (Arm_relocate_functions::thm_pc8): New Method.
133         (Arm_relocate_functions::thm_pc12): New Method.
134         (Target_arm::Scan::local): Handle the relocations.
135         (Target_arm::Scan::global): Likewise.
136         (Target_arm::Relocate::relocate): Likewise.
137         (Target_arm:Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
138
139 2010-01-29  Doug Kwan  <dougkwan@google.com>
140
141         * arm.cc (Target_arm::Scan::global): General PLTs for the same set
142         of relocation types as ld.
143
144 2010-01-29  Doug Kwan  <dougkwan@google.com>
145
146         * arm.cc (Arm_relocate_functions::arm_branch_common) Change visibility
147         to public.
148         (Arm_relocate_functions::thumb_branch_common): Ditto.
149         (Arm_relocate_functions::thm_call, Arm_relocate_functions::thm_jump24,
150         Arm_relocate_functions::thm_xpc22, Arm_relocate_functions::plt32,
151         Arm_relocate_functions::xpc25, Arm_relocate_functions::call,
152         Arm_relocate_functions::jump24): Remove.
153         (Target_arm::Relocate::relocate): Adjust code to call
154         Arm_relocation_functions::arm_branch_common and
155         Arm_relocation_functions::thumb_branch_common instead of their removed
156         wrappers.  Merge switch-cases together to reduce source code size.  
157
158 2010-01-29  Doug Kwan  <dougkwan@google.com>
159
160         * arm.cc (Arm_relobj::Arm_relobj): Initialize new data member
161         output_local_symbol_count_needs_update_.
162         (Arm_relobj::output_local_symbol_count_needs_update,
163          Arm_relobj::set_output_local_symbol_count_needs_update,
164          Arm_relobj::update_output_local_symbol_count): New methods.
165         (Arm_relobj::output_local_symbol_count_needs_update_): New data
166         member.
167         (Arm_exidx_cantunwind::do_fixed_endian_write): Write address
168         of pointed function as in a R_ARM_PREL31 relocation.
169         (Arm_output_section<big_endian>::fix_exidx_coverage): Mark objects
170         for output local symbol count updating.
171         (Target_arm::do_relax): Update output local symbol counts in objects
172         if necessary.
173         * object.h (Sized_relobj::set_output_local_symbol_count): New method.
174
175 2010-01-29  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
176
177         * arm.cc: Added support for the ARM relocations:
178         R_ARM_MOVW_BREL_NC, R_ARM_MOVT_BREL, R_ARM_MOVW_BREL,
179         R_ARM_THM_MOVW_BREL_NC, R_ARM_THM_MOVT_BREL, R_ARM_THM_MOVW_BREL.
180         (Arm_relocate_functions::movw_rel_nc): Renamed (was
181         movw_prel_nc).
182         (Arm_relocate_functions::movw_rel): New method.
183         (Arm_relocate_functions::movt_rel): Renamed (was movt_prel).
184         (Arm_relocate_functions::thm_movw_rel_nc): Renamed (was
185         thm_movw_prel_nc).
186         (Arm_relocate_functions::thm_movw_rel): New method.
187         (Arm_relocate_functions::thm_movt_rel): Renamed (was
188         thm_movt_prel).
189         (Target_arm::Scan::local): Handle MOVW_BREL/MOVT_BREL
190         relocations.
191         (Target_arm::Scan::global): Likewise.
192         (Target_arm::Relocate::relocate): Likewise.
193         (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
194         Likewise.
195
196 2010-01-27  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
197
198         * arm.cc: Added support for ARM group relocations.
199         (Target_arm::reloc_needs_sym_origin): New method.
200         (Arm_relocate_functions::calc_grp_kn): New method.
201         (Arm_relocate_functions::calc_grp_residual): New method.
202         (Arm_relocate_functions::calc_grp_gn): New method.
203         (Arm_relocate_functions::arm_grp_alu): New Method.
204         (Arm_relocate_functions::arm_grp_ldr): New Method.
205         (Arm_relocate_functions::arm_grp_ldrs): New Method.
206         (Arm_relocate_functions::arm_grp_ldc): New Method.
207         (Target_arm::Scan::local): Handle the ARM group relocations.
208         (Target_arm::Scan::global): Likewise.
209         (Target_arm::Relocate::relocate): Likewise.
210         (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
211         Likewise.
212
213 2010-01-26  Doug Kwan  <dougkwan@google.com>
214
215         * arm.cc (set): Include.
216         (class Arm_exidx_fixup): Change type of last_input_section_ to const
217         pointer type.
218         (Arm_output_section::Text_section_list): New type.
219         (Arm_output_section::append_text_sections_to_list): New method.
220         (Arm_output_section::fix_exidx_coverage): Ditto.
221         (Arm_relobj::Arm_relobj): Initialize exidx_section_map_.
222         (Arm_relobj::convert_input_section_to_relaxed_section): Use
223         Relobj::set_section_offset() instead of
224         Sized_relobj::invalidate_section_offset().
225         (Arm_relobj::section_needs_reloc_stub_scanning): Add an extra
226         parameter for section headers. Ignore relocation sections for
227         unallocated sections and EXIDX sections.
228         (Target_arm::fix_exidx_coverage): New method.
229         (Target_arm::output_section_address_less_than): New type.
230         (Arm_exidx_fixup::add_exidx_cantunwind_as_needed): Use index of the
231         linked text section instead of the EXIDX section.
232         (Arm_output_section::create_stub_group): Add an assertion to check
233         that this is not an EXIDX output section.
234         (Arm_output_section::append_text_sections_to_list): New method.
235         (Arm_output_section::fix_exidx_coverage): Ditto.
236         (Arm_relobj::scan_sections_for_stubs): Adjust call to
237         Arm_relobj::section_needs_reloc_stub_scanning.
238         (Target_arm::do_relax): Fix EXIDX output section coverage in the
239         first pass.
240         (Target_arm::fix_exidx_coverage): New method.
241         * object.h (Relobj::set_output_section): New method.
242         (Sized_relobj::invalidate_section_offset): Remove method.
243         (Sized_relobj::do_invalidate_section_offset): Remove method.
244         (Sized_relobj::do_set_section_offset): Handle offset value -1.
245
246 2010-01-25  Doug Kwan  <dougkwan@google.com>
247
248         * arm.cc (Arm_exidx_merged_section::do_output_offset):
249         Fix warning due to signed and unsigned comparison on a 32-bit host.
250
251 2010-01-22  Doug Kwan  <dougkwan@google.com>
252
253         * arm.cc (Target_arm::do_relax): Record an output section for section
254         offset adjustment it contains any stub table that has changed.
255         * layout.cc (Layout::clean_up_after_relaxation): Adjust section
256         offsets in an output section if necessary.
257         * output.cc (Output_section::Output_section): Initialize
258         section_offsets_need_adjustments_.
259         (Output_section::add_input_section_for_script): Renamed to
260         Output_section::add_simple_input_section.
261         (Output_section::save_states): Add a comment.
262         (Output_section::discard_states): New method defintion.
263         (Output_section::adjust_section_offsets): Same.
264         * output.h (Output_section::add_input_section_for_script): Renamed to
265         Output_section::add_simple_input_section.
266         (Output_section::discard_states): New method declaration.
267         (Output_section::adjust_section_offsets): Same.
268         (Output_section::section_offsets_need_adjustment,
269         Output_section::set_section_offsets_need_adjustment): New method
270         definitions.
271         (Output_section::section_offsets_need_adjustment_): New data member.
272         * script-sections.cc
273         (Output_section_element_input::set_section_address): Adjust code for
274         renaming of Output_section::add_input_section_for_script.
275         (Orphan_output_section::set_section_address): Same.
276
277 2010-01-22  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
278
279         * gold/arm.cc (Target_arm): Updated fix_v4bx method and usage of
280         Fix_v4bx enum values .
281         * gold/options.h (General_options): New option definitions.
282         (General_options::fix_v4bx): New method.
283         (General_options::Fix_v4bx): New enum.
284         * gold/options.cc (General_options::parse_fix_v4bx): New method.
285         (General_options::parse_fix_v4bx_interworking): New method.
286
287 2010-01-22  Doug Kwan  <dougkwan@google.com>
288
289         * arm.cc (Arm_exidx_fixup): New class.
290
291 2010-01-21  Doug Kwan  <dougkwan@google.com>
292
293         * arm.cc (Arm_exidx_cantunwind, Arm_exidx_merged_section): New
294         classes.
295         (Arm_exidx_section_offset_map): New type.
296
297 2010-01-21  Doug Kwan  <dougkwan@google.com>
298
299         * arm.cc (Arm_exidx_input_section): New class.
300         (Arm_relobj::exidx_input_section_by_link,
301         Arm_relobj::exidx_input_section_by_shndx,
302         Arm_relobj::make_exidx_input_section): New methods.
303         (read_arm_attributes_section): Remove.
304         (Arm_relobj::do_read_symbols): Look for ARM.exidx sections and record
305         information about them.
306         (Arm_dynobj::do_read_symbols): Move code in read_arm_attributes_section
307         to here.
308
309 2010-01-20  Doug Kwan  <dougkwan@google.com>
310
311         * arm.cc (Target_arm::Arm_input_section_map): Change key type from
312         Input_section_specifier to Section_id.
313         (Target_arm::new_arm_input_section: Adjust code for change of key
314         type.
315         (Target_arm::find_arm_input_section): Ditto.
316         * gc.h (object.h): Include for Section_id nand Section_id_hash.
317         (Section_id): Remove.
318         (Garbage_collection::Section_id_hash): Remove.
319         * icf.h (object.h): Include for Section_id nand Section_id_hash.
320         (Section_id): Remove.
321         (Icf::Section_id_hash): Remove.
322         * object.h (Section_id, Const_section_id, Section_id_hash,
323         Const_section_id_hash): New type definitions.
324         * output.cc (Output_section::add_relaxed_input_section): Change to
325         use Const_section_id instead of Input_section_specifier as key type.
326         (Output_section::add_merge_input_section): Ditto.
327         (Output_section::build_relaxation_map): Change to use Section_id
328         instead of Input_section_specifier as key type.
329         (Output_section::convert_input_sections_in_list_to_relaxed_sections):
330         Ditto.
331         (Output_section::convert_input_sections_to_relaxed_sections): Change
332         to use Const_section_id instead of Input_section_specifier as key type.
333         (Output_section::find_merge_section): Ditto.
334         (Output_section::find_relaxed_input_section): Ditto.
335         * output.h (Input_section_specifier): Remove class.
336         (Output_section::Output_section_data_by_input_section_map): Change
337         key type to Const_section_id.
338         (Output_section::Output_relaxed_input_section_by_input_section_map):
339         Ditto.
340         (Output_section::Relaxation_map): Change key type to Section_id.
341
342 2010-01-20  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
343
344         * gold/arm.cc: Added support for R_ARM_V4BX relocation
345         (class Arm_v4bx_stub): New class.
346         (DEF_STUBS): Updated definition to support v4_veneer_bx.
347         (Stub_factory::make_arm_v4bx_stub): New method.
348         (Stub_factory::elf32_arm_stub_v4_veneer_bx): New veneer template.
349         (Stub_table::empty): Handle v4bx stubs.
350         (Stub_table::add_arm_v4bx_stub): New method.
351         (Stub_table::find_arm_v4bx_stub): New method.
352         (Arm_relocate_functions::v4bx): New method.
353         (Target_arm::fix_v4bx): New method.
354         (Target_arm::Target_arm): Handle R_ARM_V4BX.
355         (Stub_table::relocate_stubs): Likewise.
356         (Stub_table::do_write): Likewise.
357         (Stub_table::update_data_size_and_addralign): Likewise.
358         (Stub_table::finalize_stubs):  Likewise.
359         (Target_arm::Scan::local): Likewise.
360         (Target_arm::Scan::global): Likewise.
361         (Target_arm::do_finalize_sections): Likewise.
362         (Target_arm::Relocate::relocate): Likewise.
363         (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
364         Likewise.
365         (Target_arm::scan_reloc_for_stub): Likewise.
366         (Target_arm::scan_reloc_section_for_stubs): Likewise.
367
368 2010-01-19  Ian Lance Taylor  <iant@google.com>
369
370         * output.cc (Output_section_headers::do_sized_write): Write large
371         segment count to sh_info field.
372         (Output_file_header::do_sized_write): For large segment count,
373         write PN_XNUM to e_phnum field.
374
375 2010-01-15  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
376
377         * arm.cc (Arm_relocate_functions::thm_jump6): New function.
378         (Arm_relocate_functions::thm_jump8): New function.
379         (Arm_relocate_functions::thm_jump11): New function.
380         (Target_arm::Scan::local): Handle R_ARM_THM_JUMP6, R_ARM_THM_JUMP8,
381         R_ARM_THM_JUMP11.
382         (Target_arm::Scan::global): Likewise.
383         (Target_arm::Relocate::relocate): Likewise.
384         (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
385         Likewise.
386
387 2010-01-14  Doug Kwan  <dougkwan@google.com>
388
389         * arm.cc (map, utility): Include headers.
390         (Target_arm::apply_cortex_a8_workaround): New method.
391         (Arm_relobj::do_relocate_sections): Apply any Cortex-A8 workaround.
392         (Target_arm::Scan::local): Handle R_ARM_THM_JUMP24, R_ARM_THM_JUMP19.
393         (Target_arm::Scan::global): R_ARM_THM_JUMP19.
394         (Target_arm::do_finalize_sections): Set fix_cortex_a8_ according to
395         the --[no-]fix-cortex-a8 command line options.
396         (Target_arm::Relocate::relocate): Handle R_ARM_JUMP19.
397         (Target_arm::relocate_stub): Use addend in instruction template.
398         * options.h (DEFINE_bool): Set the user-set flag.
399         (General_options): Add --[no-]-fix-cortex options.
400         * output.cc (Output_section::convert_input_sections_to_relaxed_sections)
401         : Update fast look-up map after conversion. 
402
403 2010-01-14  Sriraman Tallam  <tmsriram@google.com>
404
405         * object.cc (Sized_relobj::do_layout): Change to call layout_gnu_stack
406         in the first pass of do_layout.
407
408 2010-01-13  Doug Kwan  <dougkwan@google.com>
409
410         * arm.cc (Arm_relobj::section_needs_reloc_stub_scanning,
411         Arm_relobj::scan_sections_for_stubs): Rearrange code to avoid an
412         apparent compiler problem of not folding static constant integral
413         data members of elfcpp::Elf_sizes<32>.
414
415 2010-01-13  Doug Kwan  <dougkwan@google.com>
416
417         * arm.cc (Arm_relobj::section_needs_reloc_stub_scanning,
418         Arm_relobj::section_needs_cortex_a8_stub_scanning,
419         Arm_relobj::scan_section_for_cortex_a8_erratum,
420         Arm_relobj::scan_span_for_cortex_a8_erratum): New methods.
421         (Arm_relobj::scan_sections_for_stubs): Move code deciding what
422         sections to scan for relocation stubs into a new method
423         Arm_relobj::section_needs_reloc_stub_scanning.  Handle both
424         relocation and Cortex-A8 stub scanning.
425         (Target_arm::do_relax): Force stubs to be after stubbed sections
426         if fixing the Cortex-A8 erratum.  Remove all Cortex-A8 stubs at
427         the beginning of a new relaxation pass.  Update a comment. 
428         (Target_arm::scan_span_for_cortex_a8_erratum): New method definition.
429
430 2010-01-12  Ian Lance Taylor  <iant@google.com>
431
432         * target-reloc.h (visibility_error): New inline function.
433         (relocate_section): Call visibility_error.
434         * testsuite/Makefile.am (check_DATA): Add protected_3.err.
435         (MOSTLYCLEANFILES): Likewise.
436         (protected_4_pic.o, protected_3.err): New targets.
437         * testsuite/protected_4.cc: New file.
438
439 2010-01-12  Doug Kwan  <dougkwan@google.com>
440
441         * arm.cc (Cortex_a8_reloc): New class.
442         (Target_arm::Target_arm): Initialize new data members fix_cortex_a8_
443         and cortex_a8_relocs_info_.
444         (Target_arm::fix_cortex_a8): New method definition.
445         (Target_arm::Cortex_a8_relocs_info): New type.
446         (Target_arm::fix_cortex_a8_, Target_arm::cortex_a8_relocs_info_):
447         New data member declarations.
448         (Target_arm::scan_reloc_for_stub): Record information about
449         relocations for THUMB branches that might be exempted from the
450         Cortex-A8 workaround.
451         (Target_arm::do_relax): Clear all Cortex-A8 relocation information
452         at the beginning of a relaxation pass.
453
454 2010-01-12  Doug Kwan  <dougkwan@google.com>
455
456         * arm.cc (Arm_relobj::mapping_symbols_info_): New data member.
457         (Arm_relobj::Mapping_symbol_position,
458          Arm_reloj::Mapping_symbol_position_less,
459          Arm_relobj::Mapping_symbols_info): New types.
460         (Target_arm::is_mapping_symbol_name): New method definition.
461         (Arm_relobj::do_count_local_symbols): Save information about mapping
462         symbols.
463
464 2010-01-11  Doug Kwan  <dougkwan@google.com>
465
466         * arm.cc (Arm_relocate_functions::thumb32_branch_offset,
467         Arm_relocate_functions::thumb32_branch_upper,
468         Arm_relocate_functions::thumb32_branch_lower,
469         Arm_relocate_functions::thumb32_cond_branch_offset,
470         Arm_relocate_functions::thumb32_cond_branch_upper,
471         Arm_relocate_functions::thumb32_cond_branch_lower,
472         Arm_relocate_functions::thm_jump19): New methods to handle THUMB
473         branch offset encoding.
474         (Arm_relocate_functions::thumb_branch_common): Use new branch
475         offset encoding methods to avoid code duplication.
476         (Stub_template::Stub_template) Handle THUMB16_SPECIAL_TYPE.
477         (Stub_addend_reader::operator()): Use new branch encoding method
478         to avoid code duplication.
479
480 2010-01-11  Doug Kwan  <dougkwan@google.com>
481
482         * arm.cc (Arm_relobj::do_gc_process_relocs): New method.
483         (Target_arm::do_finalize_sections): Define special EXIDX section
484         symbols only if referenced.
485         * gc.h (Garbage_collection::add_reference): New method.
486         (gc_process_relocs): Use Garbage_collection::add_reference to avoid
487         code duplication.
488
489 2010-01-11  Ian Lance Taylor  <iant@google.com>
490
491         * script.cc (Version_script_info::build_expression_list_lookup):
492         Change complaing about duplicate wildcard match from error to
493         warning.
494
495         * script.cc (class Lazy_demangler): Recreate--revert part of patch
496         of 2009-12-30.
497         (Version_script_info::Version_script_info): Initialize globs_,
498         default_version_, default_is_global_, and exact_.  Don't
499         initialize globals_ or locals_.
500         (Version_script_info::build_lookup_tables): Build local symbols
501         first.
502         (Version_script_info::unquote): New function.
503         (Version_script_info::add_exact_match): New function.
504         (Version_script_info::build_expression_list_lookup): Remove lookup
505         parameter.  Add is_global parameter.  Change all callers.  Handle
506         wildcard pattern specially.  Unquote pattern.  Call
507         add_exact_match.
508         (Version_script_info::get_name_to_match): New function.
509         (Version_script_info::get_symbol_version): New function.
510         (Version_script_info::get_symbol_version_helper): Remove.
511         (Version_script_info::check_unmatched_names): Call unquote.
512         * script.h (class Version_script_info): Change get_symbol_version
513         to be non-inline and add is_global parameter; change all callers.
514         Rewrite symbol_is_local.  Update declarations.  Define struct
515         Version_tree_match, Exact, Globs.  Don't define struct Lookup.
516         Remove globals_ and locals_ members.  Add exact_, globs_,
517         default_version_, is_global_.
518         (Version_script_info::Glob): Remove pattern, add expression and
519         is_global.  Update constructor.  Change all callers.
520         * dynobj.cc (Versions::finalize): Mark the version symbol as the
521         default version.
522         (Versions::symbol_section_contents): If a symbol is undefined, or
523         defined in a dynamic object, set the version index to
524         VER_NDX_LOCAL.
525         * symtab.cc (Symbol_table::add_from_relobj): Don't call
526         symbol_is_local.
527         (Symbol_table::add_from_pluginobj): Likewise.
528         * testsuite/ver_matching_test.sh: blaza1 and blaza go into V2.
529
530 2010-01-11  Doug Kwan  <dougkwan@google.com>
531
532         * Makefile.am (incremental_dump_DEPENDENCIES): Add libintl dependency.
533         (incremental_dump_LDADD): Add linking option for libintl.
534         * Makefile.in: Regenerate.
535
536 2010-01-11  H.J. Lu  <hongjiu.lu@intel.com>
537
538         PR gold/11144
539         * testsuite/Makefile.am (dynamic_list.stdout): Use --dyn-syms
540         instead of -Ds.
541         * testsuite/Makefile.in: Regenerated.
542
543 2010-01-10  Doug Kwan  <dougkwan@google.com>
544
545         * options.h (DEFINE_var): Use parentheses around argument varname__
546         in macro body to avoid any unintended subsequent substitutions.
547
548 2010-01-10  Ian Lance Taylor  <iant@google.com>
549
550         * resolve.cc (Symbol_table::resolve): Add symbols to list of ODR
551         candidates before doing symbol resolution.
552
553         * resolve.cc (Symbol_table::resolve): Add symbols to the list of
554         ODR candidates if only one is weak.
555
556 2010-01-08  Ian Lance Taylor  <iant@google.com>
557
558         * script.cc (Version_script_info::build_expression_list_lookup):
559         Don't warn about ambiguous version, just record the ambiguity.
560         (Version_script_info::get_symbol_version_helper): Give error if
561         version is ambiguous.
562
563 2010-01-08  Doug Kwan  <dougkwan@google.com>
564
565         * arm.cc (Stub_table::Stub_table): Initalize cortex_a8_stubs_,
566           prev_data_size_ and prev_addralign_.  Remove initializer for
567           deleted data member has_been_changed_.
568           (Stub_table::empty): Look at both reloc_stubs_ and cortex_a8_stubs_
569           to determine if the table is empty.
570           (Stub_table::has_been_changed, Stub_table_set_has_been_changed):
571           Remove.
572           (Stub_table::add_reloc_stub): Define method in class definition
573           instead of just declaring it there.
574           (Stub_table::add_cortex_a8_stub): New method definition.
575           (Stub_table::update_data_size_and_addralign): Ditto.
576           (Stub_table::finalize_stubs): Ditto.
577           (Stub_table::apply_cortex_a8_workaround_to_address_range): Ditto.
578           (Stub_table::do_addralign_): Return address alignment in the
579           (Stub_table::do_reset_address_and_file_offset): Define method in
580           class definition instead of declaring it there.  Set current data
581           size to be the data size of the previous pass.
582           (Stub_table::set_final_data_size): Use current data size as the
583           final data size.
584           (Stub_table::relocate_stub): Change parameter type of stub from
585           Reloc_stub pointer to Stub pointer.
586           (Stub_table::addralign_, Stub_table::has_been_changed_): Remove.
587           (Stub_table::Cortex_a8_stub_list): New typedef.
588           (Stub_table::cortex_a8_stubs_, Stub_table::prev_data_size_,
589            Stub_table::prev_addralign_): New data member.
590           (Arm_relobj::Arm_relobj): Initialize data member
591           section_has_cortex_a8_workaround_.
592           (Arm_relobj::section_has_cortex_a8_workaround,
593            Arm_relobj::mark_section_for_cortex_a8_workaround): New method
594            definitions.
595           (Arm_relobj::section_has_cortex_a8_workaround_): New data member
596           declarations.
597           (Target_arm::relocate_stub): Change parameter type of stub from
598           Reloc_stub pointer to Stub pointer.
599           (Insn_template::size, Insn_template::alignment): Handle
600           THUMB16_SPECIAL_TYPE.
601           (Stub_table::remove_all_cortex_a8_stubs, Stub_table::finalize_stubs,
602            Stub_table::update_data_size_and_addralign,
603            Stub_table::apply_cortex_a8_workaround_to_address_range): New method
604           definitions.
605           (Stub_table::relocate_stubs): Handle Cortex-A8 stubs.
606           (Stub_table::do_write): Ditto.
607           (Target_arm::do_relax): Adjust code for changes in Stub_table.
608
609 2010-01-08  Ian Lance Taylor  <iant@google.com>
610
611         PR 11108
612         * symtab.h (class Symbol): Remove fields is_target_special_ and
613         has_plt_offset_.  Add field is_defined_in_discarded_section_.
614         (Symbol::is_defined_in_discarded_section): New function.
615         (Symbol::set_is_defined_in_discarded_section): New function.
616         (Symbol::has_plt_offset): Rewrite.
617         (Symbol::set_plt_offset): Verify that new offset is not -1U.
618         * symtab.cc (Symbol::init_fields): Initialize plt_offset_ to -1U.
619         Don't initialize is_target_special_ or has_plt_offset_.
620         Initialize is_defined_in_discarded_section_.
621         (Symbol_table::add_from_relobj): If appropriate, set
622         is_defined_in_discarded_section.
623         * resolve.cc (Symbol::override_base_with_special): Don't test
624         is_target_special_.  Change has_plt_offset_ to has_plt_offset().
625         * target-reloc.h (relocate_section): Do special handling for
626         symbols defined in discarded sections for global symbols as well
627         as local symbols.
628
629 2010-01-08  Ian Lance Taylor  <iant@google.com>
630
631         * dynobj.cc (big_endian>::find_dynsym_sections): Set pi to NULL in
632         the SHT_SYMTAB case.
633
634 2010-01-08  Ian Lance Taylor  <iant@google.com>
635
636         * object.cc (Sized_relobj::do_layout): Don't get confused if
637         layout_eh_frame returns NULL.
638
639 2010-01-08  Ian Lance Taylor  <iant@google.com>
640
641         PR 11084
642         * dynobj.cc (Sized_dynobj::find_dynsym_sections): If there is no
643         dynamic symbol table, use the normal symbol table.
644         (Sized_dynobj::do_read_symbols): Remove assertion about type of
645         symbol table.
646
647 2010-01-08  Ian Lance Taylor  <iant@google.com>
648
649         PR 11072
650         * layout.cc (Layout::include_section): Remove .gnu_debuglink
651         sections.
652
653 2010-01-08  H.J. Lu  <hongjiu.lu@intel.com>
654
655         * version.cc (print_version): Change to "Copyright 2010".
656
657 2010-01-08  Ian Lance Taylor  <iant@google.com>
658
659         PR 10287
660         PR 11063
661         * i386.cc (class Target_i386): Change return type of plt_section
662         to be non-const.
663         (class Output_data_plt_i386): Add tls_desc_rel_ field.
664         (Output_data_plt_i386::Output_data_plt_i386): Initialize
665         tls_desc_rel_ field.
666         (Output_data_plt_i386::rel_tls_desc): New function.
667         (Target_i386::rel_tls_desc_section): New function.
668         (Target_i386::Scan::local): Rewrite R_386_TLS_GOTDESC handling.
669         (Target_i386::Scan::global): For R_386_TLS_GOTDESC put
670         R_386_TLS_DESC reloc in rel_tls_desc_section.
671         * x86_64.cc (class Target_x86_64): Add tlsdesc_reloc_info_ field.
672         Define struct Tlsdesc_info.
673         (Target_x86_64::Target_x86_64): Initialize tlsdesc_reloc_info_.
674         (Target_x86_64::do_reloc_symbol_index): New function.
675         (Target_x86_64::add_tlsdesc_info): New function.
676         (class Output_data_plt_x86_64): Add tlsdesc_rel_ field.
677         (Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize
678         tlsdesc_rel_ field.
679         (Output_data_plt_x86_64::rela_plt): Rename from rel_plt.  Change
680         all callers.
681         (Output_data_plt_x86_64::rela_tlsdesc): New function.
682         (Target_x86_64::rela_tlsdesc_section): New function.
683         (Target_x86_64::Scan::local): Rewrite R_X86_64_GOTPC32_TLSDESC
684         handling.
685         (Target_x86_64::Scan::global): For R_X86_64_GOTPC32_TLSDESC put
686         (Target_x86_64::do_reloc_addend): New function.
687         R_X86_64_TLSDESC reloc in rela_tlsdesc_section.
688         * output.h (class Output_reloc) [SHT_REL]: Add new constructor
689         declarations.  Define TARGET_CODE.  Add arg field to u1_ union.
690         (Output_reloc::type): New function.
691         (Output_reloc::is_local_section_symbol): Check for TARGET_CODE.
692         (Output_reloc::is_target_specific): New function.
693         (Output_reloc::target_arg): New function.
694         (class Output_reloc) [SHT_RELA]: Add four new constructors for
695         absolute relocs and target specific relocs.
696         (class Output_data_reloc) [SHT_REL]: Add add_absolute and
697         add_target_specific.
698         (class Output_data_reloc) [SHT_RELA]: Likewise.
699         * output.cc (Output_reloc::Output_reloc): Add four new versions
700         for absolute relocs and target specific relocs.
701         (Output_reloc::set_needs_dynsym_index): Add TARGET_CODE case.
702         (Output_reloc::get_symbol_index): Likewise.
703         (Output_reloc::local_section_offset): Check that local_sym_index_
704         is not TARGET_CODE or 0.
705         (Output_reloc::symbol_value): Likewise.
706         (Output_reloc::write) [SHT_RELA]: Call target for target specific
707         reloc.
708         * target.h (class Target): Add reloc_symbol_index and reloc_addend
709         functions.  Add do_reloc_symbol_index and do_reloc_addend virtual
710         functions.
711         * layout.cc (add_target_dynamic_tags): Use output section for
712         DT_PLTRELSZ and DT_JMPREL.
713
714 2010-01-07  Ian Lance Taylor  <iant@google.com>
715
716         PR 11061
717         * output.h (class Output_reloc) [SHT_RELA]: Add is_relative
718         function.
719         (class Output_data_reloc_generic): Define.
720         (class Output_data_reloc_base): Change base class to
721         Output_data_reloc_generic.  Change add() method to call
722         bump_relative_reloc_count for a relative reloc.  Remove
723         sort_relocs_ field.
724         * output.cc (Output_data_reloc_base::do_write): Change sort_reloc_
725         to sort_relocs().
726         * layout.cc (Layout::add_target_dynamic_tags): Change dyn_rel to
727         Output_data_reloc_generic*.  Add DT_RELCOUNT/DT_RELACOUNT tag if
728         appropriate.
729         * layout.h (class Layout): Update declaration.
730
731 2010-01-07  Ian Lance Taylor  <iant@google.com>
732
733         * output.h (class Output_data): Add const version of
734         output_section and do_output_section.
735         (class Output_section_data): Add const version of
736         do_output_section.
737         (class Output_section): Likewise.
738         * layout.cc (Layout::add_target_dynamic_tags): New function.
739         * layout.h (class Layout): Update declarations.
740         * arm.cc (Target_arm::do_finalize_sections): Use
741         add_target_dynamic_tags.
742         * i386.cc (Target_i386::do_finalize_sections): Likewise.
743         * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
744         * sparc.cc (Target_sparc::do_finalize_sections): Likewise.
745         * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
746
747 2010-01-07  Ian Lance Taylor  <iant@google.com>
748
749         PR 11042
750         * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Mark the dynamic
751         object as needed.
752
753 2010-01-07  Dmitry Gorbachev  <d.g.gorbachev@gmail.com>
754             Ian Lance Taylor  <iant@google.com>
755
756         PR 11019
757         * object.cc: Instantiate Xindex::initialize_symtab_xindex and
758         Xindex::read_symtab_xindex.
759
760 2010-01-07  Doug Kwan  <dougkwan@google.com>
761
762         * arm.cc (Insn_template::Type): New enum value THUMB16_SPECIAL_TYPE.
763         (Insn_template::thumb16_bcond_insn): New method declaration.
764         (Insn_template): Fix spelling.
765         (Stub::thumb16_special): New method declaration.
766         (Stub::do_write): Define virtual method which was previously pure
767         virtual.
768         (Stub::do_thumb16_special): New method declaration.
769         (Stub::do_fixed_endian_write): New template member.
770         (Reloc_stub::do_write): Remove.
771         (Reloc_stub::do_fixed_endian_write): Remove.
772         (Cortex_a8_stub): New class definition.
773         (Stub_factory::make_cortex_a8_stub): New method definition.
774         (Stub_factory::Stub_factory): Add missing static storage class
775         qualifier for elf32_arm_stub_a8_veneer_blx.
776
777 2010-01-07  Ian Lance Taylor  <iant@google.com>
778
779         PR 10980
780         * options.h (class General_options): Add --warn-unresolved-symbols
781         and --error-unresolved-symbols.
782         * errors.cc (Errors::undefined_symbol): Implement
783         --warn-unresolved-symbols.
784
785         * options.h (class General_options): Add -z text and -z textoff.
786         * layout.cc (Layout::finish_dynamic_section): Implement -z text.
787
788 2010-01-06  Sriraman Tallam  <tmsriram@google.com>
789
790         * gc.h (Garbage_collection::Cident_section_map): New typedef.
791         (Garbage_collection::cident_sections): New function.
792         (Garbage_collection::add_cident_section): New function.
793         (Garbage_collection::cident_sections_): New member.
794         (gc_process_relocs): Add references to sections whose names are C
795         identifiers.
796         * gold.h (cident_section_start_prefix): New constant.
797         (cident_section_stop_prefix): New constant.
798         (is_cident): New function.
799         * layout.cc (Layout::define_section_symbols): Replace string constants
800         with the newly defined constants.
801         * object.cc (Sized_relobj::do_layout): Track sections whose names are
802         C identifiers.
803         * testsuite/Makefile.am: Add gc_orphan_section_test.
804         * testsuite/Makefile.in: Regenerate.
805         * testsuite/gc_orphan_section_test.cc: New file.
806         * testsuite/gc_orphan_section_test.sh: New file.
807
808 2010-01-06  Ian Lance Taylor  <iant@google.com>
809
810         PR 10980
811         * options.h (class General_options): Add --warn-shared-textrel.
812         * layout.cc (Layout::finish_dynamic_section): Implement
813         --warn-shared-textrel.
814
815         PR 10980
816         * options.h (class General_options): Add --warn-multiple-gp.
817
818 2010-01-06  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
819
820         * Makefile.am (incremental_dump_DEPENDENCIES): Remove
821         $(THREADSLIB) and $(LIBDL).
822         * Makefile.in: Rebuild.
823
824 2010-01-06  Ian Lance Taylor  <iant@google.com>
825
826         PR 10980
827         * options.cc (General_options::parse_section_start): New function.
828         (General_options::section_start): New function.
829         (General_options::General_options): Initialize all members.
830         * options.h: Include <map>
831         (class General_options): Add --section-start.  Add section_starts_
832         member.
833         * layout.cc (Layout::attach_allocated_section_to_segment): If
834         --section-start was used, set the address of the segment.  Remove
835         local sort_sections.
836         (Layout::relaxation_loop_body): If the address of the load segment
837         has been set by --section-start, don't use it.
838         * output.h (Output_segment::update_flags_for_output_section): New
839         function.
840         * output.cc (Output_segment::add_output_section): Call
841         update_flags_for_output_section.
842
843 2010-01-05  Ian Lance Taylor  <iant@google.com>
844
845         PR 10980
846         * options.h (class General_options): Add --undefined-version.
847         * script.cc (struct Version_expression): Add was_matched_by_symbol
848         field.
849         (Version_script_info::matched_symbol): New function.
850         (Version_script_info::get_symbol_version_helper): Call
851         matched_symbol.
852         (Version_script_info::check_unmatched_names): New function.
853         * script.h (class Version_script_info): Update declarations.
854         * gold.cc (queue_middle_tasks): Handle --no-undefined-version.
855
856         * options.h (class General_options): Use DEFINE_bool_alias for
857         allow_multiple_definition.
858         * resolve.cc (Symbol_table::should_override): Don't test
859         allow_multiple_definition.
860
861         PR 10980
862         * options.h (class General_options): Add --cref.
863         * main.cc (main): Print cref table if --cref.  Don't close mapfile
864         until after printing cref table.
865         * cref.cc: Include "symtab.h".
866         (class Cref_inputs): Define Cref_table_compare and Cref_table.
867         (Cref_table_compare::operator()): New function.
868         (Cref_inputs::gather_cref): New function.
869         (filecol): New static const.
870         (Cref_inputs::print_cref): New function.
871         (Cref::print_cref): New function.
872         * cref.h: Include <cstdio>.
873         (class Cref): Update declarations.
874         * mapfile.h (Mapfile::file): New function.
875         * object.h (class Object): Define Symbols.  Declare virtual
876         do_get_global_symbols.
877         (Object::get_global_symbols): New function.
878         * object.cc (Input_objects::add_object): Pass object to cref_ if
879         --cref.
880         (Input_objects::archive_start): Likewise.
881         (Input_objects::archive_stop): Likewise.
882         (Input_objects::print_cref): New function.
883         * dynobj.h (Sized_dynobj::do_get_global_symbols): New function.
884         * dynobj.cc (big_endian>::do_add_symbols): Create symbols_ if
885         --cref.
886         * plugin.cc (Sized_pluginobj::do_get_global_symbols): New
887         function.
888         * plugin.h (class Sized_pluginobj): Update declarations.
889
890 2010-01-05  Ian Lance Taylor  <iant@google.com>
891
892         * symtab.cc (Symbol_table::add_from_object): Rename def parameter
893         to is_default_version.  Rename insdef to insdefault.
894         (Symbol_table::add_from_relobj): Rename def to is_default_version
895         and local to is_forced_local.
896         (Symbol_table::add_from_pluginobj): Likewise.
897         (Symbol_table::add_from_dynobj): Likewise.
898         (Symbol_table::define_special_symbol): Rename insdef to
899         insdefault.
900
901 2010-01-04  Ian Lance Taylor  <iant@google.com>
902
903         PR 10980
904         * options.h (class General_options): Add
905         --allow-multiple-definition and -z muldefs.
906         * resolve.cc (Symbol_table::should_override): Don't warn about a
907         multiple symbol definition if --allow-multiple-definition or -z
908         muldefs.
909
910         PR 10980
911         * options.h (class General_options): Add --add-needed and
912         --copy-dt-needed-entries.  Tweak --as-needed help entry.
913         * object.cc (Input_objects::check_dynamic_dependencies): Give an
914         error if --copy-dt-needed-entries aka --add-needed is used and
915         would cause a change in behaviour.
916
917         PR 10980
918         * options.h (class General_options): Add -G as a short version of
919         --shared.  Add no-op options -assert, -g, and -i.
920
921 2010-01-04  Sriraman Tallam  <tmsriram@google.com>
922
923         * gc.h (gc_process_relocs): Call is_section_foldable_candidate to
924         check for .text or .gnu.linkonce.t sections.
925         * icf.cc (Icf::find_identical_sections): Ditto.
926         Change the detection for mangled function name within the section
927         name.
928         * icf.h (is_section_foldable_candidate): New function.
929
930 2009-12-30  Ian Lance Taylor  <iant@google.com>
931
932         PR 10980
933         * options.h (class General_options): Permit two dashes with
934         --retain-symbols-file.
935
936 2009-12-30  Ian Lance Taylor  <iant@google.com>
937
938         PR 10979
939         * layout.cc (Layout::relaxation_loop_body): If -Ttext was used,
940         don't put the file header and segment headers in the text
941         segment.
942
943         PR 10979
944         * common.cc (Sort_commons::operator()): Stabilize sort when both
945         entries are NULL.
946         (Symbol_table::do_allocate_commons_list): When allocating common
947         symbols, skip a symbol which is no longer common.
948         * symtab.h (Symbol::is_common): Test whether the symbol comes from
949         an object before checking its type.
950         * testsuite/common_test_2.c: New file.
951         * testsuite/common_test_3.c: New file.
952         * testsuite/Makefile.am (check_PROGRAMS): Add common_test_2.
953         (common_test_2_SOURCES, common_test_2_DEPENDENCIES): Define.
954         (common_test_2_LDFLAGS, common_test_2_LDADD): Define.
955         (common_test_2_pic.o, common_test_2.so): New targets.
956         (common_test_3_pic.o, common_test_3.so): New targets.
957         * testsuite/Makefile.in: Rebuild.
958
959         PR 10979
960         * script.cc (read_input_script): If we see a new SECTIONS clause,
961         and we have added an input section, give an error.
962         * layout.h (class Layout): Add have_added_input_section function.
963         Add have_added_input_section_ field.
964         * layout.cc (Layout::Layout): Initialize
965         have_added_input_section_.
966         (Layout::layout): Set have_added_input_section_.
967         (Layout::layout_eh_frame): Likewise.
968
969 2009-12-30  Ian Lance Taylor  <iant@google.com>
970
971         PR 10931
972         * options.h (class General_options): Add --sort-common option.
973         * symtab.h (class Symbol_table): Define Sort_commons_order enum.
974         * common.cc (Sort_common): Add sort_order parameter to
975         constructor.  Add sort_order_ field.
976         (Sort_commons::operator): Check sort_order_.
977         (Symbol_table::allocate_commons): Determine the sort order.
978         (Symbol_table::do_allocate_commons): Add sort_order parameter.
979         Change all callers.
980         (Symbol_table::do_allocate_commons_list): Likewise.
981
982 2009-12-30  Ian Lance Taylor  <iant@google.com>
983
984         PR 10916
985         * symtab.cc (Symbol_table::add_from_relobj): When not exporting
986         symbols from this object, don't change the visibility of an
987         undefined symbol.
988         * testsuite/exclude_libs_test_1.c (lib1_ref): New function.
989
990 2009-12-30  Ian Lance Taylor  <iant@google.com>
991
992         PR 10861
993         * script.h (class Version_script_info): Define Language enum.
994         Update declarations.  Define Glob, Exact, and Lookup types.  Add
995         new fields globals_, locals_, and is_finalized_.
996         * script.cc: Various formatting fixes.
997         (class Parser_closure): Change language_stack_ from a vector of
998         std::string to one of Version_script_info::Language.  Adjust all
999         uses accordingly.
1000         (class Lazy_demangler): Remove.
1001         (struct Version_expression): Change language from std::string to
1002         Version_script_info::Language.
1003         (Version_script_info::Version_script_info): New function.
1004         (Version_script_info::~Version_script_info): Don't call clear.
1005         (Version_script_info::finalize): New function.
1006         (Version_script_info::build_lookup_tables): New function.
1007         (Version_script_info::build_expression_list_lookup): New
1008         function.
1009         (Version_script_info::get_symbol_version_helper): Rewrite to use
1010         lookup tables.
1011         (Version_script_info::print_expression_list): Adjust to use
1012         Version_script_info::Language.
1013         (script_push_lex_into_version_mode): Check that the version script
1014         has not been finalized.
1015         (version_script_push_lang): Change language string to
1016         Version_script_info::Language.
1017         * options.cc (Command_line::version_script): New function.
1018         * options.h (class General_options): Add finalize_dynamic_list
1019         function.  Change version_script from declaration to definition.
1020         * testsuite/ver_test_4.script: Remove duplicate def of t2_2.
1021         * testsuite/version_script.map: Remove duplicate def of foo.
1022         * testsuite/Makefile.am (ver_matching_def.so): Depend upon
1023         version_script.map.
1024         * testsuite/Makefile.in: Rebuild.
1025
1026 2009-12-30  Ian Lance Taylor  <iant@google.com>
1027
1028         PR 10843
1029         * target-reloc.h (relocate_for_relocatable): When copying a reloc,
1030         if the input symbol index is 0, make the output symbol index 0.
1031
1032 2009-12-30  Ian Lance Taylor  <iant@google.com>
1033
1034         PR 10670
1035         * options.h (class General_options): Add -x/--discard-all.
1036         * object.cc (Sized_relobj::do_count_local_symbols): Handle
1037         --discard-all.  If the local symbol needs a dynamic entry, check
1038         that before handling --discard-locals.
1039
1040 2009-12-30  Ian Lance Taylor  <iant@google.com>
1041
1042         PR 10450
1043         * output.cc (Output_segment::Output_segment): If PT_TLS, set the
1044         flags to PF_R.
1045         (Output_segment::add_output_section): Don't change the flags if
1046         the type is PT_TLS.
1047
1048         PR 10450
1049         * dynobj.cc (Dynobj::create_gnu_hash_table): Add symbols to the
1050         GNU hash table if they need a dynamic value.  Otherwise, don't add
1051         them if they are defined in a dynamic object or are forced local.
1052
1053 2009-12-29  Ian Lance Taylor  <iant@google.com>
1054
1055         PR 10450
1056         * layout.cc (Layout::create_dynamic_symtab): Only set entsize of
1057         .gnu.hash table for a 32-bit target.
1058
1059         PR 10450
1060         * symtab.h (Symbol::needs_dynsym_entry): A symbol in both a
1061         regular and a dynamic object only needs a dynamic symbol table
1062         entry if it is externally visible.
1063
1064         PR 10450
1065         * i386.cc (class Target_i386): Initialize global_offset_table_ in
1066         constructor.  Add global_offset_table_ field.
1067         (Target_i386::got_section): Set global_offset_table_.
1068         (Target_i386::do_finalize_sections): Set global_offset_table_
1069         size.
1070         * x86_64.cc (class Target_x86_64): Initialize global_offset_table_
1071         in constructor.  Add global_offset_table_ field.
1072         (Target_x86_64::got_section): Set global_offset_table_.
1073         (Target_x86_64::do_finalize_sections): Set global_offset_table_
1074         size.
1075
1076         * layout.cc (Layout::Layout): Initialize increase_relro_.
1077         (Layout::get_output_section): Add is_relro, is_last_relro, and
1078         is_first_non_relro parameters.  Change all callers.
1079         (Layout::choose_output_section): Likewise.
1080         (Layout::add_output_section_data): Likewise.
1081         (Layout::make_output_section): Likewise.
1082         (Layout::set_segment_offsets): Clear increase_relro when using a
1083         linker script.
1084         * layout.h (class Layout): Add increase_relro method.  Add
1085         increase_relro_ field.  Update declarations.
1086         * output.cc (Output_section::Output_section): Initialize
1087         is_last_relro_ and is_first_non_relro_.
1088         (Output_segment::add_output_section): Group relro sections is
1089         do_sort is true.  Handle is_last_relro and is_first_non_relro.
1090         (Output_segment::maximum_alignment): Remove relro handling.
1091         (Output_segment::set_section_addresses): Add increase_relro
1092         parameter.  Change all callers.  Add initial alignment to align
1093         relro sections on separate page.  Remove old relro handling.
1094         (Output_segment::set_section_list_addresses): Remove in_relro
1095         parameter.  Change all callers.
1096         (Output_segment::set_offset): Add increase parameter.  Change all
1097         callers.  Remove old relro handling.
1098         * output.h (class Output_section): Add new methods: is_last_relro,
1099         set_is_last_relro, is_first_non_relro, set_is_first_non_relro.
1100         Add is_last_relro_ and is_first_non_relro_ fields.
1101         * i386.cc (Target_i386::got_section): Don't call set_is_relro.
1102         Create separate .got.plt section.  Call increase_relro.
1103         * x86_64.cc (Target_x86_64::got_section): Likewise.
1104         * testsuite/relro_script_test.t: Add .got.plt.
1105
1106         PR 10450
1107         * layout.cc (Layout::Layout): Initialize dynamic_symbol_ field.
1108         (Layout::create_initial_dynamic_sections): Set dynamic_symbol_.
1109         (Layout::finalize): Call set_dynamic_symbol_size.
1110         (Layout::set_dynamic_symbol_size): New function.
1111         * layout.h (class Layout): Add dynamic_symbol_ field.  Declare
1112         set_dynamic_symbol_size.
1113
1114         PR 10450
1115         * output.h (class Output_section): Add is_entsize_zero_ field.
1116         * output.cc (Output_section::Output_section): Initialize
1117         is_entsize_zero_.
1118         (Output_section::set_entsize): If two different entsizes are
1119         requested, force it to zero.
1120         (Output_section::add_input_section): Set flags for .debug_str
1121         before updating section flags.  Set entsize.
1122         (Output_section::update_flags_for_input_section): Set SHF_MERGE
1123         and SHF_STRING if all input sections have those flags.
1124
1125 2009-12-29   Rafael Espindola  <espindola@google.com>
1126
1127         * main.cc (main): Fix the sys time reporting.
1128         * workqueue.cc (Workqueue::find_and_run_task): Fix the sys time
1129         reporting.
1130
1131 2009-12-29  Sriraman Tallam  <tmsriram@google.com>
1132
1133         * options.cc (General_options::parse_version): Allow -v to exit
1134         without an error if there is nothing to link.
1135
1136 2009-12-29  Ian Lance Taylor  <iant@google.com>
1137
1138         * configure.ac: Set the MCMODEL_MEDIUM conditional to false if
1139         using a version of gcc before 4.1.
1140         * configure: Rebuild.
1141
1142 2009-12-28  Chris Demetriou  <cgd@google.com>
1143
1144         * attributes.cc (Output_attributes_section_data::do_write): Use
1145         std::vector::front rather than std::vector::data.
1146
1147 2009-12-28  Ian Lance Taylor  <iant@google.com>
1148
1149         * symtab.h (class Symbol_table): Add enum Defined.
1150         * resolve.cc (Symbol_table::should_override): Add defined
1151         parameter.  Change all callers.  Test whether object is NULL
1152         before calling a method on it.
1153         (Symbol_table::report_resolve_problem): Add defined parameter.
1154         Change all callers.
1155         (Symbol_table::should_override_with_special): Likewise.
1156         * symtab.cc (Symbol_table::define_in_output_data): Add defined
1157         parameter.  Change all callers.
1158         (Symbol_table::do_define_in_output_data): Likewise.
1159         (Symbol_table::define_in_output_segment): Likewise.
1160         (Symbol_table::do_define_in_output_segment): Likewise.
1161         (Symbol_table::define_as_constant): Likewise.
1162         (Symbol_table::do_define_as_constant): Likewise.
1163         * script.h (class Symbol_assignment): Add is_defsym parameter to
1164         constructor; change all callers.
1165         * script.cc (Script_options::add_symbol_assignment): Add is_defsym
1166         parameter.  Change all callers.  Add is_defsym_ field.
1167         (class Parser_closure): Add parsing_defsym parameter to
1168         constructor; change all callers.  Add parsing_defsym accessor
1169         function.  Add parsing_defsym_ field.
1170
1171 2009-12-28  Ian Lance Taylor  <iant@google.com>
1172
1173         * gold.cc (queue_middle_tasks): Fix formatting.
1174         * object.cc (Relobj::is_section_name_included): Likewise.
1175
1176 2009-12-23  Ian Lance Taylor  <iant@google.com>
1177
1178         * i386.cc (Target_i386::do_calls_non_split): Recognize
1179         -fsplit-stack prologue for a function with a static chain.
1180         * x86_64.cc (Target_x86_64::do_calls_non_split): Recognize
1181         -fsplit-stack prologue when using %r11.
1182
1183 2009-12-21  Sriraman Tallam  <tmsriram@google.com>
1184
1185         * options.cc (General_options::parse_version): Make -v continue and do
1186         the link like GNU ld does.
1187
1188 2009-12-17  Rafael Avila de Espindola  <espindola@google.com>
1189
1190         * Makefile.am (CCFILES): Add timer.cc.
1191         (HFILES): Add timer.h.
1192         * configure.ac: Check for sysconf and times.
1193         * main.cc: include timer.h.
1194         (main): Use Timer instead of get_run_time.
1195         * timer.cc: New.
1196         * timer.h: New.
1197         * workqueue.cc: include timer.h.
1198         (Workqueue::find_and_run_task):
1199         Report user, sys and wall time.
1200         * Makefile.in: Regenerate.
1201         * config.in: Regenerate.
1202         * configure: Regenerate.
1203
1204 2009-12-16  Doug Kwan  <dougkwan@google.com>
1205
1206         * arm.cc (Arm_relobj::scan_sections_for_stubs): Exclude ICF-eliminated
1207         sections.
1208         * object.cc (Sized_relobj::do_finalize_local_symbols): Handle
1209         relaxed input sections.
1210         * output.cc (Output_section::find_relaxed_input_section): Change
1211         return type to Output_relaxed_input_section pointer.  Adjust code
1212         for new type of relaxed_input_section_map_.
1213         * output.h (Output_section::find_relaxed_input_section): Change
1214         return type to Output_relaxed_input_section pointer.
1215         (Output_section::Output_relaxed_input_section_by_input_section_map):
1216         New type.
1217         (Output_section::relaxed_input_section_map_): Change type to
1218         Output_section::Output_relaxed_input_section_by_input_section_map.
1219         * symtab.cc (Symbol_table::compute_final_value): Handle relaxed
1220         input section.
1221
1222 2009-12-15  Ian Lance Taylor  <iant@google.com>
1223
1224         * layout.cc (Layout::create_shstrtab): Only write out after input
1225         sections if we are compressing debug sections.
1226
1227 2009-12-15  Ian Lance Taylor  <iant@google.com>
1228
1229         * archive.cc (Archive::add_symbols): Only look up a symbol without
1230         a version if there is, in fact, a version.
1231
1232 2009-12-14  Ian Lance Taylor  <iant@google.com>
1233
1234         Revert -Wshadow changes, all changes from:
1235         2009-12-11  Doug Kwan  <dougkwan@google.com>
1236         2009-12-11  Nick Clifton  <nickc@redhat.com>
1237         * configure.ac: Remove -Wshadow when setting WARN_CXXFLAGS.
1238
1239 2009-12-11  Doug Kwan  <dougkwan@google.com>
1240
1241         * arm.cc (Target_arm::do_finalize_sections): Fix build breakage
1242         due to -Wshadow.
1243         * attributes.cc (Object_attribute::size): Ditto.
1244         (Attributes_section_data::size): Ditto.
1245         (Attributes_section_data::Attributes_section_data): Ditto.
1246         (Output_attributes_section_data::do_write): Ditto.
1247         * attributes.h (Object_attribute::set_type): Ditto.
1248         * testsuite/tls_test_main.cc (safe_lock, safe_unlock): Ditto.
1249
1250 2009-12-11  Nick Clifton  <nickc@redhat.com>
1251
1252         * archive.cc: Fix shadowed variable warnings.
1253         * arm.cc: Likewise.
1254         * compressed_output.cc: Likewise.
1255         * compressed_output.h: Likewise.
1256         * configure: Likewise.
1257         * dwarf_reader.cc: Likewise.
1258         * dynobj.cc: Likewise.
1259         * dynobj.h: Likewise.
1260         * ehframe.cc: Likewise.
1261         * ehframe.h: Likewise.
1262         * errors.cc: Likewise.
1263         * expression.cc: Likewise.
1264         * fileread.cc: Likewise.
1265         * fileread.h: Likewise.
1266         * freebsd.h: Likewise.
1267         * i386.cc: Likewise.
1268         * icf.cc: Likewise.
1269         * incremental.h: Likewise.
1270         * layout.cc: Likewise.
1271         * layout.h: Likewise.
1272         * mapfile.cc: Likewise.
1273         * merge.cc: Likewise.
1274         * merge.h: Likewise.
1275         * object.cc: Likewise.
1276         * object.h: Likewise.
1277         * options.h: Likewise.
1278         * output.cc: Likewise.
1279         * output.h: Likewise.
1280         * parameters.cc: Likewise.
1281         * plugin.cc: Likewise.
1282         * powerpc.cc: Likewise.
1283         * reduced_debug_output.cc: Likewise.
1284         * reduced_debug_output.h: Likewise.
1285         * reloc.cc: Likewise.
1286         * reloc.h: Likewise.
1287         * resolve.cc: Likewise.
1288         * script-sections.cc: Likewise.
1289         * script.cc: Likewise.
1290         * script.h: Likewise.
1291         * sparc.cc: Likewise.
1292         * symtab.cc: Likewise.
1293         * symtab.h: Likewise.
1294         * target-select.cc: Likewise.
1295         * target-select.h: Likewise.
1296         * token.h: Likewise.
1297         * workqueue.cc: Likewise.
1298         * workqueue.h: Likewise.
1299         * x86_64.cc: Likewise.
1300
1301 2009-12-10  Doug Kwan  <dougkwan@google.com>
1302
1303         * arm.cc (attributes.h): New include.
1304         (Arm_relobj::Arm_relobj): Initialize attributes_section_data_.
1305         (Arm_relobj::~Arm_relobj): Delete object pointed by
1306         attributes_section_data_.
1307         (Arm_relobj::attributes_section_data): New method definition.
1308         (Arm_relobj::attributes_section_data_): New data member declaration.
1309         (Arm_dynobj::Arm_dynobj): Initialize attributes_section_data_.
1310         (Arm_dynobj::~Arm_dynobj): Delete object pointed by
1311         attributes_section_data_.
1312         (Arm_dynobj::attributes_section_data): New method definition.
1313         (Arm_dynobj::attributes_section_data_): New data member declaration.
1314         (Target_arm::Target_arm): Initialize attributes_section_data_.  Change
1315         initialization value of may_use_blx_ to false.
1316         (Target_arm::using_thumb2, Target_arm::using_thumb_only,
1317         Target_arm::may_use_arm_nop, Target_arm::may_use_thumb2_nop): Use
1318         object attributes to compute results instead of hard-coding.
1319         (Target_arm::do_attribute_arg_type, Target_arm::do_attributes_order,
1320         Target_arm::get_secondary_compatible_arch,
1321         Target_arm::set_secondary_compatible_arch
1322         Target_arm::tag_cpu_arch_combine, Target_arm::aeabi_enum_name,
1323         Target_arm::tag_cpu_name_value, Target_arm::merge_object_attributes):
1324         New method declarations.
1325         (Target_arm::get_aeabi_object_attribute): New method definition.
1326         (Target_arm::attributes_section_data_): New data member declaration.
1327         (read_arm_attributes_section): New template definition.
1328         (Arm_relobj::do_read_symbols): Read attributes section if it exists.
1329         (Arm_dynobj::do_read_symbols): Ditto.
1330         (Target_arm::do_finalize_sections): Merge attributes sections from
1331         input.  Check for BLX use after attributes section merging.
1332         Fix __exidx_start and __exidx_end visibility.  Create an
1333         .ARM.attributes section if necessary.
1334         (Target_arm::get_secondary_compatible_arch,
1335         Target_arm::set_secondary_compatible_arch,
1336         Target_arm::tag_cpu_arch_combine, Target_arm::aeabi_enum_name,
1337         Target_arm::tag_cpu_name_value, Target_arm::merge_object_attributes,
1338         Target_arm::do_attribute_arg_type, Target_arm::do_attributes_order): 
1339         New method definitions.
1340
1341 2009-12-09  Ian Lance Taylor  <iant@google.com>
1342
1343         * plugin.cc (Plugin::load): Don't cast from void* to a function
1344         pointer.
1345
1346 2009-12-09  Ian Lance Taylor  <iant@google.com>
1347
1348         * dynobj.cc (Sized_dynobj::do_read_symbols): Clear version
1349         information fields.
1350
1351 2009-12-09  H.J. Lu  <hongjiu.lu@intel.com>
1352
1353         * testsuite/Makefile.am (two_file_shared_1_pic_2_test_DEPENDENCIES):
1354         Replace two_file_shared_1.so with two_file_shared_2.so.
1355         * testsuite/Makefile.in: Regenerated.
1356
1357 2009-12-08  Doug Kwan  <dougkwan@google.com>
1358
1359         * Makefile.am (CCFILES): Add attributes.cc and int_encoding.cc.
1360         (HFILES): Add attributes.h and int_encoding.h.
1361         * Makefile.in: Regenerate.
1362         * dwarf_reader.cc (read_unsigned_LEB_128, read_signed_LEB_128): Move
1363         function definitions to int_encoding.cc
1364         * dwarf_reader.h (read_unsigned_LEB_128, read_signed_LEB_128): Move
1365         prototypes to int_encoding.h
1366         * reduced_debug_output.cc (int_encoding.h): New include.
1367         (write_unsigned_LEB_128, get_length_as_unsigned_LEB_128): Move
1368         function definitions to int_encoding.cc
1369         (insert_into_vector, read_from_pointer): Move template definitions to
1370         int_encoding.h
1371         * attributes.cc: New file.
1372         * attributes.h: New file.
1373         * int_encoding.cc: New file.
1374         * int_encoding.h: New file.
1375
1376 2009-12-07  Rafael Avila de Espindola  <espindola@google.com>
1377
1378         PR gold/11055
1379         * incremental-dump.cc (dump_incremental_inputs): New.
1380         (main): Use dump_incremental_inputs.
1381
1382 2009-12-07  H.J. Lu  <hongjiu.lu@intel.com>
1383
1384         PR gold/10893
1385         * i386.cc (Target_i386::Scan::globa): Use is_func instead of
1386         checking elfcpp::STT_FUNC.
1387         (Target_i386::Relocate::relocate): Likewise.
1388         * x86_64.cc (Target_x86_64::Scan::global): Likewise.
1389
1390         * symtab.cc (Symbol_table::sized_write_symbol): Turn IFUNC
1391         symbols from shared libraries into normal FUNC symbols.
1392
1393         * symtab.h (Symbol): Add is_func and use it.
1394
1395 2009-12-05  Doug Kwan  <dougkwan@google.com>
1396
1397         * arm.cc (Target_arm::arm_info): Initialize new fields
1398         attributes_section and attributes_vendor.
1399         * i386.cc (Target_i386::i386_info): Same.
1400         * object.cc (Sized_relobj::do_layout): Skip attribute section.
1401         * gold/powerpc.cc (Target_powerpc::powerpc_info): Initialize new
1402         fields attributes_section and attributes_vendor.
1403         * sparc.cc (Target_sparc::sparc_info): Same.
1404         * target.h (Target::attributes_section, Target::attributes_vendor,
1405         Target::is_attributes_section, Target::attribute_arg_type,
1406         Target::attributes_order): New method definitions.
1407         (Target::Target_info::attributes_section,
1408         Target::Target_info::attributes_vendor): New fields.
1409         (Target::do_attribute_arg_type, Target::do_attributes_order): New
1410         virtual method definitions.
1411         * x86_64.cc (Target_x86_64::x86_64_info): Initialize new fields
1412         attributes_section and attributes_vendor.
1413         * testsuite/testfile.cc (Target_test::test_target_info): Same.
1414
1415 2009-12-05  Doug Kwan  <dougkwan@google.com>
1416
1417         * arm.cc: Update comments about interworking and stub generation.
1418         (Target_arm::Relocate::reloc_is_non_pic): Update list of relocations
1419         considered as non-PIC.
1420         (Arm_relocate_functions::base_abs): Fix formatting.
1421         (Arm_relocate_functions::got_prel): Fix comment.  Change interface
1422         of function to use GOT entry address instead of offset.
1423         (Target_arm::Scan::global): Issue an error if a symbol would need a
1424         PLT does not get one because it is untyped.  Remove code to create
1425         dynamic symbols for relative branches.
1426         (Target_arm::Relocate::relocate: Use 0 instead of false since function
1427         takes unsigned integer instead of boolean.
1428
1429 2009-12-05  H.J. Lu  <hongjiu.lu@intel.com>
1430
1431         * testsuite/Makefile.am (constructor_test_LDADD): New. Empty.
1432         (two_file_test_LDADD): Likewise.
1433         (common_test_1_LDADD): Likewise.
1434         (exception_test_LDADD) Likewise.
1435         (weak_test_LDADD): Likewise.
1436         (many_sections_test_LDADD): Likewise.
1437         (initpri1_LDADD): Likewise.
1438         (script_test_1_LDADD): Likewise.
1439         (script_test_2_LDADD): Likewise.
1440         (justsyms_LDADD): Likewise.
1441         (binary_test_LDADD): Likewise.
1442         (large_LDADD): Likewise.
1443         * testsuite/Makefile.in: Regenerated.
1444
1445 2009-12-04  H.J. Lu  <hongjiu.lu@intel.com>
1446
1447         * resolve.cc (symbol_to_bits): Treat STB_GNU_UNIQUE as STB_GLOBAL.
1448         (Symbol_table::override_with_special): Likewise.
1449         (Symbol_table::add_from_object): Likewise.
1450
1451 2009-12-04  Rafael Avila de Espindola  <espindola@google.com>
1452
1453         * incremental.cc (Incremental_inputs::sized_create_inputs_section_data):
1454         Don't set the data_offset twice.
1455
1456 2009-12-04  Rafael Avila de Espindola  <espindola@google.com>
1457
1458         * testsuite/Makefile.in: Regenerate.
1459
1460 2009-12-03  Doug Kwan  <dougkwan@google.com>
1461
1462         * arm.cc: Remove comment about missing .ARM.exidx section symbols.
1463         (Target_arm::do_finalize_sections): Add parameter for symbol table
1464         pointer.  Add __exidx_start and __exidx_end symbols as appropriate.
1465         * i386.cc (Target_i386::do_finalize_sections): Add an additional
1466         parameter for symbol table pointer.
1467         * layout.cc (Layout::finalize): Call Target::finalize_sections with
1468         an additional parameter for a pointer to symbol table.
1469         * powerpc.cc (Target_powerpc::do_finalize_sections): Add an additional
1470         parameter for a symbol table pointer.
1471         * sparc.cc (Target_sparc::do_finalize_sections): Ditto.
1472         * target.h (Target::finalize_sections, Target::do_finalize_sections):
1473         Ditto.
1474         * x86_64.cc (Target_x86_64::do_finalize_sections): Add an additional
1475         parameter for a symbol table pointer.
1476
1477 2009-12-03  Rafael Avila de Espindola  <espindola@google.com>
1478
1479         * incremental.cc (Incremental_inputs_header)
1480         (Incremental_inputs_header_write, Incremental_inputs_entry)
1481         (Incremental_inputs_entry_write): Move ...
1482         * incremental.h (Incremental_inputs_header)
1483         (Incremental_inputs_header_write, Incremental_inputs_entry)
1484         (Incremental_inputs_entry_write): here.
1485
1486 2009-12-02  Rafael Avila de Espindola  <espindola@google.com>
1487
1488         * incremental.cc (make_sized_incremental_binary): Set the target.
1489         Error if it is incompatible.
1490         * output.h (Output_file): Add filename method.
1491
1492 2009-12-02  Rafael Avila de Espindola  <espindola@google.com>
1493
1494         * incremental.cc (Incremental_inputs_entry): Remove unused argument
1495         from the get_* methods.
1496
1497 2009-12-02  Rafael Avila de Espindola  <espindola@google.com>
1498
1499         * incremental-dump.cc (main): Check that the offeset of a script is 0.
1500         * incremental.cc (Incremental_inputs::sized_create_inputs_section_data):
1501         Write 0 for the data_offset of scripts.
1502
1503 2009-12-02  Rafael Avila de Espindola  <espindola@google.com>
1504
1505         * testsuite/Makefile.am: Add the incremental_test.sh test.
1506         * testsuite/incremental_test.sh: New.
1507         * testsuite/incremental_test_1.c: New.
1508         * testsuite/incremental_test_2.c: New.
1509
1510 2009-12-01  Rafael Avila de Espindola  <espindola@google.com>
1511
1512        * incremental-dump.cc (main): Fix typos.
1513
1514 2009-11-27  Rafael Avila de Espindola  <espindola@google.com>
1515
1516         PR gold/11025
1517         * incremental-dump.cc (main): Use llu to print 64 bit values.
1518
1519 2009-11-26  Per Ã˜yvind Karlsen <peroyvind@mandriva.org>
1520             H.J. Lu  <hongjiu.lu@intel.com>
1521
1522         * Makefile.am (incremental_dump_DEPENDENCIES): Add $(THREADSLIB)
1523         $(LIBDL).
1524         (incremental_dump_LDADD): Likewise.
1525         * Makefile.in: Regenerated.
1526
1527 2009-11-25  Doug Kwan  <dougkwan@google.com>
1528         
1529         Revert:
1530
1531         2009-11-25  Doug Kwan  <dougkwan@google.com>
1532
1533                 * arm.cc (Target_arm::Target_arm): Move method definition
1534                 outside of class definition.  Add code to handle
1535                 --target1-rel, --target1-abs and --target2= options.
1536                 (Target_arm::get_reloc_reloc_type): Change method to be
1537                 non-static and const.
1538                 (Target_arm::target1_is_rel_, Target_arm::target2_reloc_):
1539                 New data member declaration.
1540                 (Target_arm::Scan::local, Target_arm::Scan::global,
1541                 Target_arm::Relocate::relocate,
1542                 Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
1543                 Adjust call to Target_arm::get_real_reloc_type.
1544                 (Target_arm::get_real_reloc_type): Use command line options
1545                 to determine real types of R_ARM_TARGET1 and R_ARM_TARGET2.
1546                 * options.h (--target1-rel, --target1-abs, --target2): New
1547                 ARM-only options.
1548
1549 2009-11-25  Doug Kwan  <dougkwan@google.com>
1550
1551         * arm.cc (Target_arm::Target_arm): Move method definition outside of
1552         class definition.  Add code to handle --target1-rel, --target1-abs
1553         and --target2= options.
1554         (Target_arm::get_reloc_reloc_type): Change method to be non-static
1555         and const.
1556         (Target_arm::target1_is_rel_, Target_arm::target2_reloc_): New data
1557         member declaration.
1558         (Target_arm::Scan::local, Target_arm::Scan::global,
1559         Target_arm::Relocate::relocate,
1560         Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): Adjust
1561         call to Target_arm::get_real_reloc_type.
1562         (Target_arm::get_real_reloc_type): Use command line options to
1563         determine real types of R_ARM_TARGET1 and R_ARM_TARGET2.
1564         * options.h (--target1-rel, --target1-abs, --target2): New ARM-only
1565         options.
1566
1567 2009-11-25  Doug Kwan  <dougkwan@google.com>
1568
1569         * arm.cc (Target_arm::may_use_thumb2_nop): New method definition.
1570         (Arm_relocate_functions::thumb_branch_common): New metod declaration.
1571         (Arm_relocate_functions::abs12, Arm_relocate_functions::abs16): Fix
1572         formatting.
1573         (Arm_relocate_functions::thm_call): Replace body with a call to
1574         Arm_relocate_functions::thumb_branch_common.
1575         (Arm_relocate_functions::thm_jump24,
1576         Arm_relocate_functions::thm_xpc22): New method definitions.
1577         (Arm_relocate_functions::thumb_branch_common): New method definition.
1578         (Reloc_stub::stbu_type_for_reloc): Fix incorrect uses of bit-wise-or
1579         operator.
1580         (Target_arm::Relocate::relocate): Adjust call to thm_call.
1581         Add code to handle R_ARM_THM_XPC22 and R_ARM_THM_JUMP24.
1582
1583 2009-11-24  Rafael Avila de Espindola  <espindola@google.com>
1584
1585         * Makefile.am: Build incremental-dump
1586         * Makefile.in: Regenerate.
1587         * incremental-dump.cc: New.
1588         * incremental.cc (Incremental_inputs_header_data,
1589         Incremental_inputs_entry_data): Move to incremental.h
1590         * incremental.h: (Incremental_inputs_header_data,
1591         Incremental_inputs_entry_data): Move from incremental.cc
1592
1593 2009-11-24  Rafael Avila de Espindola  <espindola@google.com>
1594
1595         * incremental.cc (Incremental_inputs_header,
1596         Incremental_inputs_header_write, Incremental_inputs_entry,
1597         Incremental_inputs_entry_write): Add a typedef with the data type.
1598
1599 2009-11-24  Rafael Avila de Espindola  <espindola@google.com>
1600
1601         * incremental.cc (Incremental_inputs_header,
1602         Incremental_inputs_header_write, Incremental_inputs_entry,
1603         Incremental_inputs_entry_write): Update comment about which
1604         type has the filed descriptions.
1605
1606 2009-11-15  Doug Kwan  <dougkwan@google.com>
1607
1608         * arm.cc (Target_arm::may_use_arm_nop): New method definition.
1609         (Arm_relocate_functions::arm_branch_common): Change method defintion
1610         in class definition to a method declaration and update list of formal
1611         parameters.
1612         (Arm_relocate_functions::plt32, Arm_relocate_functions::call,
1613         Arm_relocation_functions::jump24): Adjust call to
1614         Arm_relocate_functions::arm_branch_common.  Update list of formal
1615         parameters.
1616         (Arm_relocate_functions::xpc25): New method definition.
1617         (Arm_relocate_functions::arm_branch_common): Move method defintion
1618         out from class definition.  Use stubs for mode-switching and extending
1619         branch ranges.
1620         (Target_arm::Relocate::relocate): Handle weakly-undefined symbols
1621         specially.  Change code to enable use of stubs in ARM branches.
1622
1623 2009-11-10  Doug Kwan  <dougkwan@google.com>
1624
1625         * arm.cc (Arm_relobj::do_relocate_sections): Remove options parameter
1626         in method declaration.
1627         (Target_arm::relocate_stub): New method declaration.
1628         (Target_arm::default_target): Change to return a pointer instead of
1629         a const reference.
1630         (Reloc_stub::stub_type_for_reloc): Adjust for the change in
1631         Target_arm::default_target.
1632         (Arm_Relobj::do_relocate_sections): Remove options paramater in
1633         method definition.
1634         (Target_arm::relocate_section): Adjust view.
1635         (Target_arm::relocate_stub): New method definition.
1636
1637 2009-11-10  Doug Kwan  <dougkwan@google.com>
1638
1639         * i386.cc (Target_i386::do_calls_non_split): Add a cast to avoid
1640         a format warning.
1641         * incremental.cc (open_incremental_binary): Initialized local
1642         variables to avoid warnings.
1643         * object.cc (make_elf_object): Ditto.
1644         * x86_64.cc (Target_x86_64::do_calls_non_split): Add a cast to avoid
1645         a format warning.
1646  
1647 009-11-09  H.J. Lu  <hongjiu.lu@intel.com>
1648
1649         PR gold/10930
1650         * testsuite/plugin_test.c: Include "config.h".
1651
1652 2009-11-09  Doug Kwan  <dougkwan@google.com>
1653
1654         * arm.cc (Target_arm::fake_relnum_for_stubs): New constant.
1655         (arm_symbol_value): Remove.
1656         (Arm_relocate_functions::arm_branch_common,
1657         Arm_relocate_functions::abs8, Arm_relocate_functions::thm_abs5,
1658         Arm_relocate_functions::abs12, Arm_relocate_functions::abs16,
1659         Arm_relocate_functions::abs32, Arm_relocate_functions::rel32,
1660         Arm_relocate_functions::thm_call, Arm_relocate_functions::plt32,
1661         Arm_relocate_functions::call, Arm_relocate_functions::jump24,
1662         Arm_relocate_functions::prel31, Arm_relocate_functions::mov_abs_nc,
1663         Arm_relocate_functions::movt_abs, Arm_relocate_functions::movw_abs_nc,
1664         Arm_relocate_functions::thm_mobw_abs_nc,
1665         Arm_relocate_functions::thm_mov_abs,
1666         Arm_relocate_functions::movw_prel_nc,
1667         Arm_relocate_functions::thm_movt_abs,
1668         Arm_relocate_functions::movt_prel,
1669         Arm_relocate_functions::thm_movw_prel_nc,
1670         Arm_relocate_functions::thm_movt_prel): Adjust callers of the above.
1671         (Target_arm::Relocate::relocate): Only decompose address into two
1672         parts if relocation type uses the thumb-bit and pass the actual
1673         bit instead of a flag indicating that the thumb-bit is used.  Adjust
1674         calls to methods in Arm_relocate_functions for this change.
1675
1676 2009-11-08  Ian Lance Taylor  <iant@google.com>
1677
1678         PR 10925
1679         * reloc.cc: Instantiate
1680         Sized_relobj::initialize_input_to_output_maps and
1681         Sized_relobj:free_input_to_output_maps.
1682
1683 2009-11-06  Ian Lance Taylor  <iant@google.com>
1684
1685         PR 10876
1686         * defstd.cc (in_segment): Set only_if_ref true for "end".
1687
1688 2009-11-06  Doug Kwan  <dougkwan@google.com>
1689
1690         * arm.cc (class Reloc_stub): Correct a comment.
1691         (Target_arm::Target_arm): Initialize arm_input_section_map_.
1692         (Target_arm::scan_section_for_stubs): New method declaration.
1693         (Target_arm::do_make_elf_object, Target_arm::do_make_output_section):
1694         Change methods from private to protected.
1695         (Target_arm::do_may_relax): New method definition.
1696         (Target_arm::do_relax, Target_arm::group_sections,
1697         Target_arm::scan_reloc_for_stub,
1698         Target_arm::scan_reloc_section_for_stubs): New method declarations.
1699         (Target_arm::arm_input_section_map_): New data member declaration.
1700         (Target_arm::scan_reloc_for_stub,
1701         Target_arm::scan_reloc_section_for_stubs,
1702         Target_arm::scan_section_for_stubs, Target_arm::group_sections,
1703         Target_arm::do_relax): New method definitions.
1704
1705 2009-11-06  Mikolaj Zalewski  <mikolaj@google.com>
1706
1707         * configure.ac: Check for (struct stat)::st_mtim
1708         * fileread.cc (File_read::get_mtime): Use st_mtim if available.
1709         * config.in: Regenerate.
1710         * configure: Regenerate.
1711
1712 2009-11-05  Ian Lance Taylor  <iant@google.com>
1713
1714         PR 10910
1715         * output.cc (Output_segment::add_output_section): Add missing
1716         return statement.
1717
1718 2009-11-04  Ian Lance Taylor  <iant@google.com>
1719
1720         PR 10880
1721         * object.h (class Object): Add is_needed and set_is_needed
1722         methods.  Add is_needed_ field.  Make bool fields into bitfields.
1723         * symtab.cc (Symbol_table::set_dynsym_indexes): If a symbol is
1724         defined in a dynamic object and referenced by a regular object,
1725         set is_needed for the dynamic object.
1726         * layout.cc (Layout::finish_dynamic_section): Don't add DT_NEEDED
1727         if the file is marked with as_needed and it is not needed.
1728
1729 2009-11-04  Ian Lance Taylor  <iant@google.com>
1730
1731         PR 10887
1732         * arm.cc (Target_arm::do_finalize_sections): Don't add dynamic
1733         tags if data is discarded by linker script.
1734         * i386.cc (Target_i386::do_finalize_sections): Likewise.
1735         * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
1736         * sparc.cc (Target_sparc::do_finalize_sections): Likewise.
1737         * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
1738
1739 2009-11-04  Ian Lance Taylor  <iant@google.com>
1740
1741         * layout.cc (Layout::get_output_section): Add is_interp and
1742         is_dynamic_linker_section parameters.  Change all callers.
1743         (Layout::choose_output_section): Likewise.
1744         (Layout::make_output_section): Likewise.
1745         (Layout::add_output_section_data): Add is_dynamic_linker_section
1746         parameter.  Change all callers.
1747         * layout.h (class Layout): Update declarations.
1748         * output.h (class Output_section): Add is_interp, set_is_interp,
1749         is_dynamic_linker_section, set_is_dynamic_linker_section methods.
1750         Add is_interp_, is_dynamic_linker_section_ fields.  Change
1751         generate_code_fills_at_write_ to a bitfield.
1752         * output.cc (Output_section::Output_sections): Initialize new
1753         fields.
1754         (Output_segment::add_output_section): Add do_sort parameter.
1755         Change all callers.
1756
1757 2009-11-03  Ian Lance Taylor  <iant@google.com>
1758
1759         PR 10860
1760         * options.h (class General_options): Add --warn-common.
1761         * resolve.cc (Symbol_table::resolve): Handle --warn-common when
1762         merging two common symbols.
1763         (Symbol_table::should_override): Handle --warn-common when merging
1764         a common symbol with a defined symbol.  Use report_resolve_problem
1765         for multiple definitions.
1766         (Symbol_table::report_resolve_problem): New function.
1767         * symtab.h (class Symbol_table): Declare report_resolve_problem.
1768
1769 2009-11-03  Doug Kwan  <dougkwan@google.com>
1770
1771         * arm.cc (Target_arm::Target_arm): Initialize stub_tables_ and
1772         stub_factory_.
1773         (Target_arm::stub_factory): New method definition.
1774         (Target_arm::new_arm_input_section,
1775         Target_arm::find_arm_input_section, Target_arm::new_stub_table,
1776         Target_arm::reloc_uses_thumb_bit): New method declarations.
1777         (Target_arm::Stub_table_list, Target_arm::Arm_input_section_map): 
1778         New type definitions.
1779         (Target_arm::stub_tables_, Target_arm::stub_factory_): New data
1780         member declarations.
1781         (Target_arm::reloc_uses_thumb_bit, Target_arm::new_arm_input_section,
1782         Target_arm::find_arm_input_section, Target_arm::new_stub_table):
1783         New method definitions.
1784
1785 2009-11-03  Ian Lance Taylor  <iant@google.com>
1786
1787         * options.h (class General_options): Add --warn_constructors.
1788
1789 2009-11-03  Ian Lance Taylor  <iant@google.com>
1790
1791         PR 10893
1792         * defstd.cc (in_section): Add entries for __rel_iplt_start,
1793         __rel_iplt_end, __rela_iplt_start, __rela_iplt_end, and __stack.
1794
1795 2009-11-03  Ian Lance Taylor  <iant@google.com>
1796
1797         PR 10895
1798         * po/Make-in ($(srcdir)/$(PACKAGE).pot): Pass -C and
1799         --msgid-bugs-address.
1800         (install-pdf): New target.
1801         (install-data_yes): Look up one directory to find mkinstalldirs.
1802
1803 2009-11-03  H.J. Lu  <hongjiu.lu@intel.com>
1804
1805         * po/Make-in (.po.gmo): Don't generate .gmo files in source
1806         tree.
1807
1808 2009-10-30  Doug Kwan  <dougkwan@google.com>
1809
1810         * arm.cc (Stub_addend_reader): Fix bug in previouls check-in.
1811
1812 2009-10-30  Doug Kwan  <dougkwan@google.com>
1813
1814         * arm.cc (Stub_addend_reader): New struct template definition
1815         and partial specializations.
1816         (Stub_addend_reader::operator()): New method definition for a
1817         partially specialized template.
1818
1819 2009-10-30  Doug Kwan  <dougkwan@google.com>
1820
1821         * arm.cc (Arm_relobj::processor_specific_flags): New method
1822         definition.
1823         (Arm_relobj::do_read_symbols): New method declaration.
1824         (Arm_relobj::processor_specific_flags_): New data member declaration.
1825         (Arm_dynobj): New class definition.
1826         (Target_arm::do_finalize_sections): Add input_objects parameter.
1827         (Target_arm::do_adjust_elf_header): New method declaration.
1828         (Target_arm::are_eabi_versions_compatible,
1829         (Target_arm::merge_processor_specific_flags): New method declaration.
1830         (Target_arm::do_make_elf_object): New overloaded method definitions
1831         and declaration.
1832         (Arm_relobj::do_read_symbols): New method definition.
1833         (Arm_dynobj::do_read_symbols): Ditto.
1834         (Target_arm::do_finalize_sections): Add input_objects parameters.
1835         Merge processor-specific flags from all input objects.
1836         (Target_arm::are_eabi_versions_compatible,
1837         Target_arm::merge_processor_specific_flags,
1838         Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object):
1839         New method definitions.
1840         * i386.cc (Target_i386::do_finalize_sections): Add unnamed
1841         Input_objects pointer type parameter.
1842         * layout.cc (Layout::finalize): Pass input objects to target's.
1843         finalize_sections function.
1844         * output.cc (Output_file_header::do_sized_write): Set ELF file
1845         header's processor-specific flags.
1846         * powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed
1847         Input_objects pointer type parameter.
1848         * sparc.cc (Target_sparc::do_finalize_sections): Same.
1849         * target.h (Input_objects): New forward class declaration.
1850         (Target::processor_specific_flags,
1851         Target::are_processor_specific_flags_sect): New method definitions.
1852         (Target::finalize_sections): Add input_objects parameter.
1853         (Target::Target): Initialize processor_specific_flags_ and
1854         are_processor_specific_flags_set_.
1855         (Target::do_finalize_sections): Add unnamed Input_objects pointer type
1856         parameter.
1857         (Target::set_processor_specific_flags): New method definition.
1858         (Target::processor_specific_flags_,
1859         Target::are_processor_specific_flags_set_): New data member
1860         declarations.
1861         * x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed
1862         Input_objects pointer type parameter.
1863
1864 2009-10-30  Doug Kwan  <dougkwan@google.com>
1865
1866         * arm.cc: Use Arm_address instead of elfcpp::Elf_types<32>::Elf_Addr.
1867
1868 2009-10-28  Ian Lance Taylor  <iant@google.com>
1869
1870         * object.h (class Relobj): Drop options parameter from
1871         gc_process_relocs, scan_relocs, relocate, do_gc_process_relocs,
1872         do_scan_relocs, do_relocate.  Change all callers.
1873         (class Sized_relobj): Drop options parameters from
1874         do_gc_process_relocs, do_scan_relocs, do_relocate,
1875         do_relocate_sections, relocate_sections, emit_relocs_scan,
1876         emit_relocs_scan_reltype.  Change all callers.
1877         (struct Relocate_info): Remove options field and all references to
1878         it.
1879         * reloc.h (class Read_relocs): Remove options constructor
1880         parameter and options_ field.  Change all callers.
1881         (class Gc_process_relocs, class Scan_relocs): Likewise.
1882         (class Relocate_task): Likewise.
1883         * target-reloc.h (scan_relocs): Remove options parameter.  Change
1884         all callers.
1885         (scan_relocatable_relocs): Likewise.
1886         * target.h (class Sized_target): Remove options parameter from
1887         gc_process_relocs, scan_relocs, scan_relocatable_relocs.  Change
1888         all callers.
1889         * gc.h (gc_process_relocs): Remove options parameter.  Change all
1890         callers.
1891         * arm.cc: Update functions to remove options parameters.
1892         * i386.cc: Likewise.
1893         * powerpc.cc: Likewise.
1894         * sparc.cc: Likewise.
1895         * x86_64.cc: Likewise.
1896         * testsuite/testfile.cc: Likewise.
1897
1898 2009-10-28  Doug Kwan  <dougkwan@google.com>
1899
1900         * arm.cc (Arm_relobj): New class definition.
1901         (Arm_relobj::scan_sections_for_stubs, 
1902         Arm_relobj::do_count_local_symbols, Arm_relobj::do_relocate_sections):
1903         New method definitions.
1904
1905 2009-10-28  Cary Coutant  <ccoutant@google.com>
1906
1907         * plugin.h (Plugin::Plugin): Initialize cleanup_done_.
1908         (Plugin::cleanup_done_): New member.
1909         (Plugin_manager::Plugin_manager): Remove cleanup_done_.
1910         (Plugin_manager::cleanup_done_): Remove.
1911         (Plugin_manager::add_input_file): Edit error message.
1912         * plugin.cc (Plugin::cleanup): Test and set cleanup_done_.
1913         (Plugin_manager::cleanup): Remove use of cleanup_done_.
1914
1915 2009-10-27  Mikolaj Zalewski  <mikolajz@google.com>
1916
1917         * fileread.cc: (File_read::View::~View): Use the new
1918         data_ownership_ filed.
1919         (File_read::~File_read): Dispose the new whole_file_view_.
1920         (File_read::open): Mmap the whole file if needed.
1921         (File_read::open): Use whole_file_view_ instead of contents_.
1922         (File_read::find_view): Use whole_file_view_ if applicable.
1923         (File_read::do_read): Use whole_file_view_ instead of contents_.
1924         (File_read::make_view): Use whole_file_view_ instead of contents_,
1925         update File_read::View::View call.
1926         (File_read::find_or_make_view): Update File_read::View::View
1927         call.
1928         * fileread.h: (File_read::File_read): Initialize whole_file_view_,
1929         remove contents_
1930         (File_read::View::Data_ownership): New enum.
1931         (File_read::View::View): Replace bool mapped_ with Data_ownership
1932         argument.
1933         (File_read::View::mapped_): Remove (replaced by data_ownership_).
1934         (File_read::View::data_ownership_): New field.
1935         (File_read::contents_): Remove (replaced by whole_file_view_).
1936         (File_read::whole_file_view_): New field.
1937         * options.h (class General_options): Add --keep-files-mapped.
1938
1939 2009-10-27  Cary Coutant  <ccoutant@google.com>
1940
1941         * symtab.cc (add_from_pluginobj): Pass correct value for is_ordinary.
1942         * testsuite/Makefile.am (plugin_test_5): New test case.
1943         * testsuite/Makefile.in: Regenerate.
1944
1945 2009-10-25  Doug Kwan  <dougkwan@google.com>
1946
1947         * object.h (Sized_relobj::View_size, Sized_relobj::Views): Change
1948         from private to protected to allow access by child class.
1949         (Sized_relobj::do_relocate_sections): New method declaration.
1950         (Sized_relobj::relocate_sections): Virtualize.
1951         * reloc.cc (Sized_relobj::do_relocate_sections): Rename from 
1952         Sized_relobj::relocate_sections.  Instantiate template explicitly
1953         for different target sizes and endianity.
1954
1955 2009-10-24  Doug Kwan  <dougkwan@google.com>
1956
1957         * arm.cc (Arm_output_section, Arm_relobj): Forward class declarations.
1958         (Arm_input_section::as_arm_input_section): New method.
1959         (Arm_output_section): New class definition.
1960         (Arm_output_section::create_stub_group,
1961         Arm_output_section::group_sections): New method definitions.
1962
1963 2009-10-22  Doug Kwan  <dougkwan@google.com>
1964
1965         * arm.cc (Arm_input_section): New class definition.
1966         (Arm_input_section::init, Arm_input_section:do_write,
1967         Arm_input_section::set_final_data_size,
1968         Arm_input_section::do_reset_address_and_file_offset): New method
1969         definitions.
1970
1971 2009-10-21  Doug Kwan  <dougkwan@google.com>
1972
1973         * arm.cc (Stub_table, Arm_input_section): New forward class
1974         declarations.
1975         (Stub_table): New class defintion.
1976         (Stub_table::add_reloc_stub, Stub_table::relocate_stubs
1977         Stub_table::do_reset_address_and_file_offset, Stub_table::do_write):
1978         New method definition.
1979
1980 2009-10-21  Doug Kwan  <dougkwan@google.com>
1981
1982         * arm.cc: Update copyright comments.
1983         (Target_arm): New forward class template declaration.
1984         (Arm_address): New type.
1985         (ARM_MAX_FWD_BRANCH_OFFSET, ARM_MAX_BWD_BRANCH_OFFSET,
1986         THM_MAX_FWD_BRANCH_OFFSET, THM_MAX_BWD_BRANCH_OFFSET,
1987         THM2_MAX_FWD_BRANCH_OFFSET, THM2_MAX_BWD_BRANCH_OFFSET): New
1988         constants.
1989         (Insn_template): Same.
1990         (DEF_STUBS): New macro.
1991         (Stub_type): New enum type.
1992         (Stub_template): New class definition.
1993         (Stub): Same.
1994         (Reloc_stub): Same.
1995         (Stub_factory): Same.
1996         (Target_arm::Target_arm): Initialize may_use_blx_ and
1997         should_force_pic_veneer_.
1998         (Target_arm::may_use_blx, Target_arm::set_may_use_blx,
1999         Target_arm::should_force_pic_veneer,
2000         Target_arm::set_should_force_pic_veneer, Target_arm::using_thumb2,
2001         Target_arm::using_thumb_only, Target_arm:;default_target): New
2002         method defintions.
2003         (Target_arm::may_use_blx_, Target_arm::should_force_pic_veneer_):
2004         New data member declarations.
2005         (Insn_template::size, Insn_template::alignment): New method defintions.
2006         (Stub_template::Stub_template): New method definition.
2007         (Reloc_stub::Key::name, Reloc_stub::stub_type_for_reloc,
2008         Reloc_stub::do_fixed_endian_write, Reloc_stub::do_write): Same.
2009         (Stub_factory::Stub_factory): New method definition.
2010         * gold.h (string_hash): New template.
2011         * output.h (Input_section_specifier::hash_value): Use
2012         gold::string_hash.
2013         (Input_section_specifier::string_hash): Remove.
2014         * stringpool.cc (Stringpool_template::string_hash): Use
2015         gold::string_hash.
2016
2017 2009-10-20  Doug Kwan  <dougkwan@google.com>
2018
2019         * object.cc (Sized_relobj::do_finalize_local_symbols): Handle section
2020         symbols of relaxed input sections.
2021         * output.h (Output_section::find_relaxed_input_section): Make
2022         method public.
2023
2024 2009-10-16  Doug Kwan  <dougkwan@google.com>
2025
2026         * dynobj.cc (Versions::Versions): Initialize version_script_.
2027         Only insert base version symbol definition for a shared object
2028         if version script defines any version versions.
2029         (Versions::define_base_version): New method definition.
2030         (Versions::add_def): Check that base version is not needed.
2031         (Versions::add_need): Define base version lazily.
2032         * dynobj.h (Versions::define_base_version): New method declaration.
2033         (Versions::needs_base_version_): New data member declaration.
2034         * testsuite/Makefile.am (check_SCRIPTS): Add no_version_test.sh
2035         (check_DATA): Add no_version_test.stdout.
2036         (libno_version_test.so, no_version_test.o no_version_test.stdout):
2037         New make rules.
2038         * testsuite/Makefile.in: Regenerate.
2039         * testsuite/no_version_test.c: New file.
2040         * testsuite/no_version_test.sh: Ditto.
2041
2042 2009-10-16  Doug Kwan  <dougkwan@google.com>
2043
2044         * expression.cc (class Segment_start_expression): New class definition.
2045         (Segment_start_expression::value): New method definition.
2046         (script_exp_function_segment_start): Return a new
2047         Segment_start_expression.
2048         * gold/script-c.h (script_saw_segment_start_expression): New function
2049         prototype.
2050         * script-sections.cc (Script_sections::Script_sections): Initialize
2051         SAW_SEGMENT_START_EXPRESSION_ to false.
2052         (Script_sections::set_section_addresses): Use -Ttext, -Tdata
2053         and -Tbbs options to specify section addresses if given in
2054         command line and no SEGMENT_START expression is seen in a script.
2055         * script-sections.h (Script_sections::saw_segment_start_expression,
2056         Script_sections::set_saw_segment_start_expression): New method
2057         definition.
2058         (Script_sections::saw_segment_start_expression_): New data member
2059         declaration.
2060         * script.cc (script_saw_segment_start_expression): New function.
2061         * yyscript.y (SEGMENT_START): Call script_saw_segment_start_expression.
2062         * testsuite/Makefile.am (check_SCRIPTS): Add script_test_6.sh,
2063         script_test_7.sh and script_test_8.sh.
2064         (check_DATA): Add script_test_6.stdout, script_test_7.stdout and
2065         script_test_8.stdout.
2066         (MOSTLYCLEANFILES): Add script_test_6, script_test_7 and script_test_8.
2067         (script_test_6, script_test_6.stdout, script_test_7,
2068         script_test_7.stdout, script_test_8, script_test_8.stdout): New rules.
2069         * Makefile.in: Regenerate.
2070         * testsuite/script_test_6.sh: New file.
2071         * testsuite/script_test_6.t: Same.
2072         * testsuite/script_test_7.sh: Same.
2073         * testsuite/script_test_7.t: Same.
2074         * testsuite/script_test_8.sh: Same.
2075
2076 2009-10-16  Doug Kwan  <dougkwan@google.com>
2077
2078         * output.cc (Output_segment::set_section_list_address): Cast
2079         expressions to unsigned long long type to avoid format warnings.
2080
2081 2009-10-15  Ian Lance Taylor  <iant@google.com>
2082
2083         * script.cc (Script_options::add_symbol_assignment): Always add a
2084         dot assignment to script_sections_.
2085         * script-sections.cc (Script_sections::add_dot_assignment):
2086         Initialize if necessary.
2087
2088         * layout.cc (Layout::relaxation_loop_body): Don't crash if we see
2089         program headers with no load segment if there is a linker script.
2090
2091         * layout.cc (Layout::set_segment_offsets): Align the file offset
2092         to the segment aligment for -N or -n with no load segment.
2093         * output.cc (Output_segment::add_output_section): Don't crash if
2094         the first section is a TLS section.
2095         (Output_segment::set_section_list_addresses): Print an error
2096         message if the address moves backward in a linker script.
2097         * script-sections.cc
2098         (Output_section_element_input::set_section_addresses): Don't
2099         increase *dot_value for a SHF_TLS/SHT_NOBITS section.
2100         (Orphan_output_section::set_section_addresses): Likewise.
2101
2102 2009-10-15  Doug Kwan  <dougkwan@google.com>
2103
2104         * layout.cc (Layout::finish_dynamic_section): Generate tags
2105         DT_FINI_ARRAY, DT_FINI_ARRAYSZ, DT_INIT_ARRAY, DT_INIT_ARRAYSZ,
2106         DT_PREINIT_ARRAY, DT_PREINIT_ARRAYSZ as needed. If -Bsymbolic is
2107         used, add DT_SYMBOLIC and set DF_SYMBOLIC in DT_FLAGS.
2108
2109 2009-10-14  Ian Lance Taylor  <iant@google.com>
2110
2111         * object.h (class Relocate_info): Add reloc_shdr and data_shdr
2112         fields.
2113         * object.cc (Sized_relobj::relocate_sections): Set reloc_shdr and
2114         data_shdr fields of relinfo.
2115         * i386.cc (class Target_i386::Relocate): Remove ldo_addrs_ field.
2116         (Target_i386::Relocate::relocate_tls): Don't call fix_up_ldo.  For
2117         R_386_TLS_LDO_32, adjust based on section flags.
2118         (Target_i386::Relocate::fix_up_ldo): Remove.
2119
2120 2009-10-13  Ian Lance Taylor  <iant@google.com>
2121
2122         Add support for -pie.
2123         * options.h (class General_options): Add -pie and
2124         --pic-executable.
2125         (General_options::output_is_position_independent): Test -pie.
2126         (General_options::output_is_executable): Return true if not shared
2127         and not relocatable.
2128         (General_options::output_is_pie): Remove.
2129         * options.cc (General_options::finalize): Reject incompatible uses
2130         of -pie.
2131         * gold.cc (queue_middle_tasks): A -pie link is not static.
2132         * symtab.h (Symbol::needs_plt_entry): Return false if -pie.
2133         * symtab.cc (Symbol::final_value_is_known): Return false if
2134         output_is_position_independent.
2135         * layout.cc (Layout::set_segment_offsets): Start at address 0 if
2136         output_is_position_independent.
2137         * output.cc (Output_file_header::do_sized_write): Use ET_DYN if
2138         output_is_position_independent.
2139         * i386.cc (Output_data_plt_i386::do_write): Use the PIC PLT if
2140         output_is_position_independent.
2141         * testsuite/Makefile.am (check_PROGRAMS): Add basic_pie_test and
2142         two_file_pie_test.
2143         (basic_pie_test.o, basic_pie_test): New targets.
2144         (two_file_test_1_pie.o, two_file_test_1b_pie.o): New targets.
2145         (two_file_test_2_pie.o, two_file_test_main_pie.o): New targets.
2146         (two_file_pie_test): New target.
2147         * testsuite/Makefile.in: Rebuild.
2148         * README: Remove note saying that -pie is not supported.
2149
2150 2009-10-13  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
2151
2152         * options.h (class General_options): Add -init and -fini.
2153         * layout.cc (Layout::finish_dynamic_section): Emit
2154         given init and fini functions.
2155
2156 2009-10-13  Sriraman Tallam  <tmsriram@google.com>
2157
2158         * gc.h (gc_process_relocs): Check if icf is enabled using new
2159         function.
2160         * gold.cc (queue_initial_tasks): Likewise.
2161         (queue_middle_tasks): Likewise.
2162         * object.cc (do_layout): Likewise.
2163         * symtab.cc (is_section_folded): Likewise.
2164         * main.cc (main): Likewise.
2165         * reloc.cc (Read_relocs::run): Likewise.
2166         (Sized_relobj::do_scan_relocs): Likewise.
2167         * icf.cc (is_function_ctor_or_dtor): New function.
2168         (Icf::find_identical_sections): Check if function is ctor or dtor when
2169         safe icf is chosen.
2170         * options.h (General_options::icf): Change option to be an enum.
2171         (Icf_status): New enum.
2172         (icf_enabled): New method.
2173         (icf_safe_folding): New method.
2174         (set_icf_status): New method.
2175         (icf_status_): New variable.
2176         * (options.cc) (General_options::finalize): Set icf_status_.
2177         * testsuite/Makefile.am: Add commands to build icf_safe_test. Modify
2178         icf_test and icf_keep_unique_test to use the --icf enum flag.
2179         * testsuite/icf_safe_test.sh: New file.
2180         * testsuite/icf_safe_test.cc: New file. 
2181
2182 2009-10-12  Sriraman Tallam  <tmsriram@google.com>
2183
2184         * symtab.h: Check for GOLD_SYMTAB_H before header includes. Remove
2185         includes to gc.h and icf.h.
2186         * arm.cc: Include gc.h.
2187         * gold.cc: Likewise.
2188         * i386.cc: Likewise.
2189         * powerpc.cc: Likewise.
2190         * sparc.cc: Likewise.
2191         * x86_64.cc: Likewise.
2192         * gc.h: Include icf.h.
2193
2194 2009-10-11  Ian Lance Taylor  <iant@google.com>
2195
2196         * plugin.cc: Include "gold.h" before other header files.
2197
2198 2009-10-10  Chris Demetriou  <cgd@google.com>
2199
2200         * options.h (Input_file_argument::Input_file_type): New enum.
2201         (Input_file_argument::is_lib_): Replace with...
2202         (Input_file_argument::type_): New member.
2203         (Input_file_argument::Input_file_argument): Take Input_file_type
2204         'type' rather than boolean 'is_lib' as second argument.
2205         (Input_file_argument::is_lib): Use type_.
2206         (Input_file_argument::is_searched_file): New function.
2207         (Input_file_argument::may_need_search): Handle is_searched_file.
2208         * options.cc (General_options::parse_library): Support -l:filename.
2209         (General_options::parse_just_symbols): Update for Input_file_argument
2210         changes.
2211         (Command_line::process): Likewise.
2212         * archive.cc (Archive::get_file_and_offset): Likewise.
2213         * plugin.cc (Plugin_manager::release_input_file): Likewise.
2214         * script.cc (read_script_file, script_add_file): Likewise.
2215         * fileread.cc (Input_file::Input_file): Likewise.
2216         (Input_file::will_search_for): Handle is_searched_file.
2217         (Input_file::open): Likewise.
2218         * readsyms.cc (Read_symbols::get_name): Likewise.
2219         * testsuite/Makefile.am (searched_file_test): New test.
2220         * testsuite/Makefile.in: Regenerate.
2221         * testsuite/searched_file_test.cc: New file.
2222         * testsuite/searched_file_test_lib.cc: New file.
2223
2224 2009-10-09  Andrew Pinski  <andrew_pinski@playstation.sony.com>
2225             Ian Lance Taylor  <iant@google.com>
2226
2227         * descriptor.cc: Include <cstdio> and "binary-io.h".
2228         (Descriptors::open): Open the files in binary mode always.
2229         * script.cc (Lex::get_token): Treat \r as whitespace.
2230
2231 2009-10-09  Ian Lance Taylor  <iant@google.com>
2232
2233         * testsuite/retain_symbols_file_test.sh: Don't test for __tcf_0.
2234
2235 2009-10-09  Andrew Pinski  <andrew_pinski@playstation.sony.com>
2236             Ian Lance Taylor  <iant@google.com>
2237
2238         * configure.ac: Check for readv function also.
2239         * fileread.cc (readv): Define if not HAVE_READV.
2240         * fileread.h (File_read:: max_readv_entries): Set to 1 if readv
2241         does not exist.
2242         * config.in: Regenerate.
2243         * configure: Regenerate.
2244
2245 2009-10-09  Doug Kwan  <dougkwan@google.com>
2246
2247         * layout.cc (Layout::make_output_section): Call target hook to make
2248         ordinary output section.
2249         (Layout::finalize): Adjust parameter list of call the
2250         Target::may_relax().
2251         * layout.h (class Layout::section_list): New method.
2252         * merge.h (Output_merge_base::entsize): Change visibility to public.
2253         (Output_merge_base::is_string, Output_merge_base::do_is_string):
2254         New methods.
2255         (Output_merge_string::do_is_string): New method.
2256         * object.cc (Sized_relobj::do_setup): renamed from
2257         Sized_relobj::set_up.
2258         * object.h (Sized_relobj::adjust_shndx,
2259         Sized_relobj::initializ_input_to_output_maps,
2260         Sized_relobj::free_input_to_output_maps): Change visibilities to
2261         protected.
2262         (Sized_relobj::setup): Virtualize.
2263         (Sized_relobj::do_setup): New method declaration.
2264         (Sized_relobj::invalidate_section_offset,
2265         Sized_relobj::do_invalidate_section_offset): New method decfinitions.
2266         (Sized_relobj::elf_file, Sized_relobj::local_values): New methods.
2267         * options.cc (parse_int): New function.
2268         * options.h (parse_int): New declaration.
2269         (DEFINE_int): New macro.
2270         (stub_group_size): New option.
2271         * output.cc (Output_section::Output_section): Initialize memebers
2272         merge_section_map_, merge_section_by_properties_map_,
2273         relaxed_input_section_map_, is_relaxed_input_section_map_valid_.
2274         (Output_section::add_input_section): Handled deferred code-fill
2275         generation and remove an old comment.
2276         (Output_section::add_relaxed_input_section): New method definition.
2277         (Output_section::add_merge_input_section): Use merge section by
2278         properties map to speed to search.  Update merge section maps
2279         as appropriate.
2280         (Output_section::build_relaxation_map): New method definition.
2281         (Output_section::convert_input_sections_in_list_to_relaxed_sections):
2282         Same.
2283         (Output_section::relax_input_section): Renamed to
2284         Output_section::convert_input_sections_to_relaxed_sections and change
2285         interface to take a vector of pointers to relaxed sections.
2286         (Output_section::find_merge_section,
2287         Output_section::find_relaxed_input_section): New method definitions.
2288         (Output_section::is_input_address_mapped,
2289         Output_section::output_offset, Output_section::output_address):
2290         Use output section data maps to speed up searching.
2291         (Output_section::find_starting_output_address): Add comments.
2292         (Output_section::do_write,
2293         Output_section::write_to_postprocessing_buffer): Do code-fill
2294         generation as appropriate.
2295         (Output_section::get_input_sections): Invalidate relaxed input section
2296         map.
2297         (Output_section::restore_states): Adjust type of checkpoint .
2298         Invalidate relaxed input section map.
2299         * output.h (Output_merge_base): New class declaration.
2300         (Input_section_specifier): New class defintion.
2301         (class Output_relaxed_input_section) Change base class to
2302         Output_section_data_build.
2303         (Output_relaxed_input_section::Output_relaxed_input_section): Adjust
2304         base class initializer.
2305         (Output_section::add_relaxed_input_section): New method declaration.
2306         (Output_section::Input_section): Change visibility to protected.
2307         (Output_section::Input_section::relobj,
2308         Output_section::Input_section::shndx): Handle relaxed input sections.
2309         Output_section::input_sections) Change visibility to protected.  Also
2310         define overload to return a non-const pointer.
2311         (Output_section::Merge_section_properties): New class defintion.
2312         (Output_section::Merge_section_by_properties_map,
2313         Output_section::Output_section_data_by_input_section_map,
2314         Output_section::Relaxation_map): New types.
2315         (Output_section::relax_input_section): Rename method to
2316         Output_section::convert_input_sections_to_relaxed_sections and change
2317         interface to take a vector of relaxed section pointers.
2318         (Output_section::find_merge_section,
2319         Output_section::find_relaxed_input_section,
2320         Output_section::build_relaxation_map,
2321         Output_section::convert_input_sections_in_list_to_relaxed_sections):
2322         New method declarations.
2323         (Output_section::merge_section_map_
2324         Output_section::merge_section_by_properties_map_,
2325         Output_section::relaxed_input_section_map_,
2326         Output_section::is_relaxed_input_section_map_valid_,
2327         Output_section::generate_code_fills_at_write_): New data members.
2328         * script-sections.cc
2329         (Output_section_element_input::set_section_addresses): Call
2330         current_data_size and addralign methods of relaxed input sections.
2331         (Orphan_output_section::set_section_addresses): Call current_data_size
2332         and addralign methods of relaxed input sections.
2333         * symtab.cc (Symbol_table::compute_final_value): Extract template
2334         from the body of Symbol_table::sized_finalize_symbol.
2335         (Symbol_table::sized_finalized_symbol): Call
2336         Symbol_table::compute_final_value.
2337         * symtab.h (Symbol_table::Compute_final_value_status): New enum type.
2338         (Symbol_table::compute_final_value): New templated method declaration.
2339         * target.cc (Target::do_make_output_section): New method defintion.
2340         * target.h (Target::make_output_section): New method declaration.
2341         (Target::relax): Add more parameters for input objects, symbol table
2342         and layout.  Adjust call to do_relax.
2343         (Target::do_make_output_section): New method declaration.
2344         (Target::do_relax): Add parameters for input objects, symbol table
2345         and layout.
2346
2347 2009-10-09  Andrew Pinski  <andrew_pinski@playstation.sony.com>
2348
2349         * pread.c: Include stdio.h.
2350
2351 2009-10-09  Andrew Pinski  <andrew_pinski@playstation.sony.com>
2352
2353         * plugin.cc: Don't include dlfcn.h when ENABLE_PLUGINS is not
2354         defined.
2355
2356 2009-10-09  Andrew Pinski  <andrew_pinski@playstation.sony.com>
2357
2358         * dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info):
2359         Change read_shndx type to unsigned int.
2360         (Sized_dwarf_line_info::read_lines): Change shndx type to unsigned
2361         int.
2362         (Sized_dwarf_line_info::read_line_mappings): Likewise.
2363         * dwarf_reader.h (Sized_dwarf_line_info::Sized_dwarf_line_info):
2364         Change read_shndx type to unsigned int.
2365         (Sized_dwarf_line_info::read_lines): Change shndx type to unsigned
2366         int.
2367         (Sized_dwarf_line_info::read_line_mappings): Likewise.
2368         * layout.cc (Layout::create_symtab_sections): Cast the result of
2369         local_symcount * symsize to off_t in the gold_assert.
2370
2371 2009-10-09  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
2372
2373         * arm.cc (Target_arm::relocate::reloc_is_non_pic): Return true for
2374         R_ARM_THM_ABS5, R_ARM_ABS8, R_ARM_ABS12, R_ARM_ABS16,
2375         R_ARM_BASE_ABS.
2376         (Arm_relocate_functions::abs8): Remove has_thumb_bit parameter.
2377         (Arm_relocate_functions::thm_abs5): New function.
2378         (Arm_relocate_functions::abs12): New function.
2379         (Arm_relocate_functions::abs16): New function.
2380         (Arm_relocate_functions::base_abs): New function.
2381         (Scan::check_non_pic): Handle R_ARM_ABS32_NOI.
2382         (Scan::local): Remove special handling of R_ARM_ABS8.  Handle
2383         R_ARM_ABS32_NOI, R_ARM_THM_ABS5, R_ARM_ABS12, R_ARM_ABS16, and
2384         R_ARM_BASE_ABS.
2385         (Scan::global): Likewise.
2386         (Relocate::relocate): Handle R_ARM_ABS12, R_ARM_ABS16,
2387         R_ARM_ABS32_NOI, R_ARM_THM_ABS5, and R_ARM_BASE_ABS.
2388         (Relocatable_size_for_reloc::get_size_for_reloc): Handle
2389         R_ARM_ABS16, R_ARM_THM_ABS5, R_ARM_ABS32_NOI, R_ARM_ABS12, and
2390         R_ARM_BASE_ABS.
2391
2392 2009-10-09  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
2393
2394         * arm.cc (Arm_relocate_functions::movw_prel_nc): New function.
2395         (Arm_relocate_functions::movt_prel): New function.
2396         (Arm_relocate_functions::thm_movw_prel_nc): New function.
2397         (Arm_relocate_functions::thm_movt_prel): New function.
2398         (Scan::local): Handle R_ARM_MOVW_PREL_NC, R_ARM_MOVT_PREL,
2399         R_ARM_THM_MOVW_PREL_NC, and R_ARM_THM_MOVT_PREL.
2400         (Scan::global, Relocate::relocate): Likewise.
2401         (Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
2402
2403 2009-10-09  Mikolaj Zalewski  <mikolajz@google.com>
2404
2405         * gold.cc: (queue_initial_tasks): Pass incremental_inputs to
2406         Incremental_checker.
2407         * incremental.cc: (INCREMENTAL_LINK_VERSION): Change type to
2408         unsigned int.
2409         (class Incremental_inputs_header): New class.
2410         (Incremental_inputs_header_writer): Edit comment.
2411         (Incremental_inputs_entry): New class.
2412         (Incremental_inputs_entry_writer): Edit comment.
2413         (Sized_incremental_binary::do_find_incremental_inputs_section):
2414         Add *strtab_shndx parameter, fill it.
2415         (Sized_incremental_binary::do_check_inputs): New method.
2416         (Incremental_checker::can_incrementally_link_output_file): Use
2417         Sized_incremental_binary::check_inputs.
2418         (Incremental_inputs::report_command_line): Save command line in
2419         command_line_.
2420         * incremental.h:
2421         (Incremental_binary::find_incremental_inputs_section): New
2422         method.
2423         (Incremental_binary::do_find_incremental_inputs_section): Add
2424         strtab_shndx parameter.
2425         (Incremental_binary::do_check_inputs): New pure virtual method.
2426         (Sized_incremental_binary::do_check_inputs): Declare.
2427         (Incremental_checker::Incremental_checker): Add incremental_inputs
2428         parameter, use it to initialize incremental_inputs_.
2429         (Incremental_checker::incremental_inputs_): New field.
2430         (Incremental_checker::command_line): New method.
2431         (Incremental_checker::inputs): New method.
2432         (Incremental_checker::command_line_): New field.
2433
2434 2009-10-09  Mikolaj Zalewski  <mikolajz@google.com>
2435
2436         * incremental.cc: Include <cstdarg> and "target-select.h".
2437         (vexplain_no_incremental): New function.
2438         (explain_no_incremental): New function.
2439         (Incremental_binary::error): New method.
2440         (Sized_incremental_binary::do_find_incremental_inputs_section): New
2441         method.
2442         (make_sized_incremental_binary): New function.
2443         (open_incremental_binary): New function.
2444         (can_incrementally_link_file): Add checks if output is ELF and has
2445         inputs section.
2446         * incremental.h: Include "elfcpp_file.h" and "output.h".
2447         (Incremental_binary): New class.
2448         (Sized_incremental_binary): New class.
2449         (open_incremental_binary): Declare.
2450         * object.cc (is_elf_object): Use
2451         elfcpp::Elf_recognizer::is_elf_file.
2452         (make_elf_object): Use elfcpp::Elf_recognizer::is_valid_header.
2453         * output.h (Output_file::filesize): New method.
2454
2455 2009-10-07  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
2456
2457         * arm.cc (Arm_relocate_functions::extract_arm_movw_movt_addend):
2458         New function.
2459         (Arm_relocate_functions::insert_val_arm_movw_movt): New function.
2460         (Arm_relocate_functions::extract_thumb_movw_movt_addend): New
2461         function.
2462         (Arm_relocate_functions::insert_val_thumb_movw_movt): New
2463         function.
2464         (Arm_relocate_functions::movw_abs_nc): New function.
2465         (Arm_relocate_functions::movt_abs): New function.
2466         (Arm_relocate_functions::thm_movw_abs_nc): New function.
2467         (Arm_relocate_functions::thm_movt_abs): New function.
2468         (Scan::local): Handle R_ARM_MOVW_ABS_NC, R_ARM_MOVT_ABS,
2469         R_ARM_THM_MOVW_ABS_NC, R_ARM_THM_MOVT_ABS.
2470         (Scan::global): Likewise.
2471         (Relocate::relocate): Likewise.
2472         (Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
2473
2474 2009-10-07  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
2475
2476         * arm.cc (Arm_relocate_functions::got_prel) New function.
2477         (Scan::local, Scan::global): Handle R_ARM_GOT_PREL.
2478         (Relocate::relocate): Likewise.
2479         (Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
2480
2481 2009-10-06  Ian Lance Taylor  <iant@google.com>
2482
2483         * options.h (class General_options): Define
2484         split_stack_adjust_size parameter.
2485         * object.h (class Object): Add uses_split_stack_ and
2486         has_no_split_stack_ fields.  Add uses_split_stack and
2487         has_no_split_stack accessor functions.  Declare
2488         handle_split_stack_section.
2489         (class Reloc_symbol_changes): Define.
2490         (class Sized_relobj): Define Function_offsets.  Declare
2491         split_stack_adjust, split_stack_adjust_reltype, and
2492         find_functions.
2493         * object.cc (Object::handle_split_stack_section): New function.
2494         (Sized_relobj::do_layout): Call handle_split_stack_section.
2495         * dynobj.cc (Sized_dynobj::do_layout): Call
2496         handle_split_stack_section.
2497         * reloc.cc (Sized_relobj::relocate_sections): Call
2498         split_stack_adjust for executable sections in split_stack
2499         objects.  Pass reloc_map to relocate_section.
2500         (Sized_relobj::split_stack_adjust): New function.
2501         (Sized_relobj::split_stack_adjust_reltype): New function.
2502         (Sized_relobj::find_functions): New function.
2503         * target-reloc.h: Include "object.h".
2504         (relocate_section): Add reloc_symbol_changes parameter.  Change
2505         all callers.
2506         * target.h (class Target): Add calls_non_split method.  Declare
2507         do_calls_non_split virtual method.  Declare match_view and
2508         set_view_to_nop.
2509         * target.cc: Include "elfcpp.h".
2510         (Target::do_calls_non_split): New function.
2511         (Target::match_view): New function.
2512         (Target::set_view_to_nop): New function.
2513         * gold.cc (queue_middle_tasks): Give an error if mixing
2514         split-stack and non-split-stack objects with -r.
2515         * i386.cc (Target_i386::relocate_section): Add
2516         reloc_symbol_changes parameter.
2517         (Target_i386::do_calls_non_split): New function.
2518         * x86_64.cc (Target_x86_64::relocate_section): Add
2519         reloc_symbol_changes parameter.
2520         (Target_x86_64::do_calls_non_split): New function.
2521         * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes
2522         parameter.
2523         * powerpc.cc (Target_powerpc::relocate_section): Add
2524         reloc_symbol_changes parameter.
2525         * sparc.cc (Target_sparc::relocate_section): Add
2526         reloc_symbol_changes parameter.
2527         * configure.ac: Call AM_CONDITIONAL for the default target.
2528         * configure: Rebuild.
2529         * testsuite/Makefile.am (TEST_AS): New variable.
2530         (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh.
2531         (check_DATA): Add split_i386 and split_x86_64 files.
2532         (SPLIT_DEFSYMS): Define.
2533         (split_i386_[1234n].o): New targets.
2534         (split_i386_[124]): New targets.
2535         (split_i386_[1234r].stdout): New targets.
2536         (split_x86_64_[1234n].o): New targets.
2537         (split_x86_64_[124]): New targets.
2538         (split_x86_64_[1234r].stdout): New targets.
2539         (MOSTLYCLEANFILES): Add new executables.
2540         * testsuite/split_i386.sh: New file.
2541         * testsuite/split_x86_64.sh: New file.
2542         * testsuite/split_i386_1.s: New file.
2543         * testsuite/split_i386_2.s: New file.
2544         * testsuite/split_i386_3.s: New file.
2545         * testsuite/split_i386_4.s: New file.
2546         * testsuite/split_i386_n.s: New file.
2547         * testsuite/split_x86_64_1.s: New file.
2548         * testsuite/split_x86_64_2.s: New file.
2549         * testsuite/split_x86_64_3.s: New file.
2550         * testsuite/split_x86_64_4.s: New file.
2551         * testsuite/split_x86_64_n.s: New file.
2552         * testsuite/testfile.cc (Target_test): Update relocation_section
2553         function.
2554         * testsuite/Makefile.in: Rebuild.
2555
2556 2009-10-06  Ian Lance Taylor  <iant@google.com>
2557
2558         * i386.cc (class Target_i386::Relocate): Add ldo_addrs_ field.
2559         (Target_i386::Relocate::relocate_tls): Call fix_up_ldo before
2560         changing local_dynamic_type_ from LOCAL_DYNAMIC_NONE.  When
2561         handling R_386_TLS_LDO_32, if local_dynamic_type_ is NONE, push
2562         the address on ldo_addrs_.
2563         (Target_i386::Relocate::fix_up_ldo): New function.
2564
2565 2009-10-06   Rafael Espindola  <espindola@google.com>
2566
2567         * plugin.cc (add_input_library): New.
2568         (Plugin::load): Add add_input_library to tv.
2569         (Plugin_manager::add_input_file): Add the is_lib argument.
2570         (add_input_file): Update call to Plugin_manager::add_input_file.
2571         (add_input_library): New.
2572         * plugin.h (Plugin_manager::add_input_file): Add the is_lib argument.
2573
2574 2009-09-30  Doug Kwan  <dougkwan@google.com>
2575
2576         * arm.cc (Target_arm::may_need_copy_reloc): Check for THUMB function
2577         symbol and call Symbol::may_need_copy_reloc to determine if
2578         a copy reloc is needed.
2579         * copy-relocs.cc (Copy_relocs::need_copy_reloc): Return false if -z
2580         nocopyreloc is given in command line.
2581         (Copy_relocs::emit_copy_reloc): Assert that -z nocopyreloc is not
2582         given in command line.
2583         * i386.cc (Target_i386::may_need_copy_reloc): Remove.
2584         (Target_i386::Scan::global): Use Symbol::may_need_copy_reloc instead
2585         of the removed Target_i386::may_need_copy_reloc.
2586         * options.h (copyreloc): New option with default value false.
2587         * powerpc.cc (Target_powerpc::may_need_copy_reloc): Remove.
2588         (Target_powerpc::Scan::global): Use Symbol::may_need_copy_reloc
2589         instead of the removed Target_powerpc::may_need_copy_reloc.
2590         * sparc.cc (Target_powerpc::may_need_copy_reloc): Remove.
2591         (Target_sparc::Scan::global): Use Symbol::may_need_copy_reloc
2592         instead of the removed Target_sparc::may_need_copy_reloc.
2593         * symtab.h (Symbol::may_need_copy_reloc): New method definition.
2594         * x86_64.cc (Target_powerpc::may_need_copy_reloc): Remove.
2595         (Target_x86_64::Scan::global): Use Symbol::may_need_copy_reloc
2596         instead of the removed Target_x86_64::may_need_copy_reloc.
2597
2598 2009-09-30  Ian Lance Taylor  <iant@google.com>
2599
2600         * object.h (class Object): Remove target_ field, and target,
2601         sized_target, and set_target methods.
2602         (Object::sized_target): Remove.
2603         (class Sized_relobj): Update declarations.  Remove sized_target.
2604         * object.cc (Sized_relobj::setup): Remove target parameter.
2605         Change all callers.
2606         (Input_objects::add_object): Don't do anything with the target.
2607         (make_elf_sized_object): Add punconfigured parameter.  Change all
2608         callers.  Set or test parameter target.
2609         * dynobj.cc (Sized_dynobj::target): Remove target parameter.
2610         Change all callers.
2611         * parameters.cc (Parameters::set_target): Change parameter type to
2612         be non-const.
2613         (Parameters::default_target): Remove.
2614         (set_parameters_target): Change parameter type to be non-const.
2615         (parameters_force_valid_target): New function.
2616         (parameters_clear_target): New function.
2617         * parameters.h (class Parameters): Update declarations.  Remove
2618         default_target method.  Add sized_target and clear_target
2619         methods.  Change target_ to be non-const.
2620         (set_parameters_target): Update declaration.
2621         (parameters_force_valid_target): Declare.
2622         (parameters_clear_target): Declare.
2623         * readsyms.cc (Read_symbols::do_read_symbols): Pass punconfigured
2624         as NULL if we aren't searching.
2625         (Add_symbols::run): Don't check for compatible target.
2626         * fileread.cc (Input_file::open_binary): Call
2627         parameters_force_valid_target.
2628         * gold.cc (queue_middle_tasks): Likewise.
2629         * plugin.cc (make_sized_plugin_object): Likewise.  Don't call
2630         set_target on object.
2631         * dynobj.h (class Sized_dynobj): Update declarations.
2632         * archive.cc (Archive::get_elf_object_for_member): Return NULL if
2633         make_elf_object returns NULL.
2634         (Archive::include_member): Don't check whether object target is
2635         compatible.
2636         * output.cc (Output_section::add_input_section): Get target from
2637         parameters.
2638         (Output_section::relax_input_section): Likewise.
2639         * reloc.cc (Sized_relobj::do_gc_process_relocs): Get target from
2640         parameters.
2641         (Sized_relobj::do_scan_relocs): Likewise.
2642         (Sized_relobj::relocate_sections): Likewise.
2643         * resolve.cc (Symbol_table::resolve): Likewise.
2644         * symtab.cc (Symbol_table::wrap_symbol): Likewise.  Remove object
2645         parameter.  Change all callers.
2646         (Symbol_table::add_from_object): Get target from parameters.
2647         (Symbol_table::add_from_relobj): Don't check object target.
2648         (Symbol_table::add_from_dynobj): Likewise.
2649         (Symbol_table::define_special_symbol): Get target from
2650         parameters.
2651         * symtab.h (class Symbol_table): Update declaration.
2652         * testsuite/binary_unittest.cc (gold_testsuite): Remove target
2653         parameter.  Change all callers.  Clear parameter target.
2654         (Binary_test): Test target here.
2655         * testsuite/object_unittest.cc (gold_testsuite): Remove
2656         target_test_pointer parameter.  Change all callers.
2657         (Object_test): Test target here.
2658
2659 2009-09-26  Ian Lance Taylor  <iant@google.com>
2660
2661         * testsuite/initpri1.c: Don't try to use constructor priorities if
2662         compiling with gcc before 4.3.
2663
2664 2009-09-22  Mikolaj Zalewski  <mikolajz@google.com>
2665
2666         * testsuite/retain_symbols_file_test.sh (check_present): Change
2667         output file name to retain_symbols_file_test.stdout.
2668         (check_absent): Likewise.
2669
2670 2009-09-18  Craig Silverstein  <csilvers@google.com>
2671
2672         * object.cc (Sized_relobj::do_count): Test should_retain_symbol map.
2673         * options.cc: Include <cerrno> and <fstream>.
2674         (General_options::finalize): Parse -retain-symbols-file tag.
2675         * options.h: New flag.
2676         (General_options): New method should_retain_symbol, new
2677         variable symbols_to_retain.
2678         * symtab.cc (Symbol_table::sized_finalize_symbol): Test
2679         should_retain_symbol map.
2680         * testsuite/Makefile.am (retain_symbols_file_test): New test.
2681         * testsuite/Makefile.in: Regenerate.
2682         * testsuite/retain_symbols_file_test.sh: New file.
2683
2684 2009-09-18  Nick Clifton  <nickc@redhat.com>
2685
2686         * po/es.po: Updated Spanish translation.
2687
2688 2009-09-17  Doug Kwan  <dougkwan@google.com>
2689
2690         * debug.h (DEBUG_RELAXATION): New constant.
2691         (DEBUG_ALL): Add DEBUG_RELAXATION.
2692         (debug_string_to_enum): Add relaxation debug option.
2693         * layout.cc
2694         (Layout::Relaxation_debug_check::check_output_data_for_reset_values,
2695         Layout::Relaxation_debug_check::read_sections,
2696         Layout::Relaxation_debug_check::read_sections): New method definitions.
2697         (Layout::Layout): Initialize data members
2698         record_output_section_data_from_scrips_,
2699         script_output_section_data_list_ and relaxation_debug_check_.
2700         (Layout::save_segments, Layout::restore_segments,
2701         Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
2702         Layout::relaxation_loop_body): New method definitions.
2703         (Layout::finalize): Support relaxation.  Move section layout code to
2704         Layout::relaxation_loop_body.
2705         (Layout::set_asection_address_from_script): Move code for orphan
2706         section placement out.
2707         (Layout::place_orphan_sections_in_script): New method definition.
2708         * layout.h (Output_segment_headers, Output_file_header):
2709         New forward class declarations.
2710         (Layout::~Layout): Define.
2711         (Layout::new_output_section_data_from_script): New method definition.
2712         (Layout::place_orphan_sections_in_script): New method declaration.
2713         (Layout::Segment_states): New type declaration.
2714         (Layout::save_segments, Layout::restore_segments,
2715         Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
2716         Layout::relaxation_loop_body): New method declarations.
2717         (Layout::Output_section_data_list): New type declaration.
2718         (Layout::Relaxation_debug_check): New class definition.
2719         (Layout::record_output_section_data_from_script_,
2720         Layout::script_output_section_data_list_, Layout::segment_states_,
2721         Layout::relaxation_debug_check_): New data members.
2722         * output.cc: (Output_section_headers::do_size): New method definition.
2723         (Output_section_headers::Output_section_headers): Move size
2724         computation to Output_section_headers::do_size.
2725         (Output_segment_headers::do_size): New method definition.
2726         (Output_file_header::Output_file_header): Move size computation to 
2727         Output_file_header::do_size and call it.
2728         (Output_file_header::do_size): New method definition.
2729         (Output_data_group::Output_data_group): Adjust call to
2730         Output_section_data.
2731         (Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
2732         (Output_symtab_xindex::do_write): Add array bound check.
2733         (Output_section::Input_section::print_to_mapfile): Handle
2734         RELAXED_INPUT_SECTION_CODE.
2735         (Output_section::Output_section): Initialize data member checkpoint_.
2736         (Output_section::~Output_section): Delete checkpoint object pointed
2737         by checkpoint_.
2738         (Output_section::add_input_section): Always add an Input_section if
2739         relaxing.
2740         (Output_section::add_merge_input_section): Add assert.
2741         (Output_section::relax_input_section): New method definition.
2742         (Output_section::set_final_data_size): Set load address to zero for
2743         an unallocated section.
2744         (Output_section::do_address_and_file_offset_have_reset_values):
2745         New method definition.
2746         (Output_section::Input_section_sort_enty::Input_section_sort_enty):
2747         Handle relaxed input section.
2748         (Output_section::sort_attached_input_sections): Checkpoint input
2749         section list lazily.
2750         (Output_section::get_input_sections): Change type of input_sections to
2751         list of Simple_input_section pointers.  Checkpoint input section list
2752         lazily.  Also handle relaxed input sections.
2753         (Output_section::add_input_section_for_script): Take a reference to
2754         a Simple_input_section object instead of Relobj pointer and section
2755         index as parameter.  Handle relaxed input sections.
2756         (Output_section::save_states, Output_section::restore_states): New
2757         method definitions.
2758         * output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
2759         (Output_data::is_data_size_fixed): New method definition.
2760         (Output_data::reset_addresss_and_file_offset): Do not reset data size
2761         if it is fixed.
2762         (Output_data::address_and_file_offset_have_reset_values): New method
2763         definition.
2764         (Output_data::do_address_and_file_offset_have_reset_values): New method
2765         definition.
2766         (Output_data::set_data_size): Check that data size is not fixed.
2767         (Output_data::fix_data_size): New method definition.
2768         (Output_data::is_data_size_fixed_): New data member.
2769         (Output_section_headers::set_final_data_size): New method definition.
2770         (Output_section_headers::do_size): New method declaration.
2771         (Output_segment_headers::set_final_data_size): New method definition.
2772         (Output_segment_headers::do_size): New method declaration.
2773         (Output_file_header::set_final_data_size)::New method definition.
2774         (Output_file_header::do_size)::New method declaration.
2775         (Output_section_data::Output_section_data): Add new parameter
2776         is_data_size_fixed and use it to fix data size.
2777         (Output_data_const::Output_data_const): Adjust call to base class
2778         constructor and fix data size.
2779         (Output_data_const_buffer::Output_data_const_buffer): Adjust call to
2780         base class constructor and fix data size.
2781         (Output_data_fixed_space::Output_data_fixed_space): Adjust call to
2782         base class constructor and fix data size.
2783         (Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
2784         class constructor and fix data size.
2785         (Output_data_group::set_final_data_size): New method definition.
2786         (Output_data_dynamic::Dynamic_entry::tag): New method definition.
2787         (Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
2788         class constructor and fix data size.
2789         (Output_relaxed_input_section): New class definition.
2790         (Output_section::Simple_input_section): New class definition.
2791         (Output_section::get_input_sections): Adjust parameter list.
2792         (Output_section::add_input_section_for_script): Same.
2793         (Output_section::save_states, Output_section::restore_states,
2794         Output_section::do_address_and_file_offset_have_reset_values,
2795         (Output_section::Input_section::Input_section): Handle
2796         RELAXED_INPUT_SECTION_CODE.  Add new overload for
2797         Output_relaxed_input_section.
2798         (Output_section::Input_section::is_input_section,
2799         Output_section::Input_section::set_output_section): Handle relaxed
2800         input section.
2801         (Output_section::Input_section::is_relaxed_input_section,
2802         Output_section::Input_section::output_section_data,
2803         Output_section::Input_section::relaxed_input_section): New method
2804         definitions.
2805         (Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
2806         value.
2807         (Output_section::Input_section::u1_): Update comments.
2808         (Output_section::Input_section::u2_): Add new union member poris.
2809         (Output_section::Checkpoint_output_section): New classs definition.
2810         (Output_section::relax_input_section): New method declaration.
2811         (Output_section::checkpoint_): New data member.
2812         (Output_segment): Update comments.
2813         (Output_segment::Output_segment): Un-privatize copy constructor.
2814         (Output_segment::operator=): Un-privatize.
2815         * script-sections.cc (Output_section_element::Input_section_list):
2816         Change element type to Output_section::Simple_input_section.
2817         (Output_section_element_dot_assignment::set_section_addresses):
2818         Register output section data for relaxation clean up.
2819         (Output_data_exression::Output_data_expression): Adjust call to base
2820         constructor to fix data size.
2821         (Output_section_element_data::set_section_addresses): Register
2822         Output_data_expression object for relaxation clean up.
2823         (struct Input_section_info): Replace Relobj pointer and section index
2824         pair with Output_section::Simple_input_section and Convert struct to a
2825         class.
2826         (Input_section_sorter::operator()): Adjust access to
2827         Input_section_info data member to use accessors. 
2828         (Output_section_element_input::set_section_addresses): Use layout
2829         parameter.  Adjust code to use Output_section::Simple_input_section
2830         and Input_secction_info classes.  Register filler for relaxation
2831         clean up.
2832         (Orphan_output_section::set_section_addresses): Replace Relobj pointer
2833         and section index pair with Output_section::Simple_input_section
2834         class.  Adjust code accordingly.
2835         (Phdrs_element::release_segment): New method definition.
2836         (Script_sections::attach_sections_using_phdrs_clause): Do not modify
2837         segment list.
2838         (Script_sections::release_segments): New method definition.
2839         * gold/script-sections.h (Script_sections::release_segments): New
2840         method declaration.
2841         * gold/target.h (Target::may_relax, Target::relax,
2842         Target::do_may_relax, Target::do_relax): New method definitions.
2843
2844 2009-09-17  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
2845
2846         * arm.cc (has_signed_unsigned_overflow): New function.
2847         (Arm_relocate_functions::abs8): New function.
2848         (Target_arm::Scan::local): Handle R_ARM_ABS8.
2849         (Target_arm::Scan::global): Likewise.
2850         (Target_arm::relocate::relocate): Likewise.
2851         (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
2852         Likewise.
2853
2854 2009-09-16  Cary Coutant  <ccoutant@google.com>
2855
2856         * testsuite/Makefile.am (MOSTLYCLEANFILES): Add more generated files.
2857         * testsuite/Makefile.in: Regenerate.
2858
2859 2009-09-11  Nick Clifton  <nickc@redhat.com>
2860
2861         * po/gold.pot: Updated by the Translation project.
2862
2863 2009-09-08  Cary Coutant  <ccoutant@google.com>
2864
2865         * output.cc (Output_file::open): Add execute permission to empty file.
2866         * testsuite/Makefile.am (permission_test): New test.
2867         * testsuite/Makefile.in: Regenerate.
2868
2869 2009-09-02  Ian Lance Taylor  <iant@google.com>
2870
2871         * output.cc (Output_file::resize): Call map_no_anonymous rather
2872         than map.
2873
2874 2009-09-01  Mikolaj Zalewski  <mikolajz@google.com>
2875
2876         * gold.cc: Include "incremental.h".
2877         (queue_initial_tasks): Call Incremental_checker methods.
2878         * incremental.cc: Include "output.h".
2879         (Incremental_checker::can_incrementally_link_output_file): New
2880         method.
2881         * incremental.h (Incremental_checker): New class.
2882
2883         * output.cc (Output_file::open_for_modification): New method.
2884         (Output_file::map_anonymous): Changed return type to bool.  Record
2885         map in base_ field.
2886         (Output_file::map_no_anonymous): New method, broken out of map.
2887         (Output_file::map): Use map_no_anonymous and map_anonymous.
2888         * output.h (class Output_file): Update declarations.
2889
2890 2009-08-24  Cary Coutant  <ccoutant@google.com>
2891
2892         * options.h (Command_line::Pre_options): New class.
2893         (Command_line::pre_options): New member.
2894         * options.cc (gold::options::ready_to_register): New variable.
2895         (One_option::register_option): Do nothing if not registering options.
2896         Assert if same short option registered twice.
2897         (General_options::General_options): Turn off option registration when
2898         done constructing.
2899         (Command_line::Pre_options::Pre_options): New constructor.
2900
2901 2009-08-24  Cary Coutant  <ccoutant@google.com>
2902
2903         * options.h (General_options::no_keep_memory): Remove incorrect
2904         short option.
2905
2906 2009-08-24  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
2907
2908         * Makefile.am (am__skiplex, am__skipyacc): New.
2909         * Makefile.in: Regenerate.
2910
2911 2009-08-22  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
2912
2913         * Makefile.am (AM_CPPFLAGS): Renamed from ...
2914         (INCLUDES): ... this.
2915         * testsuite/Makefile.am (AUTOMAKE_OPTIONS): Add -Wno-portability.
2916         (AM_CPPFLAGS): Renamed from ...
2917         (INCLUDE): ... this.
2918         * Makefile.in, testsuite/Makefile.in: Regenerate.
2919
2920         * Makefile.in: Regenerate.
2921         * aclocal.m4: Likewise.
2922         * config.in: Likewise.
2923         * configure: Likewise.
2924         * testsuite/Makefile.in: Likewise.
2925
2926         * Makefile.am (AUTOMAKE_OPTIONS): Add foreign.
2927         * testsuite/Makefile.am (AUTOMAKE_OPTIONS): Add foreign.
2928         * Makefile.in: Regenerate.
2929         * testsuite/Makefile.in: Regenerate.
2930
2931 2009-08-19  Cary Coutant  <ccoutant@google.com>
2932
2933         * resolve.cc (Symbol_table::resolve): Don't complain about defined
2934         symbols in shared libraries overridden by hidden or internal symbols
2935         in the main program.
2936
2937 2009-08-19  Chris Demetriou  <cgd@google.com>
2938
2939         * testsuite/debug_msg.sh: Match .* rather than ${srcdir} when
2940         checking source file names in error messages.
2941
2942 2009-08-18  Doug Kwan  <dougkwan@google.com>
2943
2944         * dynobj.cc (Sized_dynobj::setup): Take a Target object instead of
2945         an elcpp::Ehdr as parameter.  Adjust call to set_target.
2946         * dynobj.h (Sized_dynobj::setup): Take a Target object instead of
2947         an elfcpp::Ehdr as parameter.
2948         * object.cc (Object::set_target): Remove the version that looks up
2949         a target and sets it.
2950         (Sized_relobj::setup): Take a Target object instead of
2951         an elfcpp::Ehdr as parameter.  Adjust call to set_target.
2952         (make_elf_sized_object): Find target and ask target to
2953         make an ELF object.
2954         * object.h: (Object::set_target): Remove the version that looks up
2955         a target and sets it.
2956         (Sized_relobj::setup): Take a Target object instead of
2957         an elfcpp:Ehdr as parameter.
2958         * target.cc: Include dynobj.h.
2959         (Target::do_make_elf_object_implementation): New.
2960         (Target::do_make_elf_object): New.
2961         * target.h (Target::make_elf_object): New template declaration.
2962         (Target::do_make_elf_object): New method declarations.
2963         (Target::do_make_elf_object_implementation): New template declaration.
2964
2965 2009-08-14  Ian Lance Taylor  <iant@google.com>
2966
2967         * gold.h (FUNCTION_NAME): Define.
2968         (gold_unreachable): Use FUNCTION_NAME.
2969
2970 2009-08-12  Sriraman Tallam  <tmsriram@google.com>
2971
2972         * icf.cc (Icf::find_identical_sections): Issue a warning when a
2973         symbol in the --keep-unique list is not found.
2974
2975 2009-08-12  Sriraman Tallam  <tmsriram@google.com>
2976
2977         * icf.cc (Icf::find_identical_sections): Unfold symbols that have
2978         been maked as --keep-unique.
2979         (Icf::unfold_section): New function.
2980         * icf.h (Icf::unfold_section): New function.
2981         * options.h (General_options::keep_unique): New option.
2982         * testsuite/Makefile.am: Add commands to build icf_keep_unique_test.
2983         * testsuite/Makefile.in: Regenerate.
2984         * testsuite/icf_keep_unique_test.sh: New file.
2985         * testsuite/icf_keep_unique_test.cc: New file.
2986
2987 2009-08-12  Cary Coutant  <ccoutant@google.com>
2988
2989         PR 10471
2990         * resolve.cc (Symbol_table::resolve): Check for references from
2991         dynamic objects to hidden and internal symbols.
2992         * testsuite/Makefile.am (hidden_test.sh): New test.
2993         * testsuite/Makefile.in: Regenerate.
2994         * testsuite/hidden_test.sh: New script.
2995         * testsuite/hidden_test_1.c: New test source.
2996         * testsuite/hidden_test_main.c: New test source.
2997
2998 2009-08-11  Doug Kwan  <dougkwan@google.com>
2999
3000         * arm.cc: Update comments.
3001         (Target_arm::do_finalize_sections): Add a special PT_ARM_EXIDX
3002         segment to locate the .ARM.exidx section if present.
3003
3004 2009-08-09  Doug Kwan  <dougkwan@google.com>
3005
3006         * dynobj.h (Sized_dynobj::do_section_entsize): Revert the previous
3007         patch.
3008
3009 2009-08-07  Sriraman Tallam  <tmsriram@google.com>
3010         * dynobj.h (Sized_dynobj::do_section_entsize): Add return to avoid
3011         compiler warnings.
3012
3013 2009-08-06  Sriraman Tallam  <tmsriram@google.com>
3014
3015         * x86_64.cc (Target_x86_64::Relocate::relocate_tls): Check for a
3016         valid tls_segment only for non-debug-section relocations.
3017         * testsuite/Makefile.am: Add gc_tls_test.
3018         * testsuite/Makefile.in: Regenerate.
3019         * testsuite/gc_tls_test.cc: New file.
3020         * testsuite/gc_tls_test.sh: New file.
3021
3022 2009-08-05  Sriraman Tallam  <tmsriram@google.com>
3023         
3024         * icf.cc: New file.
3025         * icf.h: New file.
3026         * Makefile.am (CCFILES): Add icf.cc.
3027         (HFILES): Add icf.h
3028         * Makefile.in: Regenerate.
3029         * dynobj.h (Sized_dynobj::do_section_entsize): New function.
3030         * gc.h (gc_process_relocs): Populate lists used by icf to contain
3031         section, symbol and addend information for the relocs.
3032         * gold.cc (queue_middle_tasks): Call identical code folding.
3033         * gold.h: Add defines for multimap.
3034         * layout.cc (Layout::create_symtab_sections): Add symtab as parameter
3035         to the call of finalize_local_symbols.
3036         * main.cc (main): Create object of class Icf.
3037         * object.cc (Sized_relobj::do_layout): Allow this function to be
3038         called twice during icf.
3039         (Sized_relobj::do_finalize_local_symbols): Fold symbols corresponding
3040         to sections marked as identical by icf.
3041         (Sized_relobj::do_section_flags): Get section_flags from Symbols_data
3042         when available.
3043         (Sized_relobj::do_section_entsize): New function.
3044         * object.h (Object::section_entsize): New function.
3045         (Object::do_section_entsize): New pure virtual function.
3046         (Relobj::finalize_local_symbols): Add new parameter.
3047         (Relobj::do_section_entsize): New function.
3048         * options.h (General_options::icf): New option.
3049         (General_options::icf_iterations): New option.
3050         (General_options::print_icf_sections): New option.
3051         * plugin.cc (Sized_pluginobj::do_section_entsize): New function.
3052         * plugin.h (Sized_pluginobj::do_section_entsize): New function.
3053         * reloc.cc (Read_relocs::run): Delay scanning relocs when doing
3054         icf.
3055         * symtab.cc (Symbol_table::is_section_folded): New function.
3056         (Symbol_table::sized_finalize_symbol):  Fold symbols corresponding
3057         to sections marked as identical by icf.
3058         * symtab.h (Symbol_table::set_icf): New function.
3059         (Symbol_table::icf): New function.
3060         (Symbol_table::is_section_folded): New function.
3061         (Symbol_table::icf_): New data member.
3062         * target-reloc.h (relocate_section): Ignore sections folded by icf.
3063         * testsuite/Makefile.am: Add commands to build icf_test.
3064         * testsuite/Makefile.in: Regenerate.
3065         * testsuite/icf_test.sh: New file.
3066         * testsuite/icf_test.cc: New file.
3067
3068 2009-07-24  Chris Demetriou  <cgd@google.com>
3069
3070         * layout.cc (is_compressible_debug_section): Fix incorrect
3071         comment about compressed section names.
3072
3073 2009-07-20  Ian Lance Taylor  <ian@airs.com>
3074
3075         PR 10419
3076         * x86_64.cc (Target_x86_64::do_code_fill): Correct nop sequences.
3077
3078 2009-07-16  Ian Lance Taylor  <iant@google.com>
3079
3080         PR 10400
3081         * layout.h: #include <map>.
3082         (class Kept_section): Change from struct to class.  Add accessors
3083         and setters.  Add section size to Comdat_group mapping.  Change
3084         Comdat_group to std::map.  Add is_comdat_ field.  Add
3085         linkonce_size field in union.
3086         (class Layout): Update declaration of find_or_add_kept_section.
3087         Don't declare find_kept_object.
3088         * layout.cc (Layout::find_or_add_kept_section): Remove candidate
3089         parameter.  Add object, shndx, is_comdat, and is_group_name
3090         parameters.  Change all callers.  Adjust for new Kept_section.
3091         (Layout::find_kept_object): Remove.
3092         * object.cc (Sized_relobj::include_section_group): Update use of
3093         Kept_section.  Rename secnum to shndx.  Only record
3094         Kept_comdat_section if sections are the same size.
3095         (Sized_relobj::include_linkonce_section): Update use of
3096         Kept_section.  Only record Kept_comdat_section if sections are the
3097         same size.  Set size of linkonce section.
3098         (Sized_relobj::map_to_kept_section): Update call to
3099         get_kept_comdat_section.
3100         * object.h (class Sized_relobj): Rename fields in
3101         Kept_comdat_section to drop trailing underscores; change object
3102         field to Relobj*.  Change Kept_comdat_section_table to store
3103         struct rather than pointer.
3104         (Sized_relobj::set_kept_comdat_section): Remove kept parameter.
3105         Add kept_object and kept_shndx parameters.  Change all callers.
3106         (Sized_relobj::get_kept_comdat_section): Change return type to
3107         bool.  Add kept_object and kept_shndx parameters.  Change all
3108         callers.
3109         * plugin.cc (Pluginobj::include_comdat_group): Update call to
3110         Layout::find_or_add_kept_section.
3111
3112 2009-07-09  Ian Lance Taylor  <iant@google.com>
3113
3114         * merge.cc (Object_merge_map::initialize_input_to_output_map):
3115         Reserve space in the hash table.
3116
3117 2009-07-06  Mikolaj Zalewski  <mikolajz@google.com>
3118
3119         * fileread.cc (File_read::get_mtime): New method.
3120         * fileread.h (Timespec): New structure.
3121         (File_read::get_mtime): New method.
3122         * incremental.cc (Incremental_inputs_entry_data::timestamp_usec):
3123         Renamed from timestamp_nsec.
3124         (Incremental_inputs_entry_write::timestamp_sec): Fix argument to
3125         Elf_Xword.
3126         (Incremental_inputs_entry_write::timestamp_usec): Renamed from 
3127         timestamp_nsec.
3128         (Incremental_inputs::report_archive): Save mtime; style fix. 
3129         (Incremental_inputs::report_obejct): Save mtime; style fix.
3130         (Incremental_inputs::report_script): Save mtime; style fix.
3131         (Incremental_inputs::finalize_inputs): Style fix.
3132         (Incremental_inputs::finalize): Style fix.
3133         (Incremental_inputs::create_input_section_data): Store inputs
3134         mtime.
3135         * incremental.h (Incremental_inputs::report_script): Add mtime
3136         argument.
3137         (Incremental_inputs::Input_info::Input_info): Intialize only one
3138         union member.
3139         (Incremental_inputs::Input_info::archive): Move to nameless
3140         union.
3141         (Incremental_inputs::Input_info::obejct): Move to nameless union.
3142         (Incremental_inputs::Input_info::script): Move to nameless union.
3143         (Incremental_inputs::mtime): New field.
3144         * script.cc (read_input_script): Pass file mtime to
3145         Incremental_input.
3146         * script.h (Script_info::inputs): Style fix.
3147
3148 2009-07-01  Ian Lance Taylor  <ian@airs.com>
3149
3150         * freebsd.h (Target_freebsd::do_adjust_elf_header): Use size
3151         instead of 32.
3152
3153 2009-06-24  Ian Lance Taylor  <iant@google.com>
3154
3155         PR 10156
3156         * layout.cc (Layout::choose_output_section): If we find an
3157         existing section, update the flags.
3158         (Layout::create_notes): New function, broken out of
3159         Layout::finalize.
3160         (Layout::finalize): Don't create note sections.
3161         (Layout::create_note): Don't crash if linker script discards
3162         section.
3163         (Layout::create_gold_note): Likewise.
3164         (Layout::create_build_id): Likewise.  Don't set
3165         after_input_sections on the section.
3166         (Layout::create_executable_stack_info): Remove target parameter.
3167         Change caller.
3168         * layout.h (class Layout): Declare create_notes.  Update
3169         declaration of create_executable_stack_info.
3170         * gold.cc (queue_middle_tasks): Call create_notes.
3171         * output.cc (Output_section::update_flags_for_input_section): Move
3172         here from output.h.  If SHF_ALLOC flag is newly set, mark address
3173         invalid.
3174         * output.h (Output_data::mark_address_invalid): New function.
3175         (class Output_section): Only declare, not define,
3176         update_flags_for_input_section.  Remove set_flags.
3177
3178 2009-06-24  Ian Lance Taylor  <iant@google.com>
3179
3180         * script-sections.cc (Output_section_definition::
3181         set_section_addresses): Rename shadowing local load_address to
3182         laddr.
3183
3184 2009-06-24  Ian Lance Taylor  <iant@google.com>
3185
3186         PR 10244
3187         * reloc.cc (relocate_sections): Skip empty relocation sections.
3188
3189 2009-06-23  Ian Lance Taylor  <iant@google.com>
3190
3191         PR 10156
3192         * layout.cc (Layout::create_note): Use choose_output_section
3193         rather than make_output_section.
3194
3195 2009-06-23  Ian Lance Taylor  <iant@google.com>
3196
3197         PR 10237
3198         * options.cc (General_options::parse_V): Set printed_version_.
3199         (General_options::General_options): Initialize printed_version_.
3200         * options.h (class General_options): Add printed_version_ field.
3201         * gold.cc (queue_initial_tasks): If there are no input files,
3202         don't give a fatal error if we printed the version information.
3203         (queue_middle_tasks): If using -r with a shared object, give a
3204         fatal error rather than an ordinary error.
3205
3206 2009-06-23  Ian Lance Taylor  <iant@google.com>
3207
3208         PR 10219
3209         * layout.cc (Layout::Layout): Initialize have_stabstr_section_.
3210         (Layout::make_output_section): Set have_stabstr_section_ if we see
3211         a .stab*str section.
3212         (Layout::finalize): Call link_stabs_sections.
3213         (Layout::link_stabs_sections): New file.
3214         * layout.h (class Layout): Add have_stabstr_section_ field.
3215         Declare link_stabs_sections.
3216
3217 2009-06-23  Doug Kwan  <dougkwan@google.com>
3218
3219         * Makefile.am (libgold_a_LIBADD): New.
3220         (ld_new_DEPENDENCIES, ld_new_LDADD): Remove LIBOBJS
3221         * Makefile.in: Regenerate.
3222         * config.in (HAVE_DECL_MEMMEM, HAVE_DECL_STRNDUP): New.
3223         * configure: Regenerate.
3224         * configure.ac (AC_CHECK_DECLS): Add strndup and memmem.
3225         * fileread.cc: Include sys/state.h
3226         * gold.h: Declare memmem and strndup if found missing.
3227         * gold_reloc.h: Include byteswap.h if HAVE_BYTESWAP_H is defined.
3228
3229 2009-06-23  Ian Lance Taylor  <iant@google.com>
3230
3231         * configure.ac: Call AC_CHECK_DECLS using C, not C++.
3232         * configure: Rebuild.
3233
3234 2009-06-23  Ian Lance Taylor  <iant@google.com>
3235
3236         PR 10147
3237         * object.cc (Object::section_contents): Don't try to get a view if
3238         the section has length zero.
3239         (Object::handle_gnu_warning_section): If the section is empty, use
3240         the name of the section as the warning.
3241
3242 2009-06-23  Ian Lance Taylor  <iant@google.com>
3243
3244         PR 10133
3245         * stringpool.h (class Stringpool_template): Add optimize_ field.
3246         (Stringpool_template::set_optimize): New function.
3247         * stringpool.cc (Stringpool_template::Stringpool_template):
3248         Initialize optimize_ field.
3249         (Stringpool_template::set_string_offsets): Test local optimize
3250         fild rather than parameter.
3251         * layout.cc (Layout::Layout): Call set_optimize on the section
3252         name stringpool.
3253
3254 2009-06-22  Ian Lance Taylor  <iant@google.com>
3255
3256         PR 10030
3257         * yyscript.y: Parse TARGET.
3258         * script.cc (script_set_target): New function.
3259         * script-c.h (script_set_target): Declare.
3260         * options.cc (General_options::string_to_object_format): Rename
3261         from string_to_object_format in anonymous namespace.  Change
3262         callers.
3263         * options.h (class General_options): Declare
3264         string_to_object_format.
3265
3266 2009-06-22  Ian Lance Taylor  <iant@google.com>
3267
3268         * script-sections.cc (Script_sections::create_segments): Don't put
3269         program headers in a PT_LOAD segment if -n or -N.
3270
3271 2009-06-22  Ian Lance Taylor  <iant@google.com>
3272
3273         PR 10141
3274         * options.h (class General_options): Add -z lazy and -z now.  Sort
3275         -z options into alphabetical order.
3276         * layout.cc (Layout::finish_dynamic_section): Handle -z now.
3277
3278 2009-06-21  Ian Lance Taylor  <iant@google.com>
3279
3280         * layout.cc (Layout::make_output_section): Call
3281         Target::new_output_section.
3282         (Layout::attach_allocated_section_to_segment): Put large section
3283         sections in a separate load segment with the large segment flag
3284         set.
3285         (Layout::segment_precedes): Sort large data segments after other
3286         load segments.
3287         (align_file_offset): New static function.
3288         (Layout::set_segment_offsets): Use align_file_offset.
3289         * output.h (class Output_section): Add is_small_section_ and
3290         is_large_section_ fields.
3291         (Output_section::is_small_section): New function.
3292         (Output_section::set_is_small_section):  New function.
3293         (Output_section::is_large_section): New function.
3294         (Output_section::set_is_large_section): New function.
3295         (Output_section::is_large_data_section): New function.
3296         (class Output_segment): Add is_large_data_segment_ field.
3297         (Output_segment::is_large_data_segment): New function.
3298         (Output_segment::set_is_large_data_segment): New function.
3299         * output.cc (Output_section::Output_section): Initialize new
3300         fields.
3301         (Output_segment::Output_segment): Likewise.
3302         (Output_segment::add_output_section): Add assertion that large
3303         data sections always go in large data segments.  Force small data
3304         sections to the end of the list of data sections.  Force small BSS
3305         sections to the start of the list of BSS sections.  For large BSS
3306         sections to the end of the list of BSS sections.
3307         * symtab.h (class Symbol): Declare is_common_shndx.
3308         (Symbol::is_defined): Check Symbol::is_common_shndx.
3309         (Symbol::is_common): Likewise.
3310         (class Symbol_table): Define enum Commons_section_type.  Update
3311         declarations.  Add small_commons_ and large_commons_ fields.
3312         * symtab.cc (Symbol::is_common_shndx): New function.
3313         (Symbol_table::Symbol_table): Initialize new fields.
3314         (Symbol_table::add_from_object): Put small and large common
3315         symbols in the right list.
3316         (Symbol_table::sized_finalized_symbol): Check
3317         Symbol::is_common_shndx.
3318         (Symbol_table::sized_write_globals): Likewise.
3319         * common.cc (Symbol_table::do_allocate_commons): Allocate new
3320         common symbol lists.  Don't call do_allocate_commons_list if the
3321         list is empty.
3322         (Symbol_table::do_allocate_commons_list): Remove is_tls
3323         parameter.  Add comons_section_type parameter.  Change all
3324         callers.  Handle small and large common symbols.
3325         * object.cc (Sized_relobj::do_finalize_local_symbols): Check
3326         Symbol::is_common_shndx.
3327         * resolve.cc (symbol_to_bits): Likewise.
3328         * target.h (Target::small_common_shndx): New function.
3329         (Target::small_common_section_flags): New function.
3330         (Target::large_common_shndx): New function.
3331         (Target::large_common_section_flags): New function.
3332         (Target::new_output_section): New function.
3333         (Target::Target_info): Add small_common_shndx, large_common_shndx,
3334         small_common_section_flags, and large_common_section_flags
3335         fields.
3336         (Target::do_new_output_section): New virtual function.
3337         * arm.cc (Target_arm::arm_info): Initialize new fields.
3338         * i386.cc (Target_i386::i386_info): Likewise.
3339         * powerpc.cc (Target_powerpc::powerpc_info) [all versions]:
3340         Likewise.
3341         * sparc.c (Target_sparc::sparc_info) [all versions]: Likewise.
3342         * x86_64.cc (Target_x86_64::x86_64_info): Likewise.
3343         (Target_x86_64::do_new_output_section): New function.
3344         * configure.ac: Define conditional MCMODEL_MEDIUM.
3345         * testsuite/Makefile.am (check_PROGRAMS): Add large.
3346         (large_SOURCES, large_CFLAGS, large_DEPENDENCIES): Define.
3347         (large_LDFLAGS): Define.
3348         * testsuite/large.c: New file.
3349         * testsuite/testfile.cc (Target_test::test_target_info):
3350         Initialize new fields.
3351         * configure, testsuite/Makefile.in: Rebuild.
3352
3353 2009-06-05  Doug Kwan  <dougkwan@google.com>
3354
3355         * Makefile.am (CCFILES): Add target.cc.
3356         * Makefile.in: Regenerate. 
3357         * i386.cc (class Target_i386): Define new virtual method to
3358         override do_is_local_label_name in parent.
3359         * object.cc (Sized_relobj::do_count_local_symbols): Discard
3360         local symbols if --discard-locals or -X is given.
3361         * options.h (class General_options): Declare new options
3362         '--discard-locals' and '-X' for discarding locals.
3363         * target.h (class Target): Define new methods is_local_label_name.
3364         Declare new virtual method do_is_local_label_name.
3365         * target.cc: New file.
3366         * testsuite/Makefile.am (check_PROGRAMS): Add discard_locals_test.
3367         (check_SCRIPTS): Add discard_locals_test.sh.
3368         (check_DATA): Add discard_local_tests.syms.
3369         (discard_locals_test_SOURCES, discard_locals_test_LDFLAGS): Define.
3370         (discard_local_tests.syms, discard_locals_test.o): New make rules.
3371         * testsuite/Makefile.in: Regenerate.
3372         * testsuite/discard_locals_test.c: New file.
3373         * testsuite/discard_locals_test.sh: Same.
3374
3375 2009-06-05  Doug Kwan  <dougkwan@google.com>
3376
3377         * object.cc (Sized_relobj::Sized_relobj): Initialize
3378         discarded_eh_frame_shndx_ to -1U.
3379         (Sized_relobj::do_layout): Record index of a discard .eh_frame
3380         section.
3381         (Sized_relobj::do_count_local_symbols): Skip local symbols in
3382         a discarded .eh_frame section.
3383         (Sized_relobj::do_finalize_local_symbols): Ditto.
3384         * object.h (class Sized_relobj): Declare new member
3385         discarded_eh_frame_shndx_.
3386         * testsuite/Makefile.am (check_PROGRAMS): Add local_labels_test.
3387         (local_labels_test.o, local_labels_test): New rules.
3388         * testsuite/Makefile.in: Regenerate.
3389
3390 2009-06-04  Doug Kwan  <dougkwan@google.com>
3391
3392         * layout.cc (Layout::section_name_mapping): Add mapping for
3393         special ARM sections.
3394
3395 2009-06-03  Doug Kwan  <dougkwan@google.com>
3396
3397         * arm.cc (utils::sign_extend): Reverse test in gold_assert.
3398         (utils::has_overflow): Same.
3399
3400 2009-06-03  Ian Lance Taylor  <iant@google.com>
3401
3402         * layout.cc (Layout::section_name_mapping): New array, replacing
3403         Layout::linkonce_mapping.
3404         (Layout::section_name_mapping_count): New variable, replacing
3405         Layout::linkonce_mapping_count.
3406         (Layout::linkonce_output_name): Remove.
3407         (Layout::output_section_name): Rewrite.
3408         * layout.h (class Layout): Rename Linkonce_mapping to
3409         Section_name_mapping, linkonce_mapping to section_name_mapping,
3410         linkonce_mapping_count to section_name_mapping_count.  Don't
3411         declare linkonce_output_name.
3412
3413 2009-06-03  Doug Kwan  <dougkwan@google.com>
3414
3415         * gold/arm.cc (namespace utils): New.
3416         (Target_arm::reloc_is_non_pic): Define new method.
3417         (class Arm_relocate_functions): New.
3418         (Target_arm::Relocate::relocate): Handle relocation types used by
3419         Android.
3420
3421 2009-06-03  Ian Lance Taylor  <iant@google.com>
3422
3423         * arm.cc (Target_arm::scan::global): Use || instead of |.
3424
3425 2009-06-02  Doug Kwan  <dougkwan@google.com>
3426
3427         * gold/arm.cc (Target_arm::Scan::Scan):  Initialize
3428         issued_non_pic_error_.
3429         (class Target_arm::Scan): Declare new method check_non_pic.
3430         Define new method symbol_needs_plt_entry.
3431         Declare new data member issued_non_pic_error_.
3432         (class Target_arm::Relocate): Declare new method
3433         should_apply_static_reloc.
3434         (Target_arm::may_need_copy_reloc): Handle STT_ARM_TFUNC.
3435         (Target_arm::Scan::check_non_pic): Define new method.
3436         (Target_arm::Scan::local): Handle a small subset of reloc types used
3437         by Android.
3438         (Target_arm::Scan::local): Same.
3439         (Target_arm::Relocate::should_apply_statci_reloc): Define new method.
3440
3441 2009-05-31  Mikolaj Zalewski  <mikolajz@google.com>
3442
3443         * incremental.cc (Incremental_inputs::report_command_line): Filter
3444         out --incremental-* options.
3445
3446 2009-05-29  Doug Kwan  <dougkwan@google.com>
3447
3448         * gold/arm.cc (Output_data_plt_arm): Forward declaration for new
3449         template class.
3450         (class Target_arm): Update comment.
3451         (Target_arm::Target_arm): Initialize new data members GOT_,
3452         PLT_, GOT_PLT_, REL_DYN_, COPY_RELOCS_ and DYNBSS_.
3453         Declare new methods Target_arm::got_section, Target_arm::make_plt_entry
3454         and Target_arm::rel_dyn_section.
3455         Declare new_enum Target_arm::Got_type.
3456         Declare new data members GOT_, PLT_, GOT_PLT_, REL_DYN_, COPY_RELOCS_
3457         and DYNBSS_.
3458         Update commments for member do_dynsym_value.
3459         (Target_arm::got_size, Target_arm::plt_section,
3460         Target_arm::may_need_copy_reloc and Target_arm::copy_reloc): Define
3461         new methods inside class defintion.
3462         (Target_arm::got_section): Define new method.
3463         (Target_arm::rel_dyn_section): Same.
3464         (Output_data_plt_arm): New template class.
3465         (Output_data_plt_arm::Output_data_plt_arm): Define constructor.
3466         (Output_data_plt_arm:do_adjust_output_section): Define new method.
3467         (Output_data_plt_arm::add_entry): Same.
3468         (Output_data_plt_arm::first_plt_entry): Define new
3469         static data member for PLT instruction template.
3470         (Output_data_plt_arm::plt_entry): Same.
3471         (Output_data_plt_arm::do_write): Define new method.
3472         (Target_arm::make_plt_entry): Same.
3473         (Target_arm::do_finalize_sections): Same.
3474         (Target_arm::do_dynsym_value): Same.
3475
3476 2009-05-28  Doug Kwan  <dougkwan@google.com>
3477
3478         * Makefile.am (TARGETSOURCES): Add arm.cc.
3479         (ALL_TARGETOBJECTS): Add arm.$(OBJEXT)
3480         * Makefile.in: Regenerate.
3481         * arm.cc: New file.
3482         * configure.tgt: Add armbe*-*-*, armeb*-*-* and arm*-*-* targets.
3483
3484 2009-05-26  Doug Kwan  <dougkwan@google.com>
3485
3486         * options.cc (General_options::parse_exclude_libs).  Fix a comment.
3487         (General_options::check_excluded_libs): Strip off directories in
3488         archive name before matching like GNU ld does.
3489         * testsuite/Makefile.am (MOSTLYCLEANFILES,
3490         exclude_libs_test_DEPENDENCIES): Add alt/libexclude_libs_test_3.a
3491         (exclude_libs_test_LDFLAGS): Add linker option
3492         -Wl,--exclude-libs,libexclude_libs_test_3
3493         (exclude_libs_test_LADD): Add alt/libexclude_libs_test_3.a as
3494         an explicit archive without using -l.
3495         (alt/libexclude_libs_test_3.a): New make rule.
3496         * testsuite/Makefile.in: Regenerate.
3497         * testsuite/exclude_libs_test.c : Declare lib3_default().
3498         (main): Call it.
3499         * exclude_libs_test.sh: Add tests for alt/exclude_libs_test_3.a.
3500         * exclude_libs_test_3.c: New file.
3501
3502 2009-05-26  Nick Clifton  <nickc@redhat.com>
3503
3504         * po/id.po: New Indonesian translation.
3505         * po/gold.pot: Updated template file.
3506
3507 2009-05-22  Sriraman Tallam  <tmsriram@google.com>
3508
3509         * testsuite/Makefile.am: Add -ffunction-sections to compile 
3510         gc_comdat_test files.  Add -Wl,--gc-sections to build
3511         gc_comdat_test.
3512         * testsuite/Makefile.in: Regenerate.
3513         * testsuite/gc_comdat_test.sh: Fix the condition around grep.
3514
3515 2009-05-21  Sriraman Tallam  <tmsriram@google.com>
3516
3517         * object.cc (Sized_relobj::map_to_kept_section): Return NULL if the
3518         kept comdat section was garbage collected.
3519         * testsuite/Makefile.am: Add test gc_comdat_test.sh.
3520         * testsuite/Makefile.in: Regenerate.
3521         * testsuite/gc_comdat_test.sh: New file.
3522         * testsuite/gc_comdat_test_1.cc: New file.
3523         * testsuite/gc_comdat_test_2.cc: New file.
3524
3525 2009-05-19  Doug Kwan  <dougkwan@google.com>
3526
3527         * archive.cc (Archive::Archive): Move constructor from archive.h
3528         to here.  Initialize no_export_.
3529         (Archive::get_elf_object_for_member): Set no_export flag of object.
3530         * archive.h (Archive::Archive): Move constructor body to
3531         archive.cc.
3532         (Archive::no_export): New method.
3533         (Archive::no_export_): New field.
3534         * object.h (Object::Object): Initialize no_export_ to false.
3535         (Object::no_export, Object::set_no_export): New methods.
3536         (Object::no_export_): New field.
3537         * options.cc (General_options::parse_exclude_libs): New method.
3538         (General_options::check_excluded_libs) Same.
3539         * options.h (exclude_libs): New option.
3540         (General_options::check_excluded_libs): New method declaration.
3541         (General_options::excluded_libs_): New field.
3542         * symtab.cc (Symbol_table::add_from_relobj): Hide symbols with
3543         default or protected visibility if an object has no-export flag set.
3544         testsuite/Makefile.am (check_PROGRAMS): Add exclude_libs_test.
3545         (check_SCRIPTS): Add exclude_libs_test.sh.
3546         (check_DATA): Add exclude_libs_test.syms.
3547         (MOSTLYCLEANFILES): Add exclude_libs_test.syms,
3548         libexclude_libs_test_1.a and libexclude_libs_test_2.a.
3549         (exclude_libs_test_SOURCES, exclude_libs_test_DEPENDENCIES,
3550         exclude_libs_test_LDFLAGS and exclude_libs_test_LDADD): Define.
3551         (exclude_libs_test.syms, libexclude_libs_test_1.a,
3552         libexclude_libs_test_2.a): New rules.
3553         * testsuite/Makefile.in: Regenerate.
3554         * testsuite/exclude_libs_test.c: New file.
3555         * testsuite/exclude_libs_test.sh: Ditto.
3556         * testsuite/exclude_libs_test_1.c: Ditto.
3557         * testsuite/exclude_libs_test_2.c: Ditto.
3558
3559 2009-05-15  Ian Lance Taylor  <iant@google.com>
3560
3561         * configure.ac: Check for declarations for cases where libiberty.h
3562         checks HAVE_DECL_xxx.
3563         * configure, config.in: Rebuild.
3564
3565 2009-05-15  Mikolaj Zalewski  <mikolajz@google.com>
3566
3567         * gold.h (Incremental_argument_list): Remove (invalid) forward
3568         declaration.
3569         * incremental.cc (Incremental_inputs::report_achive): New method.
3570         (Incremental_inputs::report_object): New method.
3571         (Incremental_inputs::report_script): New method.
3572         (Incremental_inputs::finalize_inputs): New method.
3573         (Incremental_inputs::finalize): Call finalize_inputs().
3574         (Incremental_inputs::sized_create_incremental_inputs_section_data):
3575         Create inputs entries.
3576         * incremental.h (Incremental_input_type): New enum.
3577         (Incremental_inputs::Incremental_input): Initialize new fields.
3578         (Incremental_inputs::report_inputs): New method.
3579         (Incremental_inputs::report_achive): New method.
3580         (Incremental_inputs::report_object): New method.
3581         (Incremental_inputs::report_script): New method.
3582         (Incremental_inputs::finalize_inputs): New method.
3583         (Incremental_inputs::Input_info): New struct.
3584         (Incremental_inputs::Input_info_map): New typedef.
3585         (Incremental_inputs::lock_): New field.
3586         (Incremental_inputs::Inputs_): New field.
3587         (Incremental_inputs::Inputs_map): New field.
3588         * main.cc (main): Call Incremental_input::report_inputs.
3589         * options.h (Input_argument_list): Typedef moved from
3590         Input_arguments.
3591         (Input_file_group::Files): Remove, use ::Input_argument_list.
3592         (Input_file_group::Input_argument_list): Remove, use
3593         ::Input_argument_list.
3594         * plugin.cc (Plugin_manager::add_input_file): Add error in
3595         incremental build.
3596         * read_syms.cc (do_read_syms): Call Incremental_input::report_*
3597         functions.
3598         * script.cc (read_input_script): Call
3599         Incremental_input::report_script.
3600         * script.h (Script_info): New class.
3601
3602 2009-04-27  Ian Lance Taylor  <iant@google.com>
3603
3604         * x86_64.cc (do_adjust_output_section): Set entsize to
3605         plt_entry_size.
3606
3607 2009-04-23  Elliott Hughes  <enh@google.com>
3608
3609         * output.cc (Output_file::close): After short writes, continue
3610         writing from the correct offset in the buffer being written.
3611
3612 2009-04-23  Chris Demetriou  <cgd@google.com>
3613
3614         * configure.ac (HAVE_TR1_UNORDERED_MAP_REHASH): New define.
3615         * configure: Regenerate.
3616         * config.in: Regenerate.
3617         * gold.h: Avoid std::tr1::unordered_map and std::tr1::unordered_set
3618         if HAVE_TR1_UNORDERED_MAP_REHASH is not defined.
3619
3620 2009-04-21  Mikolaj Zalewski  <mikolajz@google.com>
3621
3622         * incremental.cc (Incremental_inputs_header_data): Renamed from
3623         Incremental_input_header_data.
3624         (Incremental_inputs_header_data::data_size): New field.
3625         (Incremental_inputs_header_data::put_input_file_count): Renamed
3626         from input_file_count.
3627         (Incremental_inputs_header_data::put_command_line_offset): Renamed
3628         from command_line_offset.
3629         (Incremental_inputs_header_data::put_reserved): Renamed from
3630         put_reserved.
3631         (Incremental_inputs_entry_data): Renamed from
3632         Incremental_input_entry_data.
3633         (Incremental_inputs_entry_data::data_size): New field.
3634         (Incremental_inputs::report_command_line): New method.
3635         (Incremental_inputs::finalize): New method.
3636         (Incremental_inputs::create_incremental_inputs_data): New method.
3637         (Incremental_inputs::sized_create_incremental_inputs_data): New method.
3638         * incremental.h: New file.
3639         * layout.cc (Layout::Layout): Handle new incremental_inputs_.
3640        (Layout::finalize): Create incremental inputs section in
3641         incremental builds.
3642        (Layout::create_incremental_info_sections): New method.
3643         * layout.h (Layout::incremental_inputs): New method.
3644        (Layout::create_incremental_info_sections): New method.
3645        (Layout::incremental_inputs_): New field.
3646         * main.cc (main): Notify Incremental_input of the command line.
3647
3648 2009-04-01  Ian Lance Taylor  <iant@google.com>
3649             Mikolaj Zalewski  <mikolajz@google.com>
3650
3651         * gold.h (reserve_unordered_map): Define, three versions, one for
3652         each version of Unordered_map.
3653         * layout.cc (Layout::Layout): Remove options parameter.  Add
3654         number_of_input_files parameter.  Don't initialize options_.
3655         Initialize number_of_input_files_ and resized_signatures_.  Move
3656         sections_are_attached_.
3657         (Layout::layout_group): Reserve space for group_signatures_.
3658         (Layout::find_or_add_kept_section): Change name parameter to be a
3659         reference.  Resize signatures_ map when it gets large enough.
3660         (Layout::layout_eh_frame): Use parameters->options() instead of
3661         this->options_.
3662         (Layout::make_output_section): Likewise.
3663         (Layout::attach_allocated_section_to_segment): Likewise.
3664         (Layout::finalize, Layout::create_executable_stack): Likewise.
3665         (Layout::set_segment_offsets, Layout::create_interp): Likewise.
3666         (Layout::finish_dynamic_section, Layout::write_binary): Likewise.
3667         * layout.h (class Layout): Update declarations.  Remove options_
3668         field.  Add number_of_input_files_ and resized_signatures_
3669         fields.  Move sections_are_attached_ field.
3670         * main.cc (main): Pass number of input files to Layout
3671         constructor.  Don't pass options.
3672
3673 2009-03-30  Ian Lance Taylor  <iant@google.com>
3674
3675         * ffsll.c (ffsll): Correct implementation.
3676
3677 2009-03-27  Ian Lance Taylor  <iant@google.com>
3678
3679         * ffsll.c: New file.
3680         * configure.ac: Call AC_REPLACE_FUNCS on ffsll.
3681         * gold.h (ffsll): Declare if HAVE_FFSLL is not defined.
3682         * ftruncate.c (ftruncate): Declare before definition.
3683         * mremap.c (mremap): Likewise.
3684         * pread.c (pread): Likewise.
3685         * configure, Makefile.in, config.in: Rebuild.
3686
3687         * mremap.c: New file.
3688         * configure.ac: Call AC_REPLACE_FUNCS on mremap.
3689         * gold.h (MREMAP_MAYMOVE): Define if HAVE_MREMAP is not defined.
3690         (mremap): Declare if HAVE_MREMAP is not defined.
3691         * configure, Makefile.in, config.in: Rebuild.
3692
3693 2009-03-27  Cary Coutant  <ccoutant@google.com>
3694
3695         * powerpc.cc (Target_powerpc::check_non_pic): Assert that output is
3696         position independent.
3697         * sparc.cc (Target_sparc::check_non_pic): Likewise.
3698         * x86_64.cc (Target_x86_64::check_non_pic): Likewise.
3699
3700 2009-03-24  Cary Coutant  <ccoutant@google.com>
3701
3702         * symtab.h (needs_plt_entry): Check for unsatisfied reference from
3703         an executable.
3704         (needs_dynamic_reloc): Likewise.
3705
3706 2009-03-24  Ian Lance Taylor  <iant@google.com>
3707
3708         * yyscript.y (file_cmd): Recognize EXTERN.
3709         (extern_name_list, extern_name_list_body): New nonterminals.
3710         * script.cc (script_add_extern): Define.
3711         * script-c.h (script_add_extern): Declare.
3712
3713 2009-03-24  Rafael Avila de Espindola  <espindola@google.com>
3714
3715         * object.cc (is_elf_object): Define.
3716         * object.h (is_elf_object): Declare.
3717         * archive.cc (Archive::get_elf_object_for_member): Call
3718         is_elf_object.
3719         * readsyms.cc (Read_symbols::do_read_symbols): Likewise.
3720
3721 2009-03-24  Elliott Hughes  <enh@google.com>
3722
3723         * output.cc (Output_file::map_anonymous): Define.
3724         (Output_file::map): Use map_anonymous.  If the regular mmap fails,
3725         try an anonymous one.  Report the size if the mmap fails.
3726         * output.h (class Output_file): Declare map_anonymous.
3727
3728 2009-03-24  Ian Lance Taylor  <iant@google.com>
3729
3730         * target-select.cc (instantiate_target): Don't acquire the lock if
3731         the instantiated_target_ field has already been set.
3732
3733 2009-03-23  Ian Lance Taylor  <iant@google.com>
3734
3735         * gold-threads.h (class Initialize_lock): Define.
3736         * gold-threads.cc (class Initialize_lock_once): Define.
3737         (initialize_lock_control): New static variable.
3738         (initialize_lock_pointer): New static variable.
3739         (initialize_lock_once): New static function.
3740         (Initialize_lock::Initialize_lock): Define.
3741         (Initialize_lock::initialize): Define.
3742         * target-select.h: Include "gold-threads.h".
3743         (class Target_selector): Add lock_ and initialize_lock_ fields.
3744         Don't define instantiate_target, just declare it.
3745         * target-select.cc (Target_selector::Target_selector): Initialize
3746         new fields.
3747         (Target_selector::instantiate_target): Define.
3748         * descriptors.h: Include "gold-threads.h".
3749         (class Descriptors): Add initialize_lock_ field.
3750         * descriptors.cc (Descriptors::Descriptors): Initialize new
3751         field.
3752         (Descriptors::open): Use initialize_lock_ field
3753         * errors.h (class Errors): Add initialize_lock_ field.
3754         * errors.cc (Errors::Errors): Initialize new field.
3755         (Errors::initialize_lock): Use initialize_lock_ field.
3756         * powerpc.cc (class Target_selector_powerpc): Remove
3757         instantiated_target_ field.  In do_recognize call
3758         instantiate_target rather than do_instantiate_target.  In
3759         do_instantiate_target just allocate a new target.
3760         * sparc.cc (class Target_selector_sparc): Likewise.
3761
3762         * freebsd.h: New file.
3763         * i386.cc: Include "freebsd.h".
3764         (Target_i386): Derive from Target_freebsd rather than
3765         Sized_target.
3766         (Target_selector_i386): Derive from Target_selector_freebsd rather
3767         than Target_selector.
3768         * x86_64.cc: Include "freebsd.h".
3769         (Target_x86_64): Derive from Target_freebsd rather than
3770         Sized_target.
3771         (Target_selector_x86_64): Derive from Target_selector_freebsd
3772         rather than Target_selector.
3773         * target.h (class Target): Add adjust_elf_header and
3774         do_adjust_elf_header.
3775         * output.cc (Output_file_header:: do_sized_write): Call target
3776         adjust_elf_header routine.
3777         * configure.tgt: Set targ_osabi.
3778         * configure.ac: Define GOLD_DEFAULT_OSABI.
3779         * parameters.cc (Parameters::default_target): Pass
3780         GOLD_DEFAULT_OSABI to select_target.
3781         * target-select.h (class Target_selector): Make instantiate_target
3782         protected rather than private.
3783         * Makefile.am (HFILES): Add freebsd.h.
3784         * configure, Makefile.in, config.in: Rebuild.
3785
3786         * merge.cc (do_add_input_section): Correct pend value.  Change
3787         message about last entry not being null terminated from error to
3788         warning.
3789
3790 2009-03-20  Mikolaj Zalewski  <mikolajz@google.com>
3791
3792         * incremental.cc: New file.
3793         * Makefile.am (CCFILES): Add incremental.cc.
3794         * Makefile.in: Rebuild.
3795
3796 2009-03-19  Paul Pluzhnikov  <ppluzhnikov@google.com>
3797
3798         * layout.cc (Layout::output_section_name): Preserve names
3799         of '.note.' sections.
3800         
3801 2009-03-19  Ian Lance Taylor  <iant@google.com>
3802
3803         * descriptors.cc (Descriptors::open): Check that the options are
3804         valid before using them.
3805
3806 2009-03-18  Ian Lance Taylor  <iant@google.com>
3807
3808         * script-sections.h: Include <list>.
3809         (class Script_sections): Change Sections_elements from std::vector
3810         to std::list.  Typedef public Elements_iterator.  Add
3811         orphan_section_placement_, data_segment_align_start_, and
3812         saw_data_segment_align_ fields.  Remove data_segment_align_index_
3813         field.
3814         * script-sections.cc (class Orphan_section_placement): New class.
3815         (class Sections_element): Add virtual functions is_relro and
3816         orphan_section_init.  Remove virtual function place_orphan_here.
3817         (class Output_section_definition): Add is_relro and
3818         orphan_section_init.  Remove place_orphan_here.
3819         (class Orphan_output_section): Likewise.
3820         (Script_sections::Script_sections): Update for field changes.
3821         (Script_sections::data_segment_align): Set saw_data_segment_align_
3822         and data_segment_align_start_, not data_segment_align_index.
3823         (Script_sections::data_segment_relro_end): Check
3824         saw_data_segment_align_.  Use data_segment_align_start_ rather
3825         than data_segment_align_index_.
3826         (Script_sections::place_orphan): Rewrite to use
3827         Orphan_section_placement.
3828
3829 2009-03-17  Ian Lance Taylor  <iant@google.com>
3830
3831         * archive.cc (Archive::add_symbols): Check for a version attached
3832         to the symbol name in the archive map.
3833         * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_11.
3834         (ver_test_11_SOURCES, ver_test_11_DEPENDENCIES): Define.
3835         (ver_test_11_LDFLAGS, ver_test_11_LDADD): Define.
3836         (ver_test_11.a): New target.
3837         * testsuite/Makefile.in: Rebuild.
3838
3839         * configure.ac: Check for chsize and posix_fallocate.  Replace
3840         ftruncate.
3841         * ftruncate.c: New file, from gnulib.
3842         * output.cc (posix_fallocate): Define dummy version if not
3843         HAVE_POSIX_FALLOCATE.
3844         (Output_file::map): Call posix_fallocate rather than lseek and
3845         write.
3846         * gold.h (ftruncate): Declare if not HAVE_FTRUNCATE.
3847         * configure, Makefile.in, config.in: Rebuild.
3848
3849 2009-03-17  Paul Pluzhnikov  <ppluzhnikov@google.com>
3850         
3851         * layout.h (Layout::create_note): Add section_name parameter.
3852         * layout.cc (Layout::create_note): Likewise.
3853         (Layout::create_build_id, Layout::create_gold_note): Fix callers.
3854         
3855 2009-03-17  Ian Lance Taylor  <iant@google.com>
3856
3857         * descriptors.cc: Include "options.h".
3858         (FD_CLOEXEC, O_CLOEXEC): Define if not defined.
3859         (Descriptors::open): Always use O_CLOEXEC when opening a new
3860         descriptor.  If we have a plugin, and O_CLOEXEC was not defined,
3861         then set FD_CLOEXEC.
3862
3863         * sparc.cc (class Target_sparc): Add has_got_section.
3864         (Target_sparc::Scan::global): If we see _GLOBAL_OFFSET_TABLE_,
3865         make sure we have a GOT section.
3866
3867         * sparc.cc (optimize_tls_reloc): Recognize R_SPARC_TLS_IE_ADD.
3868         (Target_sparc::Scan::local): Likewise.
3869         (Target_sparc::Scan::global): Likewise.
3870         (Target_sparc::Relocate::relocate): Likewise.
3871         (Target_sparc::Relocate::relocate_tls): Likewise.
3872
3873         * symtab.cc (Symbol_table::define_default_version): New function,
3874         broken out of add_from_object.
3875         (Symbol_table::add_from_object): Call define_default_version.
3876         (Symbol_table::define_special_symbol): Add resolve_oldsym
3877         parameter.  Change all callers.  If the version for a symbol comes
3878         from a version script, resolve it with the symbol with the same
3879         name with no version.  Also add the symbol without a version if
3880         appropriate.
3881         (do_define_in_output_data): If resolving with oldsym, don't delete
3882         sym.
3883         (do_define_in_output_segment): Likewise.
3884         (do_define_as_constant): Likewise.
3885         * symtab.h (class Symbol_table): Update declarations.
3886
3887 2009-03-13  Ian Lance Taylor  <iant@google.com>
3888
3889         * readsyms.cc (Read_symbols::incompatible_warning): New function.
3890         (Read_symbols::requeue): New function.
3891         (Read_symbols::do_read_symbols): If make_elf_object fails because
3892         the target type is not configured, and the file was searched for,
3893         issue a warning and retry with the next directory.
3894         (Add_symbols::run): If the file has an incompatible format, and
3895         it was searched for, requeue the Read_symbols task.  On error,
3896         release the object.
3897         * readsyms.h (class Read_symbols): Add dirindex_ field.  Add
3898         dirindex parameter to constructor.  Change all callers.  Declare
3899         incompatible_warning and requeue.
3900         (class Add_symbols): Add dirpath_, dirindex_, mapfile_,
3901         input_argument_ and input_group_ fields.  Add them to
3902         constructor.  Change all callers.
3903         (class Read_script): Add dirindex_ field.  Add it to constructor.
3904         Change all callers.
3905         * archive.cc (Archive::setup): Remove input_objects parameter.
3906         Change all callers.
3907         (Archive::get_file_and_offset): Likewise.
3908         (Archive::read_all_symbols): Likewise.
3909         (Archive::read_symbols): Likewise.
3910         (Archive::get_elf_object_for_member): Remove input_objects
3911         parameter.  Add punconfigured parameter.  Change all callers.
3912         (Archive::add_symbols): Change return type to bool.  Check return
3913         value of include_member.
3914         (Archive::include_all_members): Likewise.
3915         (Archive::include_member): Change return type to bool.  Return
3916         false if first included object has incompatible target.  Set
3917         included_member_ field.
3918         (Add_archive_symbols::run): If add_symbols returns false, requeue
3919         Read_symbols task.
3920         * archive.h (class Archive): Add included_member_ field.
3921         Initialize it in constructor.  Add input_file and searched_for
3922         methods.  Update declarations.
3923         (class Add_archive_symbols): Add dirpath_, dirindex_, and
3924         input_argument_ fields.  Add them to constructor.  Change all
3925         callers.
3926         * script.cc: Include "target-select.h".
3927         (class Parser_closure): Add skip_on_incompatible_target_ and
3928         found_incompatible_target_ fields.  Add
3929         skip_on_incompatible_target parameter to constructor.  Change all
3930         callers.  Add methods skip_on_incompatible_target,
3931         clear_skip_on_incompatible_target, found_incompatible_target, and
3932         set_found_incompatible_target.
3933         (read_input_script): Add dirindex parameter.  Change all callers.
3934         If parser finds an incompatible target, requeue Read_symbols
3935         task.
3936         (script_set_symbol): Clear skip_on_incompatible_target in
3937         closure.
3938         (script_add_assertion, script_parse_option): Likewise.
3939         (script_start_sections, script_add_phdr): Likewise.
3940         (script_check_output_format): New function.
3941         * script.h (read_input_script): Update declaration.
3942         * script-c.h (script_check_output_format): Declare.
3943         * yyscript.y (file_cmd): Handle OUTPUT_FORMAT.
3944         (ignore_cmd): Remove OUTPUT_FORMAT.
3945         * fileread.cc (Input_file::Input_file): Add explicit this.
3946         (Input_file::will_search_for): New function.
3947         (Input_file::open): Add pindex parameter.  Change all callers.
3948         * fileread.h (class Input_file): Add input_file_argument method.
3949         Declare will_search_for.  Update declarations.
3950         * object.cc (make_elf_object): Add punconfigured parameter.
3951         Change all callers.
3952         * object.h (class Object): Make input_file public.  Add
3953         searched_for method.
3954         (make_elf_object): Update declaration.
3955         * dirsearch.cc (Dirsearch::find): Add pindex parameter.  Use it to
3956         restart search.
3957         * dirsearch.h (class Dirsearch): Update declaration.
3958         * options.h (class General_options): Add --warn-search-mismatch.
3959         * parameters.cc (Parameters::is_compatible_target): New function.
3960         * parameters.h (class Parameters): Declare is_compatible_target.
3961         * workqueue.cc (Workqueue::add_blocker): New function.
3962         * workqueue.h (class Workqueue): Declare add_blocker.
3963
3964         * fileread.cc (Input_file::open): Remove options parameter.
3965         Change all callers.
3966         (Input_file::open_binary): Likewise.
3967         * script.cc (read_input_script): Likewise.
3968         * readsyms.h (class Read_symbols): Remove options_ field.  Remove
3969         options parameter from constructor.  Change all callers.
3970         (class Read_script): Likewise.
3971         * fileread.h (class Input_file): Update declarations.
3972         * script.h (read_input_script): Update declaration.
3973
3974 2009-03-10  Nick Clifton  <nickc@redhat.com>
3975
3976         * po/es.po: New Spanish translation.
3977
3978 2009-03-06  Cary Coutant  <ccoutant@google.com>
3979
3980         * options.cc (parse_short_option): Keep dash_z from registering itself.
3981
3982 2009-03-03  Ian Lance Taylor  <iant@google.com>
3983
3984         PR 9918
3985         * target-reloc.h (relocate_section): Pass output_section to
3986         relocate.
3987         * i386.cc (Target_i386::should_apply_static_reloc): Add
3988         output_section parameter.  Change all callers.
3989         (Target_i386::Relocate::relocate): Add output_section parameter.
3990         * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
3991         * sparc.cc (Target_sparc::Relocate::relocate): Likewise.
3992         * powerpc.cc (Target_powerpc::Relocate::relocate): Likewise.
3993         * testsuite/two_file_shared.sh: New script.
3994         * testsuite/Makefile.am (check_SCRIPTS): Add two_file_shared.sh.
3995         (check_DATA): Add two_file_shared.dbg.
3996         (two_file_shared.dbg): New target.
3997         * testsuite/Makefile.in: Rebuild.
3998
3999 2009-03-01  Ian Lance Taylor  <iant@google.com>
4000
4001         * configure.ac: Check for byteswap.h.
4002         * configure: Rebuild.
4003         * config.in: Rebuild.
4004
4005 2009-03-01  Mikolaj Zalewski  <mikolajz@google.com>
4006
4007         * layout.cc (Layout::find_or_add_kept_section): New function.
4008         (Layout::add_comdat): Removed.
4009         * layout.h (struct Kept_section): Move out of class Layout.
4010         Remove trailing underscores from field names.  Add group_sections
4011         field.  Rename group_ field to is_group.  Change all uses.
4012         (class Layout): Declare find_or_add_kept_section, not add_comdat.
4013         * object.cc (Sized_relobj::Sized_relobj): Don't initialize
4014         comdat_groups_ field.
4015         (Sized_relobj::include_section_group): Use
4016         find_or_add_kept_section and Kept_section::group_sections.
4017         (Sized_relobj::include_linkonce_section): Likewise.
4018         * object.cc (class Sized_relobj): Don't define Comdat_group or
4019         Comdat_group_table.  Remove find_comdat_group and
4020         add_comdat_group.  Remove comdat_groups_ field.
4021         * plugin.cc (include_comdat_group): Use
4022         Layout::find_or_add_kept_section.
4023
4024 2009-02-28  Ian Lance Taylor  <iant@google.com>
4025
4026         * README: --gc-sections and map files are now supported.  Document
4027         some build requirements.
4028
4029         PR 6992
4030         * symtab.cc (Symbol_table::sized_write_section_symbol): In a
4031         relocatable link set the value of the section symbol to zero.
4032         * object.cc (Sized_relobj::do_finalize_local_symbols): In a
4033         relocatable link don't include the section address in the local
4034         symbol value.
4035
4036 2009-02-27  Ian Lance Taylor  <iant@google.com>
4037
4038         PR 6811
4039         * options.h (class Search_directory): Add is_system_directory.
4040         (class General_options): Declare is_in_system_directory.
4041         * options.cc (get_relative_sysroot): Make static.
4042         (get_default_sysroot): Make static.
4043         (General_optoins::is_in_system_directory): New function.
4044         * fileread.cc (Input_file::is_in_system_directory): New function.
4045         * fileread.h (class Input_file): Declare is_in_system_directory.
4046         * object.h (class Object): Add is_in_system_directory.
4047         (class Input_objects): Remove system_library_directory_ field.
4048         * object.cc (Input_objects::add_object): Don't set
4049         system_library_directory_.
4050         (input_objects::found_in_system_library_directory): Remove.
4051         * symtab.cc (Symbol_table::write_globals): Remove input_objects
4052         parameter.  Change all callers.
4053         (Symbol_table::sized_write_globals): Likewise.
4054         (Symbol_table::warn_about_undefined_dynobj_symbol): Likewise.
4055         Call Object::is_in_system_directory.
4056         * symtab.h (class Symbol_table): Update declarations.
4057
4058         PR 5990
4059         * descriptors.h (Open_descriptor): Add is_on_stack field.
4060         * descriptors.cc (Descriptors::open): If the descriptor is on the
4061         top of the stack, remove it.  Initialize is_on_stack field.
4062         (Descriptors::release): Only add pod to stack if it is not on the
4063         stack already.
4064         (Descriptors::close_some_descriptor): Clear stack_next and
4065         is_on_stack fields.
4066
4067         PR 7091
4068         * output.cc (Output_section::find_starting_output_address): Rename
4069         from starting_output_address; add PADDR parameter; change return
4070         type.
4071         * output.h (class Output_section): Declare
4072         find_starting_output_address instead of starting_output_address.
4073         * object.cc (Sized_relobj::do_finalize_local_symbols): Handle a
4074         section symbol for which we can't find a merge section.
4075
4076         PR 9836
4077         * symtab.cc (Symbol_table::add_from_object): If the visibility is
4078         hidden or internal, force the symbol to be local.
4079         * resolve.cc (Symbol::override_visibility): Define.
4080         (Symbol::override_base): Use override_visibility.
4081         (Symbol_table::resolve): Likewise.
4082         (Symbol::override_base_with_special): Likewise.
4083         (Symbol_table::override_with_special): If the visibility is hidden
4084         or internal, force the symbol to be local.
4085         * symtab.h (class Symbol): Add set_visibility and
4086         override_visibility.
4087         * testsuite/ver_test_1.sh: New file.
4088         * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh.
4089         (check_DATA): Add ver_test_1.syms.
4090         (ver_test_1.syms): New target.
4091         * testsuite/Makefile.in: Rebuild.
4092
4093 2009-02-25  Cary Coutant  <ccoutant@google.com>
4094
4095         * layout.cc (Layout::choose_output_section): Don't rename sections
4096         when using a linker script that has a SECTIONS clause.
4097         * Makefile.in: Regenerate.
4098
4099         * testsuite/Makefile.am (script_test_5.sh): New test case.
4100         * testsuite/Makefile.in: Regenerate.
4101         * testsuite/script_test_5.cc: New file.
4102         * testsuite/script_test_5.sh: New file.
4103         * testsuite/script_test_5.t: New file.
4104
4105 2009-02-13  Rafael Avila de Espindola  <espindola@google.com>
4106
4107         * archive.cc (Archive::include_member): Update calls to add_symbols.
4108         * dynobj.cc (Sized_dynobj<size, big_endian>::make_version_map): Add
4109         the Layout argument.
4110         * dynobj.h (do_add_symbols): Add the Layout argument.
4111         * object.cc (Sized_relobj<size, big_endian>::do_add_symbols): Add the
4112         Layout argument.
4113         * object.h (Object::add_symbols): Add the Layout argument.
4114         (Object::do_add_symbols): Add the Layout argument.
4115         (Sized_relobj::do_add_symbols): Add the Layout argument.
4116         * plugin.cc (Sized_pluginobj<size, big_endian>::do_add_symbols):
4117         Unify the two versions.
4118         (Add_plugin_symbols): Remove.
4119         * plugin.h (Pluginobj::add_symbols, Pluginobj::do_add_symbols): Remove.
4120         (Sized_pluginobj::do_add_symbols): Unify the two versions.
4121         (Add_plugin_symbols): Remove.
4122         * readsyms.cc (Read_symbols::do_read_symbols): Update call to
4123         Add_symbols. Use Add_symbols instead of Add_plugin_symbols.
4124         (Add_symbols::run): Make it work with Pulginobj.
4125
4126 2009-02-06  Ian Lance Taylor  <iant@google.com>
4127
4128         * object.cc (Sized_relobj::do_layout): Make info message start
4129         with lower case letter.
4130
4131 2009-02-06  Mikolaj Zalewski  <mikolajz@google.com>
4132
4133         * binary.cc: Fix file comment.
4134
4135         * options.h (enum Incremental_disposition): Define.
4136         (class General_options): Add new options: --incremental,
4137         --incremental_changed, --incremental_unchanged,
4138         --incremental_unknown.  Add incremental_disposition_ and
4139         implicit_incremental_ fields.
4140         (General_options::incremental_disposition): New function.
4141         (class Position_dependent_options): Add incremental_disposition
4142         option.
4143         (Position_dependent_options::copy_from_options): Set incremental
4144         dispositions.
4145         * options.cc (General_options::parse_incremental_changed): New
4146         function.
4147         (General_options::parse_incremental_unchanged): New function.
4148         (General_options::parse_incremental_unknown): New function.
4149         (General_options::General_options): Initialize new fields
4150         incremental_disposition_ and implicit_incremental_.
4151         (General_options::finalize): Check for uasge of --incremental-*
4152         without --incremental.
4153
4154 2009-02-06  Chris Demetriou  <cgd@google.com>
4155
4156         * gold.h (gold_undefined_symbol): Change to take only a Symbol
4157         pointer and to report location as the file name associated with
4158         the symbol.
4159         (gold_undefined_symbol_at_location): New function to replace the
4160         old gold_undefined_symbol functionality.
4161         * target-reloc.h (relocate_section): Update to use
4162         gold_undefined_symbol_at_location.
4163         * symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
4164         Call gold_undefined_symbol function rather than gold_error.
4165         * errors.h (Errors::undefined_symbol): Take location as a
4166         string, rather than calculating it from a relocation.
4167         * errors.cc (Errors::fatal): Print "fatal error:" before the
4168         formatted message.
4169         (Errors::error, Errors::error_at_location): Print "error: "
4170         before the formatted message.
4171         (Errors::undefined_symbol): Take location as a string, rather
4172         than calculating it from a relocation.
4173         (gold_undefined_symbol_at_location): New function akin to
4174         old gold_undefined_symbol, calculates location from relocation.
4175         (gold_undefined_symbol): Change to take only a Symbol pointer
4176         and to report location as the file name associated with the symbol.
4177         * testsuite/debug_msg.sh: Update for changed error messages.
4178         * testsuite/undef_symbol.sh: Likewise.
4179
4180 2009-02-04  Duncan Sands  <baldrick@free.fr>
4181
4182         PR 9812
4183         * reduced_debug_output.h
4184         (Output_reduced_debug_abbrev_section::failed): Use format for
4185         gold_warning.
4186         (Output_reduced_debug_info_section::faild): Likewise.
4187
4188 2009-01-31  Mikolaj Zalewski  <mikolajz@google.com>
4189
4190         * script.cc (Lazy_demangler): New class.
4191         (Version_script_info::get_symbol_version_helper): Demangle a
4192         symbol only once.
4193
4194 2009-01-29  Cary Coutant  <ccoutant@google.com>
4195
4196         * i386.cc (Target_i386::Relocate::relocate): Recognize non-PIC calls
4197         to __tls_get_addr.
4198         * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
4199
4200 2009-01-28  Ian Lance Taylor  <iant@google.com>
4201
4202         * version.cc (version_string): Bump to 1.9.
4203
4204         * gold.h: Include <cstring> and <stdint.h>.
4205         * version.cc: Include <cstdio>.
4206         * object.cc (Sized_relobj::do_layout): Initialize gc_sd to avoid a
4207         warning.
4208         * reduced_debug_output.cc (insert_into_vector): Rename from
4209         Insert_into_vector; change all callers.  Use Swap_unaligned to
4210         avoid aliasing issue; remove union since it is unnecessary.
4211
4212 2009-01-27  Sriraman Tallam  <tmsriram@google.com>
4213
4214         * Makefile.am (CCFILES): Add gc.cc.
4215         (HFILES): Add gc.h.
4216         * Makefile.in: Regenerate.
4217         * gold.cc (Gc_runner): New class.
4218         (queue_initial_tasks): Call garbage collection related tasks
4219         when corresponding options are invoked.
4220         (queue_middle_gc_tasks): New function.
4221         (queue_middle_tasks): Reorder tasks to allow relocs to be read and
4222         processed early before laying out sections during garbage collection.
4223         * gold.h (queue_middle_gc_tasks): New function.
4224         (is_prefix_of): Move from "layout.cc".
4225         * i386.cc (Target_i386::gc_process_relocs): New function.
4226         * layout.cc (is_prefix_of): Remove. Move to "gold.h"
4227         * main.cc (main): Create object of class "Garbage_collection".
4228         * object.cc (Relobj::copy_symbols_data): New function.
4229         (Relobj::is_section_name_included): New function.
4230         (Sized_relobj::do_layout): Allow this function to be called twice 
4231         during garbage collection and defer layout of section during the 
4232         first call.
4233         * object.h (Relobj::get_symbols_data): New function.
4234         (Relobj::is_section_name_included): New function.
4235         (Relobj::copy_symbols_data): New function.
4236         (Relobj::set_symbols_data): New function.
4237         (Relobj::get_relocs_data): New function.
4238         (Relobj::set_relocs_data): New function.
4239         (Relobj::is_output_section_offset_invalid): New pure virtual function.
4240         (Relobj::gc_process_relocs): New function.
4241         (Relobj::do_gc_process_relocs): New pure virtual function.
4242         (Relobj::sd_): New data member.
4243         (Sized_relobj::is_output_section_offset_invalid): New function.
4244         (Sized_relobj::do_gc_process_relocs): New function.
4245         * options.h (General_options::gc_sections): Modify to not be a no-op.
4246         (General_options::print_gc_sections): New option.
4247         * plugin.cc (Plugin_finish::run): Remove function call to
4248         Plugin_manager::layout_deferred_objects.  Move it to "gold.cc".
4249         * powerpc.cc (Target_powerpc::gc_process_relocs): New function.
4250         * reloc.cc (Read_relocs::run): Add task to process relocs and
4251         determine unreferenced sections when doing garbage collection.
4252         (Gc_process_relocs): New class.
4253         (Sized_relobj::do_gc_process_relocs): New function.
4254         (Sized_relobj::do_scan_relocs): Don't try to scan the relocs for
4255         sections that are garbage collected.
4256         * reloc.h (Gc_process_relocs): New class.
4257         * sparc.cc (Target_sparc::gc_process_relocs): New function.
4258         * symtab.cc (Symbol::should_add_dynsym_entry): Do not add entries for
4259         symbols whose corresponding sections are garbage collected.
4260         (Symbol_table::Symbol_table): Add new parameter for the garbage
4261         collection object.
4262         (Symbol_table::gc_mark_undef_symbols): New function.
4263         (Symbol_table::gc_mark_symbol_for_shlib): New function.
4264         (Symbol_table::gc_mark_dyn_syms): New function.
4265         (Symbol_table::resolve): Do not treat symbols seen in dynamic objects
4266         as garbage.
4267         (Symbol_table::add_from_object): Likewise.
4268         (Symbol_table::add_from_relobj): When building shared objects, do not
4269         treat externally visible symbols as garbage.
4270         (Symbol_table::sized_finalize_symbol): Do not check dynamic symbol
4271         table information for static and relocatable links.
4272         * symtab.h (Symbol_table::set_gc): New function.
4273         (Symbol_table::gc): New function.
4274         (Symbol_table::gc_mark_undef_symbols): New function.
4275         (Symbol_table::gc_mark_symbol_for_shlib): New function.
4276         (Symbol_table::gc_mark_dyn_syms): New function.
4277         (Symbol_table::gc_): New data member.
4278         * target.h (Sized_target::gc_process_relocs): New pure virtual 
4279         function.
4280         * x86_64.cc (Target_x86_64::gc_process_relocs): New function.
4281         * testsuite/testfile.cc (Target_test::gc_process_relocs): New function.
4282
4283 2009-01-20  Chris Faylor <me.sourceware@sourceware.org>
4284
4285         * options.h (General_options::gc_sections): Define as a no-op for now.
4286         (General_options::no_keep_memory): Ditto.
4287         (General_options::Bshareable): Define.
4288         * options.cc (General_options::finalize): Honor -Bshareable.
4289
4290 2009-01-20  Andreas Schwab  <schwab@suse.de>
4291
4292         * powerpc.cc (Powerpc_relocate_functions::rel16_ha): Don't try to
4293         read the value in the contents, since we don't use it.  Use the
4294         template endianness when writing.
4295         (Relocate::relocate): Use it for R_PPC_REL16_HA.
4296
4297 2009-01-19  Andreas Schwab  <schwab@suse.de>
4298
4299         * configure.tgt (powerpc64-*): Fix targ_obj.
4300
4301 2009-01-15  Ian Lance Taylor  <iant@google.com>
4302
4303         * object.cc (Sized_relobj::write_local_symbols): Don't write out
4304         local symbols when stripping all symbols.
4305
4306 2009-01-14  Cary Coutant  <ccoutant@google.com>
4307
4308         * output.cc (Output_reloc): Add explicit instantiations.
4309
4310 2009-01-14  Cary Coutant  <ccoutant@google.com>
4311
4312         * archive.cc (Archive::get_elf_object_for_member): Remove call
4313         to File_read::claim_for_plugin.
4314         * descriptors.cc (Descriptors::open): Remove reference to
4315         is_claimed.
4316         (Descriptors::claim_for_plugin): Remove.
4317         * descriptors.h (Descriptors::claim_for_plugin): Remove.
4318         (Descriptors::is_claimed): Remove.
4319         (claim_descriptor_for_plugin): Remove.
4320         * fileread.cc (File_read::claim_for_plugin): Remove.
4321         * fileread.h (File_read::claim_for_plugin): Remove.
4322         (File_read::descriptor): Reopen descriptor if necessary.
4323         * plugin.cc  (Plugin::load): Add two new APIs to transfer vector.
4324         (Plugin_manager::all_symbols_read): Add task parameter. Change
4325         all callers.
4326         (Plugin_manager::get_input_file): New function.
4327         (Plugin_manager::release_input_file): New function.
4328         (Pluginobj::Pluginobj): Add filesize parameter and initialize
4329         corresponding data member.
4330         (Sized_pluginobj::Sized_pluginobj): Add filesize parameter
4331         and pass to base constructor. Change all callers.
4332         (get_input_file, release_input_file): New functions.
4333         (make_sized_plugin_object): Add filesize parameter. Change all callers.
4334         * plugin.h (Plugin_manager::Plugin_manager): Initialize task_ member.
4335         (Plugin_manager::all_symbols_read): Add task parameter.
4336         (Plugin_manager::get_input_file): New function.
4337         (Plugin_manager::release_input_file): New function.
4338         (Plugin_manager::task_): New data member.
4339         (Pluginobj::Pluginobj): Add filesize parameter.
4340         (Pluginobj::filename): New function.
4341         (Pluginobj::descriptor): New function.
4342         (Pluginobj::filesize): New function.
4343         (Pluginobj::filesize_): New data member.
4344         (Sized_pluginobj::Sized_pluginobj): Add filesize parameter.
4345         * readsyms.cc (Read_symbols::do_read_symbols): Remove call to
4346         File_read::claim_for_plugin; use Object::unlock to unlock the file.
4347
4348         * testsuite/Makefile.am (plugin_test_4): New test case for plugins
4349         with archive libraries.
4350         * testsuite/Makefile.in: Regenerate.
4351         * testsuite/plugin_test.c (struct sym_info): New type.
4352         (get_input_file, release_input_file): New static variables.
4353         (onload): Capture new transfer vector entries.
4354         (claim_file_hook): Stop reading at end of file according to filesize.
4355         Factor out parsing of readelf output into separate function.
4356         (all_symbols_read_hook): Exercise get_input_file and release_input_file
4357         APIs and get the source file name from the symbol table.  Convert
4358         source file name to corresponding object file name.  Print info
4359         message when adding new input files.
4360         (parse_readelf_line): New function.
4361         * testsuite/plugin_test_1.sh: Add checks for new info messages.
4362         * testsuite/plugin_test_2.sh: Likewise.
4363         * testsuite/plugin_test_3.sh: Likewise.
4364         * testsuite/plugin_test_4.sh: New test case.
4365
4366 2009-01-07  Ian Lance Taylor  <iant@google.com>
4367
4368         * version.cc (version_string): Bump to 1.8.
4369
4370 2008-12-23  Cary Coutant  <ccoutant@google.com>
4371
4372         * gold.cc (gold_exit): Call plugin cleanup handlers on exit.
4373         * plugin.cc (Plugin_manager::finish): Rename as
4374         layout_deferred_objects.  Move cleanup to separate function.
4375         (Plugin_manager::cleanup): New function.
4376         (Plugin_finish::run): Call layout_deferred_objects and cleanup
4377         separately.
4378         * plugin.h (Plugin_manager::finish): Rename as
4379         layout_deferred_objects.
4380         (Plugin_manager::cleanup): New function.
4381         (Plugin_manager::cleanup_done): New field.
4382
4383 2008-12-23  Cary Coutant  <ccoutant@google.com>
4384
4385         * plugin.cc (is_visible_from_outside): New function.
4386         (Pluginobj::get_symbol_resolution_info): Call is_visible_from_outside
4387         so we don't return "IR only" status for exported symbols or -r links.
4388
4389         * testsuite/Makefile.am (plugin_test_3): New test case.
4390         * testsuite/Makefile.in: Regenerate.
4391         * testsuite/plugin_test_3.sh: New file.
4392
4393 2008-12-22  Cary Coutant  <ccoutant@google.com>
4394
4395         * object.cc (Sized_relobj::layout_section): New function.
4396         (Sized_relobj::do_layout): Defer layout of input sections until after
4397         plugin has provided replacement files.
4398         (Sized_relobj::do_layout_deferred_sections): New function.
4399         * object.h (Relobj::set_section_offset): Remove virtual keyword.
4400         (Relobj::layout_deferred_sections): New function.
4401         (Relobj::do_layout_deferred_sections): New function.
4402         (Sized_relobj::do_layout_deferred_sections): New function.
4403         (Sized_relobj::layout_section): New function.
4404         (Sized_relobj::Deferred_layout): New structure.
4405         (Sized_relobj::deferred_layout_): New field.
4406         * plugin.cc (Plugin_manager::finish): Renamed, was cleanup.
4407         Change all callers.  Layout deferred sections.
4408         (class Plugin_finish): Renamed, was Plugin_cleanup.  Change all
4409         references.
4410         (Plugin_hook::run): Move code from do_plugin_hook inline.
4411         (Plugin_hook::do_plugin_hook): Remove.
4412         * plugin.h (Plugin_manager::Plugin_manager): Add missing initializers.
4413         (Plugin_manager::finish): Renamed, was cleanup.
4414         (Plugin_manager::should_defer_layout): New function.
4415         (Plugin_manager::add_deferred_layout_object): New function.
4416         (Plugin_manager::Deferred_layout_list): New type.
4417         (Plugin_manager::deferred_layout_objects_): New field.
4418         (Plugin_hook::do_plugin_hook): Remove.
4419
4420 2008-12-17  Ian Lance Taylor  <iant@google.com>
4421
4422         * options.h (class General_options): Add --no case for
4423         --export-dynamic.
4424
4425 2008-12-16  Cary Coutant  <ccoutant@google.com>
4426
4427         * plugin.cc (Plugin::load): Move LDPT_MESSAGE to front of transfer
4428         vector.
4429         (Plugin_manager::claim_file): Create plugin object even if
4430         plugin did not call the add_symbols callback.
4431         (Plugin_obj::get_symbol_resolution_info): Guard against plugin
4432         asking for more symbols than were added.
4433         * testsuite/Makefile.am (plugin_test_1): Add test case with
4434         no global symbols.
4435         (empty.syms): New target.
4436         * testsuite/Makefile.in: Regenerate.
4437         * testsuite/plugin_test.c (claim_file_hook): Add new debug
4438         message. Don't call add_symbols if no globals.
4439         (all_symbols_read_hook): Don't provide replacement for empty
4440         claimed file.
4441
4442 2008-12-12  Ian Lance Taylor  <iant@google.com>
4443
4444         * target-reloc.h (Default_scan_relocatable_relocs): Only discard
4445         r_type == 0 for a local symbol with r_sym == 0.
4446         (scan_relocatable_relocs): Pass r_sym to
4447         local_non_section_strategy.
4448         * reloc.cc (Emit_relocs_strategy::local_non_section_strategy): Add
4449         r_sym parameter.
4450
4451         * configure.ac: Update test for TLS descriptors: they are
4452         supported as of glibc 2.9.
4453         * configure: Rebuild.
4454
4455 2008-12-11  Ian Lance Taylor  <iant@google.com>
4456
4457         PR 7091
4458         * target-reloc.h (Default_scan_relocatable_relocs): For each
4459         function, map r_type == 0 to RELOC_DISCARD.
4460
4461 2008-12-10  Cary Coutant  <ccoutant@google.com>
4462
4463         * layout.cc (Layout::add_comdat): Allow COMDAT group from a replacement
4464         object to override a kept COMDAT group from a plugin object.
4465
4466 2008-12-09  Ian Lance Taylor  <iant@google.com>
4467
4468         PR 7088
4469         * yyscript.y (file_cmd): Handle INPUT.
4470
4471         * testsuite/initpri1.c: Change all declarations to be full
4472         prototypes by adding void, to avoid compiler warnings.
4473
4474 2008-12-05  Rafael Avila de Espindola  <espindola@google.com>
4475
4476         * options.cc (General_options::parse_plugin_opt): New.
4477         (General_options::add_plugin): The argument now is just the filename.
4478         (General_options::add_plugin_option): New.
4479         * options.h (plugin_opt): New.
4480         (add_plugin): Change argument name.
4481         (add_plugin_option): New.
4482         * plugin.cc (Plugin::load): Don't parse the plugin option.
4483         * plugin.h (Plugin::Plugin): Rename argument. Init filename_.
4484         (Plugin::add_option): New.
4485         (Plugin::args_): Change type.
4486         (Plugin::filename_): New.
4487         (Plugin_manager::add_plugin_option): New.
4488         * testsuite/Makefile.am (plugin_test_1): Use new syntax.
4489         * testsuite/Makefile.in: Regenerate.
4490
4491 2008-12-05  Cary Coutant  <ccoutant@google.com>
4492
4493         * layout.cc (Layout::include_section): Check for SHF_EXCLUDE.
4494         Handle --strip-lto-sections option.
4495         * options.h (strip_lto_sections): New option.
4496
4497 2008-12-01  Cary Coutant  <ccoutant@google.com>
4498
4499         * plugin.cc (ld_plugin_message): Change format parameter to const.
4500         Fix mismatch between new[] and delete.
4501
4502 2008-11-14  Cary Coutant  <ccoutant@google.com>
4503
4504         * reloc.cc (Sized_relobj::do_read_relocs): Use constant invalid_address
4505         instead of -1U.
4506
4507 2008-11-05  Craig Silverstein  <csilvers@google.com>
4508
4509         * options.cc (General_options::parse_dynamic_list): New function.
4510         * options.h (General_options): New flags dynamic_list,
4511         dynamic_list_data, dynamic_list_cpp_new, and
4512         dynamic_list_cpp_typeinfo.  New variable dynamic_list_.
4513         (General_options::in_dynamic_list): New function.
4514         * script.cc (Lex::Mode): New enum DYNAMIC_LIST.
4515         (Lex::can_start_name): Add support for DYNAMIC_LIST mode.
4516         (Lex::can_continue_name): Likewise.
4517         (yylex): Likewise.
4518         (read_script_file): New parameter script_options.
4519         (read_dynamic_list): New function.
4520         (Script_options::define_dynamic_list): New function.
4521         (dynamic_list_keyword_parsecodes): New variable.
4522         (dynamic_list_keywords): New variable.
4523         * script.h (Script_options::define_dynamic_list): New function
4524         prototype.
4525         (read_dynamic_list): New function prototype.
4526         * symtab.cc (strprefix): New macro.
4527         (Symbol::should_add_dynsym_entry): Support dynamic_list,
4528         dynamic_list_data, dynamic_list_cpp_new, and
4529         dynamic_list_cpp_typeinfo.
4530         * yyscript.y (PARSING_DYNAMIC_LIST): New token.
4531         (dynamic_list_expr): New rule.
4532         (dynamic_list_nodes): Likewise.
4533         (dynamic_list_node): Likewise.
4534         * testsuite/Makefile.am (dynamic_list): New test.
4535         * testsuite/Makefile.in: Regenerated.
4536         * testsuite/dynamic_list.t: New file.
4537         * testsuite/dynamic_list.sh: New file.
4538
4539 2008-11-05  Craig Silverstein  <csilvers@google.com>
4540
4541         * testsuite/tls_test_c.c: Add prototype for t11 and t11_last.
4542         * testsuite/tls_test_c.c (t11): Add explicit "void" to prototype.
4543         (t11_last): Likewise.
4544         * testsuite/ver_test_6.c (main): Likewise.
4545
4546 2008-10-07  Cary Coutant  <ccoutant@google.com>
4547
4548         * options.c (General_options::finalize): Add check for -static and
4549         -shared.
4550         * gold.cc (queue_middle_tasks): Assert that list of dynamic objects
4551         is not empty.
4552
4553 2008-10-02  Cary Coutant  <ccoutant@google.com>
4554
4555         * plugin.cc (make_sized_plugin_object): Fix conditional
4556         compilation to work when not all targets are enabled.
4557
4558 2008-09-29  Cary Coutant  <ccoutant@google.com>
4559
4560         * archive.cc (Archive::get_file_and_offset): Use filename instead
4561         of name to get library path.
4562         (Archive::include_member): Unlock external member of a thin archive.
4563
4564         * testsuite/Makefile.am (TEST_AR): New variable.
4565         (thin_archive_test_1): New test.
4566         (thin_archive_test_2): New test.
4567         * testsuite/Makefile.in: Regenerate.
4568         * testsuite/thin_archive_main.cc: New file.
4569         * testsuite/thin_archive_test_1.cc: New file.
4570         * testsuite/thin_archive_test_2.cc: New file.
4571         * testsuite/thin_archive_test_3.cc: New file.
4572         * testsuite/thin_archive_test_4.cc: New file.
4573
4574 2008-09-29  Cary Coutant  <ccoutant@google.com>
4575
4576         * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.
4577         * object.cc (Sized_relobj::do_layout): Use constant invalid_address
4578         instead of -1U.
4579         (Sized_relobj::do_finalize_local_symbols): Likewise.
4580         (Sized_relobj::map_to_kept_section): Likewise.
4581         * object.h (Sized_relobj::invalid_address): New constant.
4582         (Sized_relobj::do_output_section_offset): Check for invalid_address
4583         and return -1ULL.
4584         * output.cc (Output_reloc::local_section_offset): Use constant
4585         invalid_address instead of -1U.
4586         (Output_reloc::get_address): Likewise.
4587         (Output_section::output_address): Change -1U to -1ULL.
4588         * output.h (Output_reloc::invalid_address): New constant.
4589         * reloc.cc (Sized_relobj::write_sections): Use constant
4590         invalid_address instead of -1U.
4591         (Sized_relobj::relocate_sections): Likewise.
4592         * symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
4593         values for merge sections.
4594         * target-reloc.h (relocate_for_relocatable): Use constant
4595         invalid_address instead of -1U.
4596
4597 2008-09-19  Cary Coutant  <ccoutant@google.com>
4598
4599         Add plugin functionality for link-time optimization (LTO).
4600         * configure.ac (plugins): Add --enable-plugins option.
4601         * configure: Regenerate.
4602         * config.in: Regenerate.
4603         * Makefile.am (LIBDL): New variable.
4604         (CCFILES): Add plugin.cc.
4605         (HFILES): Add plugin.h.
4606         (ldadd_var): Add LIBDL.
4607         * Makefile.in: Regenerate.
4608
4609         * archive.cc: Include "plugin.h".
4610         (Archive::setup): Don't preread archive symbols when using a plugin.
4611         (Archive::get_file_and_offset): Add memsize parameter.  Change callers.
4612         (Archive::get_elf_object_for_member): Call plugin hooks for claiming
4613         files.
4614         (Archive::include_member): Add symbols from plugin objects.
4615         * archive.h (Archive::get_file_and_offset): Add memsize parameter.
4616         * descriptors.cc (Descriptors::open): Check for file descriptors
4617         abandoned by plugins.
4618         (Descriptors::claim_for_plugin): New function.
4619         * descriptors.h (Descriptors::claim_for_plugin): New function.
4620         (Open_descriptor::is_claimed): New field.
4621         (claim_descriptor_for_plugin): New function.
4622         * fileread.cc (File_read::claim_for_plugin): New function.
4623         * fileread.h (File_read::claim_for_plugin): New function.
4624         (File_read::descriptor): New function.
4625         * gold.cc: Include "plugin.h".
4626         (queue_initial_tasks): Add task to call plugin hooks for generating
4627         new object files.
4628         * main.cc: Include "plugin.h".
4629         (main): Load plugin libraries.
4630         * object.h (Pluginobj): Declare.
4631         (Object::pluginobj): New function.
4632         (Object::do_pluginobj): New function.
4633         (Object::set_target): New function.
4634         * options.cc: Include "plugin.h".
4635         (General_options::parse_plugin): New function.
4636         (General_options::General_options): Initialize plugins_ field.
4637         (General_options::add_plugin): New function.
4638         * options.h (Plugin_manager): Declare.
4639         (General_options): Add --plugin option.
4640         (General_options::has_plugins): New function.
4641         (General_options::plugins): New function.
4642         (General_options::add_plugin): New function.
4643         (General_options::plugins_): New field.
4644         * plugin.cc: New file.
4645         * plugin.h: New file.
4646         * readsyms.cc: Include "plugin.h".
4647         (Read_symbols::do_read_symbols): Check for archive before checking
4648         for ELF file.  Call plugin hooks to claim files.
4649         * resolve.cc (Symbol_table::resolve): Record when symbol is referenced
4650         from a real object file; force override when processing replacement
4651         files.
4652         * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field.
4653         (Symbol::init_base_object): Likewise.
4654         (Symbol::init_base_output_data): Likewise.
4655         (Symbol::init_base_output_segment): Likewise.
4656         (Symbol::init_base_constant): Likewise.
4657         (Symbol::init_base_undefined): Likewise.
4658         (Symbol::output_section): Assert that object is not a plugin.
4659         (Symbol_table::add_from_pluginobj): New function.
4660         (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as
4661         undefined.
4662         (Symbol_table::sized_write_globals): Likewise.
4663         (Symbol_table::add_from_pluginobj): Instantiate template.
4664         * symtab.h (Sized_pluginobj): Declare.
4665         (Symbol::in_real_elf): New function.
4666         (Symbol::set_in_real_elf): New function.
4667         (Symbol::in_real_elf_): New field.
4668         (Symbol_table::add_from_pluginobj): New function.
4669
4670         * testsuite/Makefile.am (AM_CFLAGS): New variable.
4671         (LIBDL): New variable.
4672         (LDADD): Add LIBDL.
4673         (check_PROGRAMS): Add plugin_test_1 and plugin_test_2.
4674         (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh.
4675         (check_DATA): Add plugin_test_1.err and plugin_test_2.err.
4676         (MOSTLYCLEANFILES): Likewise.
4677         * testsuite/Makefile.in: Regenerate.
4678         * testsuite/plugin_test.c: New file.
4679         * testsuite/plugin_test_1.sh: New file.
4680         * testsuite/plugin_test_2.sh: New file.
4681
4682 2008-09-16  Ian Lance Taylor  <iant@google.com>
4683
4684         * target-reloc.h (relocate_section): Check whether a symbol is
4685         defined by the ABI before reporting an undefined symbol error.
4686         * target.h (Target::is_defined_by_abi): Make parameter const.
4687         (Target::do_is_defined_by_abi): Likewise.
4688         * i386.cc (Target_i386::do_is_defined_by_abi): Likewise.
4689         * powerpc.cc (Target_powerpc::do_is_defined_by_abi): Likewise.
4690         * sparc.cc (Target_sparc::do_is_defined_by_abi): Likewise.
4691         * x86_64.cc (Target_x86_64::do_is_defined_by_abi): Likewise.
4692         * testsuite/Makefile.am (tls_test_shared.so): Add -Wl,-z,defs.
4693         * testsuite/Makefile.in: Rebuild.
4694
4695         * fileread.cc (make_view): Add casts to avoid warning.
4696
4697 2008-09-16  Alexandre Oliva  <aoliva@redhat.com>
4698
4699         * i386.cc (Target_i386::define_tls_base_symbol): Update comments.
4700         * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
4701
4702 2008-09-16  Alexandre Oliva  <aoliva@redhat.com>
4703
4704         * options.h (General_options::output_is_executable): New.
4705         (General_options::output_is_pie): New.
4706         * i386.cc (Target_i386::define_tls_base_symbol): Use SEGMENT_START
4707         for shared libraries.
4708         * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
4709
4710 2008-09-11  Chris Demetriou  <cgd@google.com>
4711
4712         * options.h (origin): New -z option.
4713         * layout.cc (Layout:finish_dynamic_section): If "-z origin"
4714         is specified, set DF_ORIGIN in DT_FLAGS and set DF_1_ORIGIN
4715         in DT_FLAGS_1.
4716
4717 2008-09-05  Cary Coutant  <ccoutant@google.com>
4718
4719         * fileread.cc (File_read::make_view): Add check for attempt to map
4720         beyond end of file.
4721
4722 2008-09-05  Cary Coutant  <ccoutant@google.com>
4723
4724         * symtab.cc (Symbol_table::add_from_dynobj): Fix typos in
4725         explicit instantiations.
4726
4727 2008-08-28  Kris Van Hees  <kris.van.hees@oracle.com>
4728
4729         PR gold/6858
4730         * options.cc (General_options::finalize): Allow undefined symbols
4731         in shlibs if linking -shared.
4732
4733         PR gold/6859
4734         * symtab.cc (Symbol::init_base_undefined): Mark explicitly undefined
4735         symbols as not needing a dynsym entry.
4736
4737 2008-08-20  Craig Silverstein  <csilvers@google.com>
4738
4739         * fileread.cc (File_read::open): Do not lock the file unless it
4740         was successfully opened.
4741
4742 2008-08-14  Cary Coutant  <ccoutant@google.com>
4743
4744         * x86_64.cc (Target_x86_64::Relocate::relocat_tls):
4745         Use addend for DTPOFF32, DTPOFF64, and TPOFF32 relocs.
4746         * testsuite/tls_test.cc (struct int128): 128-bit struct
4747         for testing TLS relocs with non-zero addend.
4748         (v12): New TLS variable.
4749         (t12): New test.
4750         (t_last): Add check for v12.
4751         * testsuite/tls_test.h (t12): New function.
4752         * testsuite/tls_test_main.cc (thread_routine): Call new test.
4753
4754 2008-08-13  Ian Lance Taylor  <iant@google.com>
4755
4756         * layout.cc (Layout::attach_allocated_section_to_segment): Don't
4757         set tls_segment_ or relro_segment_.
4758         (Layout::make_output_segment): Set tls_segment_ and relro_segment_
4759         when appropriate.
4760         * output.h (Output_section::clear_is_relro): New function.
4761         * output.cc (Output_segment::add_output_section): Handle SHF_TLS
4762         sections specially even when output_data_ is empty.
4763         (Output_segment::maximum_alignment): When first section is relro,
4764         only force alignment for PT_LOAD segments.
4765         * script.cc (script_data_segment_align): New function.
4766         (script_data_segment_relro_end): New function.
4767         * script-c.h (script_data_segment_align): Declare.
4768         (script_data_segment_relro_end): Declare.
4769         * script-sections.h (class Script_sections): Declare
4770         data_segment_align and data_segment_relro_end.  Add fields
4771         segment_align_index_ and saw_relro_end_.
4772         * script-sections.cc (class Sections_element): Add set_is_relro
4773         virtual function.  Add new bool* parameter to place_orphan_here.
4774         Add get_output_section virtual function.
4775         (class Output_section_definition): Add set_is_relro.  Add new
4776         bool* parameter to place_orphan_here.  Add get_output_section.
4777         Add is_relro_ field.
4778         (Output_section_definition::Output_section_definition): Initialize
4779         evaluated_address_, evaluated_load_address, evaluated_addralign_,
4780         and is_relro_ fields.
4781         (Output_section_definition::place_orphan_here): Add is_relro
4782         parameter.
4783         (Output_section_definition::set_section_addresses): Set relro for
4784         output section.
4785         (Output_section_definition::alternate_constraint): Likewise.
4786         (class Orphan_output_section): Add new bool* parameter to
4787         place_orphan_here.  Add get_output_section.
4788         (Orphan_output_section::place_orphan_here): Add is_relro
4789         parameter.
4790         (Script_sections::Script_sections): Initialize
4791         data_segment_align_index_ and saw_relro_end_.
4792         (Script_sections::data_segment_align): New function.
4793         (Script_sections::data_segment_relro_end): New function.
4794         (Script_sections::place_orphan): Set or clear is_relro.
4795         (Script_sections::set_section_addresses): Force alignment of first
4796         TLS section.
4797         * yyscript.y (exp): Call script_data_segment_align and
4798         script_data_segment_relro_end.
4799         * testsuite/relro_script_test.t: New file.
4800         * testsuite/relro_test.cc (using_script): Declare.
4801         (t1, t2): Test using_script.
4802         * testsuite/Makefile.am (check_PROGRAMS): Add relro_script_test.
4803         (relro_script_test_SOURCES): Define.
4804         (relro_script_test_DEPENDENCIES): Define.
4805         (relro_script_test_LDFLAGS): Define.
4806         (relro_script_test_LDADD): Define.
4807         (relro_script_test.so): New target.
4808         * testsuite/Makefile.in: Rebuild.
4809
4810 2008-08-06  Cary Coutant <ccoutant@google.com>
4811
4812         * archive.cc (Archive::total_archives, Archive::total_members)
4813         (Archive::total_members_loaded): New variables.
4814         (Archive::setup): Add parameter.  Add option to preread
4815         archive symbols.
4816         (Archive::read_armap): Add counter.
4817         (Archive::get_file_and_offset): New function.
4818         (Archive::get_elf_object_for_member): New function.
4819         (Archive::read_all_symbols): New function.
4820         (Archive::read_symbols): New function.
4821         (Archive::add_symbols): Add counters.
4822         (Archive::include_all_members): Use armap to find members if it's
4823         already built.
4824         (Archive::include_member): Skip reading symbols if already read.
4825         Factored code into Archive::get_file_and_offset and
4826         Archive::get_elf_object_for_member.  Changed call to
4827         Mapfile::report_include_archive_member.
4828         (Archive::print_stats): New function.
4829         * archive.h: Declare Object and Read_symbols_data classes.
4830         (Archive::Archive): Add initializers for new members.
4831         (Archive::setup): Add parameter.
4832         (Archive::print_stats): New function.
4833         (Archive::total_archives, Archive::total_members)
4834         (Archive::total_members_loaded): New variables.
4835         (Archive::get_file_and_offset): New function.
4836         (Archive::get_elf_object_for_member): New function.
4837         (Archive::read_all_symbols): New function.
4838         (Archive::read_symbols): New function.
4839         (Archive::Archive_member): New class.
4840         (Archive::members_): New member.
4841         (Archive::num_members_): New member.
4842         * main.cc: Include archive.h.
4843         (main): Call Archive::print_stats.
4844         * mapfile.cc (Mapfile::report_include_archive_member): Delete
4845         archive parameter; member_name is now the fully-decorated name.
4846         * mapfile.h (Mapfile::report_include_archive_member): Likewise.
4847         * options.h: (General_options): Add --preread-archive-symbols option.
4848         * readsyms.cc (Read_symbols::do_read_symbols): Change call to
4849         Archive::setup.
4850
4851 2008-08-04  Ian Lance Taylor  <iant@google.com>
4852
4853         * symtab.h (Symbol::use_plt_offset): New function.
4854         * i386.cc (Relocate::relocate): Call Symbol::use_plt_offset.
4855         * powerpc.cc (Relocate::relocate): Likewise.
4856         * sparc.cc (Relocate::relocate): Likewise.
4857         * x86_64.cc (Relocate::relocate): Likewise.
4858         * testsuite/weak_plt.sh: New test.
4859         * testsuite/weak_plt_main.cc: New test.
4860         * testsuite/weak_plt_shared.cc: New test.
4861         * testsuite/Makefile.am (check_SCRIPTS): Add weak_plt.sh.
4862         (check_PROGRAMS): Add weak_plt.
4863         (check_DATA): Add weak_plt_shared.so.
4864         (weak_plt_main_pic.o, weak_plt): New targets.
4865         (weak_plt_shared_pic.o, weak_plt_shared.so): New targets.
4866         * testsuite/Makefile.in: Rebuild.
4867
4868         * testsuite/Makefile.am (weak_alias_test_1.so): Depend upon
4869         gcctestdir/ld.
4870         (weak_alias_test_2.so, weak_alias_test_4.so): Likewise.
4871         * testsuite/Makefile.in: Rebuild.
4872
4873 2008-08-04  Alan Modra  <amodra@bigpond.net.au>
4874
4875         * Makefile.am (POTFILES.in): Set LC_ALL=C.
4876         * Makefile.in: Regenerate.
4877         * po/POTFILES.in: Regenerate.
4878
4879 2008-07-29  Ian Lance Taylor  <iant@google.com>
4880
4881         * script.cc (Script_options::finalize_symbols): Finalize SECTIONS
4882         symbols before other symbols.
4883         * testsuite/script_test_2.cc (test_addr): Declare.
4884         (test_addr_alias): Declare.
4885         (main): Check that test_addr and test_addr_alias have the right
4886         values.
4887         * testsuite/script_test_2.t: Define test_addr_alias and
4888         test_addr.
4889
4890 2008-07-24  Ian Lance Taylor  <iant@google.com>
4891
4892         PR 5990
4893         * descriptors.cc: New file.
4894         * descriptors.h: New file.
4895         * gold-threads.h (class Hold_optional_lock): New class.
4896         * fileread.cc: Include "descriptors.h".
4897         (File_read::~File_read): Release descriptor rather than closing
4898         it.
4899         (File_read::open) [file]: Call open_descriptor rather than open.
4900         Set is_descriptor_opened_.
4901         (File_read::open) [memory]: Assert that descriptor is not open.
4902         (File_read::reopen_descriptor): New function.
4903         (File_read::release): Release descriptor.
4904         (File_read::do_read): Make non-const.  Reopen descriptor.
4905         (File_read::read): Make non-const.
4906         (File_read::make_view): Reopen descriptor.
4907         (File_read::do_readv): Likewise.
4908         * fileread.h (class File_read): Add is_descriptor_opened_ field.
4909         Update declarations.
4910         * layout.cc: Include "descriptors.h".
4911         (Layout::create_build_id): Use open_descriptor rather than open.
4912         * output.cc: Include "descriptors.h".
4913         (Output_file::open): Use open_descriptor rather than open.
4914         * archive.cc (Archive::const_iterator): Change Archive to be
4915         non-const.
4916         (Archive::begin, Archive::end): Make non-const.
4917         (Archive::count_members): Likewise.
4918         * archive.h (class Archive): Update declarations.
4919         * object.h (Object::read): Make non-const.
4920         * Makefile.am (CCFILES): Add descriptors.cc.
4921         (HFILES): Add descriptors.h.
4922         * Makefile.in: Rebuild.
4923
4924         PR 6716
4925         * gold.h: Always include <clocale>.  Add Solaris workarounds
4926         following code in binutils/sysdep.h.
4927
4928         PR 6048
4929         * ehframe.cc (Eh_frame::add_ehframe_input_section): Check whether
4930         this->eh_frame_hdr_ is NULL before using it.
4931
4932         * dynobj.cc (Versions::Versions): Update comment.
4933
4934         * dynobj.cc (Versions::Versions): If there is an soname, use it as
4935         the base version name.
4936
4937         * stringpool.cc (Stringpool_template::add_with_length): Set key to
4938         array size plus one.
4939         (Stringpool_template::set_string_offsets): Subtract one from key
4940         before using it as an array index.
4941         (Stringpool_template::get_offset_with_length): Likewise.
4942         (Stringpool_template::write_to_buffer): Likewise.
4943         * stringpool.h (Stringpool_template::get_offset_from_key):
4944         Likewise.
4945
4946 2008-07-23  Ian Lance Taylor  <iant@google.com>
4947
4948         PR 6658
4949         * object.h (Merged_symbol_value::value): Do our best to handle a
4950         negative addend.
4951
4952         PR 6647
4953         * script.cc (Version_script_info::get_versions): Don't add empty
4954         version tag to return value.
4955         (Version_script_info::get_symbol_version_helper): Change return
4956         type to bool.  Add pversion parameter.  Change all callers.
4957         (script_register_vers_node): Don't require a non-NULL tag.
4958         * script.h (class Version_script_info): Update declarations.
4959         (Version_script_info::get_symbol_version): Change return type to
4960         bool.  Add version parameter.  Change all callers.
4961         * symtab.cc (Sized_symbol::add_from_relobj): Rework version
4962         handling.  Handle an empty version from a version script.
4963         (Symbol_table::define_special_symbol): Likewise.
4964         * testsuite/ver_test_10.script: New file.
4965         * testsuite/ver_test_10.sh: New file.
4966         * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_10.sh.
4967         (check_DATA): Add ver_test_10.syms.
4968         (ver_test_10.syms, ver_test_10.so): New target.
4969         * testsuite/Makefile.in: Rebuild.
4970
4971 2008-07-23  Simon Baldwin  <simonb@google.com>
4972
4973         * symtab.cc (Symbol_table::sized_write_symbol): Only set st_size
4974         to zero for undefined symbols from dynamic libraries.
4975
4976 2008-07-23  Ian Lance Taylor  <iant@google.com>
4977
4978         * symtab.cc (Symbol_table::resolve): Remove version parameter.
4979         Change all callers.
4980         * symtab.h (class Symbol_table): Update declaration.
4981         * testsuite/ver_test_9.cc: New file.
4982         * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_9.
4983         (ver_test_9_SOURCES, ver_test_9_DEPENDENCIES): Define.
4984         (ver_test_9_LDFLAGS, ver_test_9_LDADD): Define.
4985         (ver_test_9.so, ver_test_9.o): New targets.
4986         * testsuite/Makefile.in: Rebuild.
4987
4988 2008-07-22  Ian Lance Taylor  <iant@google.com>
4989
4990         * options.h (class General_options): Define --check-sections.
4991         * layout.cc (Layout::set_segment_offsets): Handle
4992         --check-sections.
4993
4994         * options.h (class General_options): Define -n/--nmagic and
4995         -N/--omagic.
4996         * options.cc (General_options::finalize): For -n/--nmagic or
4997         -N/--omagic, set -static.
4998         * layout.cc (Layout::attach_allocated_section_to_segment): If
4999         -N/--omagic, don't put read-only and read-write sections in
5000         different segments.
5001         (Layout::find_first_load_seg): If -N/--omagic, don't insist on
5002         finding a read-only segment.
5003         (Layout::set_segment_offsets): If -N/--omagic or -n/--nmagic,
5004         don't set the minimum segment alignment to the common page size,
5005         and don't set the file offset to the address modulo the page size.
5006         * script-sections.cc (Script_sections::create_segments): If
5007         -n/--omagic, don't put read-only and read-write sections in
5008         different segments.
5009
5010         * cref.cc: New file.
5011         * cref.h: New file.
5012         * options.h (class General_options): Add --print-symbol-counts.
5013         * main.cc (main): Issue defined symbol report if requested.
5014         * archive.cc (Archive::interpret_header): Make into a const member
5015         function.
5016         (Archive::add_symbols): Call Input_objects::archive_start and
5017         archive_stop.
5018         (Archive::const_iterator): Define new class.
5019         (Archive::begin, Archive::end): New functions.
5020         (Archive::include_all_members): Rewrite to use iterator.
5021         (Archive::count_members): New function.
5022         * archive.h (class Archive): Update declarations.
5023         (Archive::filename): New function.
5024         * object.cc: Include "cref.h".
5025         (Sized_relobj::Sized_relobj): Initialize defined_count_.
5026         (Sized_relobj::do_get_global_symbol_counts): New function.
5027         (Input_objects::add_object): Add object to cross-referencer.
5028         (Input_objects::archive_start): New function.
5029         (Input_objects::archive_stop): New function.
5030         (Input_objects::print_symbol_counts): New function.
5031         * object.h: Declare Cref and Archive.
5032         (Object::get_global_symbol_counts): New function.
5033         (Object::do_get_global_symbol_counts): New pure virtual function.
5034         (class Sized_relobj): Add defined_count_ field.  Update
5035         declarations.
5036         (class Input_objects): Add cref_ field.  Update constructor.
5037         Update declarations.
5038         * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and
5039         defined_count_.
5040         (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing
5041         symbol counts.
5042         (Sized_dynobj::do_get_global_symbol_counts): New function.
5043         * dynobj.h (class Sized_dynobj): Add fields symbols_ and
5044         defined_count_.  Update declarations.  Define Symbols typedef.
5045         * symtab.cc (Symbol_table::add_from_relobj): Add defined
5046         parameter.  Change all callers.
5047         (Symbol_table::add_from_dynobj): Add sympointers and defined
5048         parameters.  Change all callers.
5049         * symtab.h (class Symbol_table): Update declarations.
5050         * Makefile.am (CCFILES): Add cref.cc.
5051         (HFILES): Add cref.h.
5052         * Makefile.in: Rebuild.
5053
5054 2008-07-22  Simon Baldwin  <simonb@google.com>
5055
5056         * symtab.cc (Symbol_table::sized_write_symbol): Set symbol size
5057         to zero when writing undefined symbols.
5058
5059 2008-07-22  Ian Lance Taylor  <iant@google.com>
5060
5061         * output.cc (Output_section::add_input_section): Don't try to
5062         merge empty merge sections.
5063
5064 2008-07-21  Craig Silverstein  <csilvers@google.com>
5065
5066         * symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
5067         Include symbol version in error message.
5068
5069 2008-07-20  Chris Demetriou  <cgd@google.com>
5070
5071         * configure.ac (gold_cv_c_random_seed): New configured variable.
5072         (RANDOM_SEED_CFLAGS): New substituted variable.
5073         * Makefile.am (AM_CFLAGS, AM_CXXFLAGS): Add $(RANDOM_SEED_CFLAGS).
5074         * configure: Rebuild.
5075         * Makefile.in: Likewise.
5076         * testsuite/Makefile.in: Likewise.
5077
5078 2008-07-18  Ian Lance Taylor  <iant@google.com>
5079
5080         * symtab.cc (Symbol_table::add_from_object): Rewrite the case
5081         where we see NAME/NULL and NAME/VERSION  as separate symbols.
5082         * testsuite/ver_test_main.cc (main): Call t4.
5083         (t4, t4_2a): Define.
5084         * testsuite/ver_test_2.cc (t4_2): Define.
5085         * testsuite/ver_test_2.script: Put t4_2a in VER2.
5086         * testsuite/ver_test_4.cc (t4_2a): Define.
5087         * testsuite/ver_test_4.script: Put t4_2a in VER2.
5088         * testsuite/ver_test.h (t4, t4_2, t4_2a): Declare.
5089
5090 2008-07-17  Ian Lance Taylor  <iant@google.com>
5091
5092         * dynobj.cc (Versions::add_def): If we give an error about a
5093         missing version, go ahead and create the version anyhow.
5094
5095 2008-07-10  Ian Lance Taylor  <iant@google.com>
5096
5097         Handle output sections with more than 0x7fffffff bytes.
5098         * object.h (class Relobj): Change map_to_output_ to
5099         output_sections_, and just keep a section pointer.  Change all
5100         uses.  Move comdat group support to Sized_relobj.
5101         (Relobj::is_section_specially_mapped): Remove.
5102         (Relobj::output_section): Remove poff parameter.  Change all
5103         callers.
5104         (Relobj::output_section_offset): New function.
5105         (Relobj::set_section_offset): Rewrite.
5106         (Relobj::map_to_output): Remove.
5107         (Relobj::output_sections): New function.
5108         (Relobj::do_output_section_offset): New pure virtual function.
5109         (Relobj::do_set_section_offset): Likewise.
5110         (class Sized_relobj): Add section_offsets_ field.  Add comdat
5111         group support from Relobj.  Update declarations.
5112         (Sized_relobj::get_output_section_offset): New function.
5113         (Sized_relobj::do_output_section_offset): New function.
5114         (Sized_relobj::do_set_section_offset): New function.
5115         * object.cc (Relobj::output_section_address): Remove.
5116         (Sized_relobj::Sized_relobj): Initialize new fields.
5117         (Sized_relobj::include_section_group): Cast find_kept_object to
5118         Sized_relobj.
5119         (Sized_relobj::include_linkonce_section): Likewise.
5120         (Sized_relobj::do_layout): Use separate arrays for output section
5121         and output offset.
5122         (Sized_relobj::do_count_local_symbols): Change map_to_output to
5123         output_sections.
5124         (Sized_relobj::do_finalize_local_symbols): Change map_to_output to
5125         output_sections and section_offsets.
5126         (Sized_relobj::write_local_symbols): Likewise.
5127         (map_to_kept_section): Compute output address directly.
5128         * reloc.cc (Sized_relobj::do_read_relocs): Change map_to_output to
5129         output_sections and section_offsets.
5130         (Sized_relobj::write_sections): Likewise.
5131         (Sized_relobj::relocate_sections): Likewise.
5132         * symtab.cc (sized_finalize_symbol): Use output_section_offset.
5133         * output.h (class Output_reloc): Update declarations.  Change
5134         u2_.relobj to Sized_relobj*.
5135         (class Output_data_reloc): Change add functions to use
5136         Sized_relobj*.
5137         * output.cc (Output_reloc::Output_reloc): Change relobj to
5138         Sized_relobj*.
5139         (Output_reloc::local_section_offset): Change return type to
5140         Elf_Addr.  Use get_output_section_offset.
5141         (Output_reloc::get_address): Likewise.
5142         (Output_section::is_input_address_mapped): Don't call
5143         is_section_specially_mapped.
5144         (Output_section::output_offset): Likewise.
5145         (Output_section::output_address): Likewise.
5146         (Output_section::starting_output_address): Likewise.
5147         * copy-relocs.cc (Copy_relocs::copy_reloc): Change object
5148         parameter to Sized_relobj*.
5149         (Copy_relocs::need_copy_reloc): Likewise.
5150         (Copy_relocs::save): Likewise.
5151         * copy-relocs.h (class Copy_relocs): Update declarations.
5152         (class Copy_relocs::Copy_reloc_entry): Change constructor to use
5153         Sized_relobj*.  Change relobj_ field to Sized_relobj*.
5154         * target-reloc.h (relocate_for_relocatable): Change
5155         offset_in_output_section type to Elf_Addr.  Change code that uses
5156         it as well.
5157         * layout.cc (Layout::layout): Always set *off.
5158         * mapfile.cc (Mapfile::print_input_section): Use
5159         output_section_offset.
5160         * i386.cc (Target_i386::copy_reloc): Change object parameter to
5161         Sized_relobj*.
5162         * powerpc.cc (Target_powerpc::copy_reloc): Likewise.
5163         * sparc.cc (Target_sparc::copy_reloc): Likewise.
5164         * x86_64.cc (Target_x86_64::copy_reloc): Likewise.
5165
5166 2008-07-03  Ian Lance Taylor  <iant@google.com>
5167
5168         * layout.cc (Layout::include_section): Do not discard unrecognized
5169         SHT_STRTAB sections.
5170
5171 2008-06-30  Craig Silverstein  <csilvers@cs.stanford.edu>
5172
5173         * script.cc (Lex::can_continue_name): Make '?' allowable in
5174         version-script names.
5175         * testsuite/version_script.map: Change glob pattern to use '?'
5176
5177 2008-06-30  Manish Singh  <yosh@gimp.org>
5178
5179         PR 6585
5180         * symtab.cc (Symbol_table::add_undefined_symbols_from_command_line):
5181         Correct typo.
5182
5183 2008-06-30  Ian Lance Taylor  <iant@google.com>
5184
5185         PR 6660
5186         PR 6682
5187         * powerpc.cc (Powerpc_relocate_functions::addr16_ha) [both
5188         versions]: Don't try to read the value in the contents, since we
5189         don't use it.  Use the template endianness when writing.
5190
5191 2008-06-25  Cary Coutant  <ccoutant@google.com>
5192
5193         * fileread.cc (File_read::make_view): Assert on zero-length view.
5194         * object.cc (Sized_relobj::do_read_symbols): Don't try to read
5195         symbol table when there are no symbols to read.
5196
5197 2008-06-23  Craig Silverstein  <csilvers@google.com>
5198
5199         * version.cc (version_string): Bump to 1.7
5200
5201 2008-06-18  Craig Silverstein  <csilvers@google.com>
5202
5203         * powerpc.cc (Powerpc_relocate_functions::addr16_ha): cast
5204         constant 0xFFFF to type Valtype.
5205         (Powerpc_relocate_functions::rel16_ha): Likewise.
5206
5207 2008-06-17  Ian Lance Taylor  <iant@google.com>
5208
5209         * output.h (Output_section::Input_section): Initialize p2align_ to
5210         zero for Output_section_data constructors.
5211         (Output_section::Input_section::addralign): If not an input
5212         section, return the alignment of the Output_section_data.
5213         * testsuite/copy_test.cc: New file.
5214         * testsuite/copy_test_1.cc: New file.
5215         * testsuite/copy_test_2.cc: New file.
5216         * testsuite/Makefile.am (check_PROGRAMS): Add copy_test.
5217         (copy_test_SOURCES, copy_test_DEPENDENCIES): New variables.
5218         (copy_test_LDFLAGS, copy_test_LDADD): New variables.
5219         (copy_test_1_pic.o, copy_test_1.so): New targets.
5220         (copy_test_2_pic.o, copy_test_2.so): New targets.
5221         * testsuite/Makefile.in: Rebuild.
5222
5223         * script-sections.cc (Script_sections::place_orphan): Initialize
5224         local variable exact.
5225
5226 2008-06-13  David Edelsohn  <edelsohn@gnu.org>
5227
5228         * powerpc.cc (Output_data_plt_powerpc::do_write): 8 + 4 = 0xC.
5229
5230 2008-06-12  David Edelsohn  <edelsohn@gnu.org>
5231             David S. Miller  <davem@davemloft.net>
5232
5233         * powerpc.cc: New file.
5234         * Makefile.am (TARGETSOURCES): Add powerpc.cc
5235         (ALL_TARGETOBJS): Add powerpc.$(OBJEXT)
5236         * configure.tgt: Add entries for powerpc-* and powerpc64-*.
5237         * Makefile.in: Rebuild.
5238
5239 2008-06-09  Ian Lance Taylor  <iant@google.com>
5240
5241         * testsuite/relro_test.cc: Include <cstdio>, <cstdlib>, and
5242         <exception>.
5243         (throwing, orig_terminate): New static variables.
5244         (terminate_handler): New static function.
5245         (t2): Set terminate handler.
5246
5247 2008-06-05  Kris Van Hees  <kris.van.hees@oracle.com>
5248
5249         PR 6584
5250         * binary.cc (Binary_to_elf::sized_convert): Fix .data
5251         alignment.
5252
5253 2008-05-30  Cary Coutant  <ccoutant@google.com>
5254
5255         * archive.cc (Archive::include_all_members) Correct to step
5256         over symbol table and extended name table in thin archives.
5257
5258 2008-05-29  Kris Van Hees  <kris.van.hees@oracle.com>
5259
5260         PR 6407
5261         * target-reloc.h (relocate_for_relocatable): Fix new_offset
5262         calculation.
5263
5264 2008-05-28  Caleb Howe  <cshowe@google.com>
5265
5266         * reduced_debug_output.cc: New file.
5267         * reduced_debug_output.h: New file.
5268         * options.h (class General_options): Add --strip-debug-non-line.
5269         * options.cc (General_options::finalize): Add strip_debug_non_line
5270         to the strip heirarchy.
5271         * layout.h (class Layout): Add debug_abbrev_ and debug_info_
5272         fields.
5273         * layout.cc: Include "reduced_debug_output.h".
5274         (Layout::Layout): Initialize new fields.
5275         (line_only_debug_sections): New static array.
5276         (is_lines_only_debug_sections): New static inline function.
5277         (Layout::include_section): Handle --strip-debug-non-line.
5278         (Layout::make_output_section): If --strip-debug-non-line, build
5279         new output sections for .debug_abbrev and .debug_info.
5280         * dwarf_reader.cc (read_unsigned_LEB_128): Move to namespace
5281         gold.  Warn about possible overflow.
5282         (read_signed_LEB_128): Likewise.
5283         * dwarf_reader.h: (read_unsigned_LEB_128): Declare.
5284         (read_signed_LEB_128): Declare.
5285         * Makefile.am (CCFILES): Add reduced_debug_output.cc.
5286         (HFILES): Add reduced_debug_output.h.
5287         * Makefile.in: Rebuild.
5288
5289 2008-05-21  Ian Lance Taylor  <iant@google.com>
5290
5291         * mapfile.cc: New file.
5292         * mapfile.h: New file.
5293         * options.h (class General_options): Add -M/--print-map and -Map.
5294         * options.cc (General_options::finalize): Make -M equivalent to
5295         -Map -.
5296         * main.cc: Include <cstdio> and "mapfile.h".
5297         (main): Open mapfile if requested.
5298         * gold.cc (class Middle_runner): Add mapfile_ field.  Update
5299         constructor.  Change caller.
5300         (queue_initial_tasks): Add mapfile parameter.  Change caller.
5301         (queue_middle_tasks): Likewise.
5302         * gold.h (queue_initial_tasks, queue_middle_tasks): Update
5303         declarations.
5304         * archive.cc: Include "mapfile.h".
5305         (Archive::add_symbols): Add mapfile parameter.  Change all
5306         callers.  Pass mapfile, symbol, and reason to include_member.
5307         (Archive::include_all_members): Add mapfile parameter.  Change all
5308         callers.
5309         (Archive::include_member): Add mapfile, sym, and why parameters.
5310         Change all callers.  Report inclusion to map file.
5311         * archive.h: Include "fileread.h".
5312         (class Archive): Update declarations.
5313         (Archive::file): New const method.
5314         (class Add_archive_symbols): Add mapfile_ field.  Update
5315         constructor.  Change all callers.
5316         * readsyms.h (class Read_symbols): Likewise.
5317         (class Finish_group): Likewise.
5318         (class Read_script): Likewise.
5319         * common.cc: Include "mapfile.h".
5320         (Symbol_table::allocate_commons): Add mapfile parameter.  Change
5321         all callers.
5322         (Symbol_table::do_allocate_commons): Likewise.
5323         (Symbol_table::do_allocate_commons_list): Likewise.  Report common
5324         symbol allocation to mapfile.
5325         * common.h (class Allocate_commons_task): Add mapfile_ field.
5326         Update constructor.  Change all callers.
5327         * symtab.h (class Symbol_table): Update declarations.
5328         * layout.cc: Include "mapfile.h".
5329         (Layout_task_runner::run): Print information to mapfile.
5330         (Layout::create_gold_note): Change Output_data_fixed_space to
5331         Output_data_zero_fill.
5332         (Layout::create_build_id): Likewise.
5333         (Layout::print_to_mapfile): New function.
5334         * layout.h (class Layout_task_runner): Add mapfile_ field.  Update
5335         constructor.  Change caller.
5336         (class Layout): Declare print_to_mapfile.
5337         * output.cc (Output_section::Input_section::print_to_mapfile): New
5338         function.
5339         (Output_section::add_input_section): If producing a map, always
5340         add to input_sections_ list.
5341         (Output_section::do_print_to_mapfile): New function.
5342         (Output_segment::print_sections_to_mapfile): New function.
5343         (Output_segment::print_section_list_to_mapfile): New function.
5344         * output.h: Include "mapfile.h".
5345         (Output_data::print_to_mapfile): New function.
5346         (Output_data::do_print_to_mapfile): New virtual function.
5347         (Output_segment_headers::do_print_to_mapfile): New function.
5348         (Output_file_header::do_print_to_mapfile): New function.
5349         (Output_data_const::do_print_to_mapfile): New function.
5350         (class Output_data_const_buffer): Add map_name_ field.  Update
5351         constructor.  Change all callers.  Add do_print_to_mapfile
5352         function.
5353         (class Output_data_fixed_space): Likewise.
5354         (class Output_data_space): Likewise.
5355         (class Output_data_zero_fill): New class.
5356         (Output_data_strtab::do_print_to_mapfile): New function.
5357         (Output_data_reloc_base::do_print_to_mapfile): New function.
5358         (Output_relocatable_relocs::do_print_to_mapfile): New function.
5359         (Output_data_group::do_print_to_mapfile): New function.
5360         (Output_data_got::do_print_to_mapfile): New function.
5361         (Output_data_dynamic::do_print_to_mapfile): New function.
5362         (Output_symtab_xindex::do_print_to_mapfile): New function.
5363         (class Output_section): Declare do_print_to_mapflie.  Declare
5364         print_to_mapfile in Input_section.
5365         (class Output_segment): Declare new functions.
5366         * object.h (Sized_relobj::symbol_count): New function.
5367         * script-sections.cc
5368         (Output_section_element_dot_assignment::set_section_addresses):
5369         Change Output_data_fixed_space to Output_data_zero_fill.
5370         (Output_data_expression::do_print_to_mapfile): New function.
5371         * script.cc (read_input_script): Add mapfile parameter.  Change
5372         all callers.
5373         * script.h (read_input_script): Update declaration.
5374         * ehframe.h (Eh_frame_hdr::do_print_to_mapfile): New function.
5375         (Eh_frame::do_print_to_mapfile): New function.
5376         * merge.h (Output_merge_data::do_print_to_mapfile): New function.
5377         (Output_merge_string::do_print_to_mapfile): New function.
5378         * i386.cc (Output_data_plt_i386::do_print_to_mapfile): New
5379         function.
5380         * sparc.cc (Output_data_plt_sparc::do_print_to_mapfile): New
5381         function.
5382         * x86_64.cc (Output_data_plt_x86_64::do_print_to_mapfile): New
5383         function.
5384         * Makefile.am (CCFILES): Add mapfile.cc.
5385         (HFILES): Add mapfile.h.
5386         * Makefile.in: Rebuild.
5387
5388 2008-05-19  Ian Lance Taylor  <iant@google.com>
5389
5390         * options.h (class General_options): Add -z relro.
5391         * layout.cc (Layout::Layout): Initialize relro_segment_.
5392         (Layout::add_output_section_data): Return the output section.
5393         (Layout::make_output_section): Rcognize relro sections and mark
5394         them appropriately.
5395         (Layout::attach_allocated_section_to_segment): Put relro sections
5396         in a PT_GNU_RELRO segment.
5397         (Layout::create_initial_dynamic_sections): Mark the .dynamic
5398         section as relro.
5399         (Layout::segment_precedes): Sort PT_GNU_RELRO segments after
5400         PT_TLS segments.
5401         (Layout::linkonce_mapping): Map d.rel.ro.local to
5402         .data.rel.ro.local.
5403         (Layout::output_section_name): Us .data.rel.ro.local for any
5404         section which begins with that.
5405         * layout.h (class Layout): Update add_output_section_data
5406         declaration.  Add relro_segment_ field.
5407         * output.cc (Output_section::Output_section): Initialize is_relro_
5408         and is_relro_local_ fields.
5409         (Output_segment::add_output_section): Group relro sections.
5410         (Output_segment::is_first_section_relro): New function.
5411         (Output_segment::maximum_alignment): If there is a relro section,
5412         align the segment to the common page size.
5413         (Output_segment::set_section_addresses): Track whether we are
5414         looking at relro sections.  If the last section is a relro
5415         section, align to the common page size.
5416         (Output_segment::set_section_list_addresses): Add in_relro
5417         parameter.  Change all callers.  Align to the page size when
5418         moving from relro to non-relro section.
5419         (Output_segment::set_offset): Align memsz of a PT_GNU_RELRO
5420         segment.
5421         * output.h (class Output_section): Add is_relro_ and
5422         is_relro_local_ fields.
5423         (Output_section::is_relro): New function.
5424         (Output_section::set_is_relro): New function.
5425         (Output_section::is_relro_local): New function.
5426         (Output_section::set_is_relro_local): New function.
5427         (class Output_segment): Update declarations.
5428         * i386.cc (Target_i386::got_section): Mark .got section as relro.
5429         * sparc.cc (Target_sparc::got_section): Likewise.
5430         * x86_64.cc (Target_x86_64::got_section): Likewise.
5431         * testsuite/relro_test_main.cc: New file.
5432         * testsuite/relro_test.cc: New file.
5433         * testsuite/Makefile.am (check_PROGRAMS): Add relro_test.
5434         (relro_test_SOURCES, relro_test_DEPENDENCIES): New variables.
5435         (relro_test_LDFLAGS, relro_test_LDADD): New variables.
5436         (relro_test.so, relro_test_pic.o): New targets.
5437         * testsuite/Makefile.in: Rebuild.
5438
5439 2008-05-16  Ian Lance Taylor  <iant@google.com>
5440
5441         * output.cc (Output_segment::add_output_section): Remove front
5442         parameter.
5443         * output.h (class Output_segment): Remove
5444         add_initial_output_section and overloaded add_output_section.
5445         Update declaration of remaining add_output_section.
5446         * layout.cc (Layout::create_interp): Call add_output_section
5447         rather than add_initial_output_section.
5448         (Layout::finish_dynamic_section): Likewise.
5449
5450         * i386.cc (Target_i386::Relocate::relocate_tls): Set dynamic type
5451         for TLS_GOTDESC and TLS_DESC_CALL.  Only optimize TLS_LDO_32 if we
5452         know the dynamic type.
5453         * x86_64.cc (Target_x86_64::Relocate): Add saw_tls_block_reloc_
5454         field.  Initialize it in constructor.
5455         (Target_x86_64::Relocate::relocate_tls): Record that we saw a TLS
5456         block reloc for TLSGD, GOTPC32_TLSDESC, TLSDESC_CALL, and TLSLD.
5457         Only optimize DTPOFF32 and DTPOFF64 if we have seen a TLS block
5458         reloc.
5459
5460         * output.cc (Output_reloc::get_address): Change return type to
5461         Elf_Addr.
5462         * output.h (class Output_reloc): Update get_address declaration.
5463         * x86_64.cc (Output_data_plt_x86_64::do_write): Use 64-bit types
5464         for section addresses.
5465
5466 2008-05-09  Ian Lance Taylor  <iant@google.com>
5467
5468         PR 6493
5469         * gold.cc (gold_nomem): Use return value of write.
5470
5471 2008-05-08  Ian Lance Taylor  <iant@google.com>
5472
5473         * symtab.c (Symbol::init_base_output_data): Add version
5474         parameter.  Change all callers.
5475         (Symbol::init_base_output_segment): Likewise.
5476         (Symbol::init_base_constant): Likewise.
5477         (Symbol::init_base_undefined): Likewise.
5478         (Sized_symbol::init_output_data): Likewise.
5479         (Sized_symbol::init_output_segment): Likewise.
5480         (Sized_symbol::init_constant): Likewise.
5481         (Sized_symbol::init_undefined): Likewise.
5482         (Symbol_table::do_define_in_output_data): If the new symbol has a
5483         version, mark it as the default.
5484         (Symbol_table::do_define_in_output_segment): Likewise.
5485         (Symbol_table::do_define_as_constant): Likewise.
5486         * symtab.h (class Symbol): Update declarations.
5487         (class Sized_symbol): Likewise.
5488         * resolve.cc (Symbol::override_version): New function.
5489         (Symbol::override_base): Call override_version.
5490         (Symbol::override_base_with_special): Likewise.
5491         * testsuite/ver_script_8.script: New file.
5492         * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_8.
5493         (ver_test_8_SOURCES, ver_test_8_DEPENDENCIES): Define.
5494         (ver_test_8_LDFLAGS, ver_test_8_LDADD): Define.
5495         (ver_test_8_1.so, ver_test_8_2.so): New targets.
5496
5497 2008-05-06  Ian Lance Taylor  <iant@google.com>
5498
5499         PR 6049
5500         * options.h (DEFINE_set): Add VARNAME_begin and VARNAME_end
5501         functions.
5502         (class General_options): Remove existing --undefined, and add
5503         --no-undefined instead.  Add new --undefined as synonym for -u.
5504         * archive.cc (Archive::add_symbols): Check whether symbol was
5505         named with -u.
5506         * gold.cc (queue_middle_tasks): Add -u symbols to symbol table.
5507         * symtab.h (class Symbol): Rename CONSTANT to IS_CONSTANT; change
5508         all uses.  Add IS_UNDEFINED.  Update declarations to split
5509         different versions of init_base.  Declare init_base_undefined.
5510         (Symbol::is_defined): Handle IS_UNDEFINED.
5511         (Symbol::is_undefined): Likewise.
5512         (Symbol::is_weak_undefined): Call is_undefined.
5513         (Symbol::is_absolute): Handle IS_CONSTANT.
5514         (class Sized_symbol): Update declarations to split different
5515         versions of init.  Declare init_undefined.
5516         (class Symbol_table): Declare new functions.
5517         * symtab.cc (Symbol::init_base_object): Rename from init_base.
5518         Change all callers.
5519         (Symbol::init_base_output_data): Likewise.
5520         (Symbol::init_base_output_segment): Likewise.
5521         (Symbol::init_base_constant): Likewise.
5522         (Symbol::init_base_undefined): New function.
5523         (Sized_symbol::init_object): Rename from init.  Change all
5524         callers.
5525         (Sized_symbol::init_output_data): Likewise.
5526         (Sized_symbol::init_output_segment): Likewise.
5527         (Sized_symbol::init_constant): Likewise.
5528         (Sized_symbol::init_undefined): New function.
5529         (Symbol_table::add_undefined_symbols_from_command_line): New
5530         function.
5531         (Symbol_table::do_add_undefined_symbols_from_command_line): New
5532         function.
5533         (Symbol::final_value_is_known): Handle IS_UNDEFINED.
5534         (Symbol::output_section): Likewise.
5535         (Symbol::set_output_section): Likewise.
5536         (Symbol_table::sized_finalize_symbol): Likewise.
5537         (Symbol_table::sized_write_globals): Likewise.
5538         * resolve.cc (Symbol_table::should_override): Likewise.
5539         (Symbol::override_base_with_special): Likewise.
5540
5541         * symtab.cc (Symbol_table::add_from_dynobj): If we see a protected
5542         symbol, change it to have default visibility.
5543         * testsuite/protected_1.cc: New file.
5544         * testsuite/protected_2.cc: New file.
5545         * testsuite/protected_3.cc: New file.
5546         * testsuite/protected_main_1.cc: New file.
5547         * testsuite/protected_main_2.cc: New file.
5548         * testsuite/protected_main_3.cc: New file.
5549         * testsuite/Makefile.am (check_PROGRAMS): Add protected_1.
5550         (protected_1_SOURCES, protected_1_DEPENDENCIES): Define.
5551         (protected_1_LDFLAGS, protected_1_LDADD): Define.
5552         (protected_1.so): New target.
5553         (protected_1_pic.o, protected_2_pic.o): New targets.
5554         (protected_3_pic.o): New target.
5555         (check_PROGRAMS): Add protected_2.
5556         (protected_2_SOURCES, protected_2_DEPENDENCIES): Define.
5557         (protected_2_LDFLAGS, protected_2_LDADD): Define.
5558         * testsuite/Makefile.in: Rebuild.
5559
5560         * options.h (DEFINE_var): Add set_user_set_##varname__.
5561         (DEFINE_bool_alias): New macro.
5562         (class General_options): Define -Bstatic using DEFINE_bool_alias
5563         rather than DEFINE_special.  Add --undefined as an alias for -z
5564         defs.
5565         * options.cc (General_options::parse_Bstatic): Remove.
5566
5567         * options.h (class General_options): Add --fatal-warnings.
5568         * main.cc (main): Implement --fatal-warnings.
5569         * errors.h (Errors::warning_count): New function.
5570
5571         * options.h (class General_options): Add -Bsymbolic-functions.
5572         * symtab.h (Symbol::is_preemptible): Check for
5573         -Bsymbolic-functions.
5574
5575 2008-05-05  Ian Lance Taylor  <iant@google.com>
5576
5577         * options.h (DEFINE_bool): For DASH_Z, create the negative option
5578         as noVARNAME rather than no-VARNAME.
5579         (class General_options): Add option -z combreloc.
5580         * output.h (class Output_reloc) [SHT_REL]: Declare compare and
5581         get_address.
5582         (Output_reloc::sort_before) [SHT_REL]: New function.
5583         (Output_reloc::sort_before) [SHT_RELA]: New function.
5584         (class Output_data_reloc_base): Add sort_relocs_ field.  Define
5585         Sort_relocs_comparison.
5586         (Output_data_reloc_base::Output_data_reloc_base): Add sort_relocs
5587         parameter.  Change all callers.
5588         (Output_data_reloc::Output_data_reloc) [both versions]: Add
5589         sort_relocs parameter.  Change all callers.
5590         * output.cc (Output_reloc::get_address): New function, broken out
5591         of write_rel.
5592         (Output_reloc::write_rel): Call it.
5593         (Output_reloc::compare): New function.
5594         (Output_data_reloc_base::do_write): Optionally sort relocs.
5595
5596         * configure.ac: If targ_extra_obj is set, link it in.
5597         * configure.tgt: Initialize all variables.
5598         (x86_64*): Set targ_extra_obj and targ_extra_size.
5599         * configure: Rebuild.
5600
5601         * object.cc (Sized_relobj::include_section_group): Adjust section
5602         indexes read from group data.  Build vector to pass to
5603         layout_group.
5604         * layout.cc (Layout::layout_group): Add flags and shndxes
5605         parameters.  Remove contents parameter.  Change caller.  Update
5606         explicit instantiations.
5607         * layout.h (class Layout): Update layout_group declaration.
5608         * output.cc (Output_data_group::Output_data_group): Add flags and
5609         input_shndxes parameters.  Remove contents parameter.  Change
5610         caller.
5611         (Output_data_group::do_write): Change input_sections_ to
5612         input_shndxes_.
5613         * output.h (class Output_data_group): Update constructor
5614         declaration.  Rename input_sections_ to input_shndxes_.
5615         * testsuite/many_sections_test.cc: Add template.
5616
5617 2008-04-30  Cary Coutant  <ccoutant@google.com>
5618
5619         * target-reloc.h (relocate_section): Fix dead-pointer bug.
5620
5621         * layout.cc (Layout::include_section): Refactored check for debug
5622         info section.
5623         (Layout::add_comdat): Add new parameters.  Change type
5624         of signature parameter.  Add object and shndx to signatures table.
5625         (Layout::find_kept_object): New function.
5626         * layout.h: Include <cstring>.
5627         (Layout::is_debug_info_section): New function.
5628         (Layout::add_comdat): Add new parameters.
5629         (Layout::find_kept_object): New function.
5630         (Layout::Kept_section): New struct.
5631         (Layout::Signatures): Change type of map range.
5632         * object.cc (Relobj::output_section_address): New function.
5633         (Sized_relobj::include_section_group): Add new parameters.  Change
5634         calls to Layout::add_comdat.  Change to build table of kept comdat
5635         groups and table mapping discarded sections to kept sections.
5636         (Sized_relobj::include_linkonce_section): Likewise.  Add new parameter.
5637         (Sized_relobj::do_layout): Change calls to include_section_group and
5638         include_linkonce_section.
5639         (Sized_relobj::do_finalize_local_symbols): Do not set local symbol
5640         value to zero when section is discarded.
5641         (Sized_relobj::map_to_kept_section): New function.
5642         * object.h (Relobj::output_section_address): New function.
5643         (Relobj::Comdat_group): New type.
5644         (Relobj::find_comdat_group): New function.
5645         (Relobj::Comdat_group_table): New type.
5646         (Relobj::Kept_comdat_section): New type.
5647         (Relobj::Kept_comdat_section_table): New type.
5648         (Relobj::add_comdat_group): New function.
5649         (Relobj::set_kept_comdat_section): New function.
5650         (Relobj::get_kept_comdat_section): New function.
5651         (Relobj::comdat_groups_): New field.
5652         (Relobj::kept_comdat_sections_): New field.
5653         (Symbol_value::input_value): Update comment.
5654         (Sized_relobj::map_to_kept_section) New function.
5655         (Sized_relobj::include_linkonce_section): Add new parameter.
5656         * target-reloc.h (Comdat_behavior): New type.
5657         (get_comdat_behavior): New function.
5658         (relocate_section): Add code to map a discarded section to the
5659         corresponding kept section when applying a relocation.
5660
5661 2008-04-30  Craig Silverstein  <csilvers@google.com>
5662
5663         * dwarf_reader.cc (next_generation_count): New static var.
5664         (Addr2line_cache_entry): New struct.
5665         (addr2line_cache): New static var.
5666         (Dwarf_line_info::one_addr2line): Added caching.
5667         (Dwarf_line_info::clear_addr2line_cache): New function.
5668         * dwarf_reader.h (Dwarf_line_info::one_addr2line): Add
5669         cache-size parameter.
5670         (Dwarf_line_info::one_addr2line_cache): New function.
5671         * symtab.cc (Symbol_table::detect_odr_violations): Pass
5672         new cache-size argument to one_addr2line(), and clear cache.
5673
5674 2008-04-28  Cary Coutant  <ccoutant@google.com>
5675
5676         * i386.cc (Relocate::relocate): Fix typos for R_386_PC16 and
5677         R_386_PC8 relocations.
5678
5679 2008-04-23  Ian Lance Taylor  <iant@google.com>
5680
5681         * object.cc (Sized_relobj::include_section_group): Check for
5682         invalid section group.
5683
5684         * object.cc (make_elf_object): Correct test for 64-bit ELF file
5685         header size.
5686
5687         * readsyms.cc (Read_symbols::do_read_symbols): Use get_view rather
5688         than read for file header.
5689         * archive.cc (Archive::include_member): Likewise.
5690
5691 2008-04-23  Paolo Bonzini  <bonzini@gnu.org>
5692
5693         * aclocal.m4: Regenerate.
5694         * configure: Regenerate.
5695
5696 2008-04-19  Ian Lance Taylor  <iant@google.com>
5697
5698         * version.cc (version_string): Bump to 1.6.
5699
5700         * testsuite/Makefile.am (many_sections_r_test): New target.
5701         (many_sections_r_test_SOURCES): Remove.
5702         (many_sections_r_test_DEPENDENCIES): Remove.
5703         (many_sections_r_test_LDFLAGS): Remove.
5704         (many_sections_r_test_LDADD): Remove.
5705
5706         * object.cc (Sized_relobj::do_add_symbols): Always pass
5707         local_symbol_count_ to add_from_relobj.
5708
5709         * testsuite/Makefile.am (many_sections_check.h): Only check one in
5710         every thousand variables.
5711         * testsuite/Makefile.in: Rebuild.
5712
5713         * object.cc (Xindex::initialize_symtab_xindex): New function.
5714         (Xindex::read_symtab_xindex): New function.
5715         (Xindex::sym_xindex_to_shndx): New function.
5716         (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if
5717         available.
5718         (Sized_relobj::do_initialize_xindex): New function.
5719         (Sized_relobj::do_read_symbols): Adjust section links.
5720         (Sized_relobj::symbol_section_and_value): Add is_ordinary
5721         parameter.  Change all callers.
5722         (Sized_relobj::include_section_group): Adjust section links and
5723         symbol section indexes.
5724         (Sized_relobj::do_layout): Adjust section links.
5725         (Sized_relobj::do_count_local_symbols): Adjust section links and
5726         symbol section indexes.
5727         (Sized_relobj::do_finalize_local_symbols): Distinguish between
5728         ordinary and special symbols.
5729         (Sized_relobj::write_local_symbols): Add symtab_xindex and
5730         dynsym_xindex parameters.  Change all callers.  Adjust section
5731         links.  Use SHN_XINDEX when needed.
5732         (Sized_relobj::get_symbol_location_info): Adjust section links.
5733         Don't get fooled by special symbols.
5734         * object.h (class Xindex): Define.
5735         (class Object): Add xindex_ parameter.  Declare virtual functoin
5736         do_initialize_xindex.
5737         (Object::adjust_sym_shndx): New function.
5738         (Object::set_xindex): New protected function.
5739         (class Symbol_value): Add is_ordinary_shndx_ field.
5740         (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_.
5741         (Symbol_value::value): Assert ordinary section.
5742         (Symbol_value::initialize_input_to_output_map): Likewise.
5743         (Symbol_value::set_input_shndx): Add is_ordinary parameter.
5744         Change all callers.
5745         (Symbol_value::input_shndx): Add is_ordinary parameter.  Change
5746         all callers.
5747         (class Sized_relobj): Update declarations.
5748         (Sized_relobj::local_symbol_input_shndx): Add is_ordinary
5749         parameter.  Change all callers.
5750         (Sized_relobj::adjust_shndx): New function.
5751         * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_
5752         field.
5753         (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx
5754         parameter.  Change all callers.  Pick up SHT_DYNSYM_SHNDX section
5755         for SHT_DYNSYM section if available.  Set dynsym_shndx_ field.
5756         (Sized_dynobj::read_dynsym_section): Adjust section links.
5757         (Sized_dynobj::read_dynamic): Likewise.
5758         (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field.  Adjust
5759         section links.
5760         (Sized_dynobj::do_initialize_xindex): New function.
5761         * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field.  Declare
5762         do_initialize_xindex.
5763         (Sized_dynobj::adjust_shndx): New function.
5764         * layout.cc (Layout::Layout): Initialize symtab_xindex_ and
5765         dynsym_xindex_ fields.
5766         (Layout::finalize): Add a call to set_section_indexes before
5767         creating the symtab sections.
5768         (Layout::set_section_indexes): Don't do anything if the section
5769         already has a section index.
5770         (Layout::create_symtab_sections): Add shnum parameter.  Change
5771         caller.  Create .symtab_shndx section if needed.
5772         (Layout::create_shdrs): Add shstrtab_section parameter.  Change
5773         caller.
5774         (Layout::allocated_output_section_count): New function.
5775         (Layout::create_dynamic_symtab): Create .dynsym_shndx section if
5776         needed.
5777         * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_
5778         fields.  Update declarations.
5779         (Layout::symtab_xindex): New function.
5780         (Layout::dynsym_xindex): New function.
5781         (class Write_symbols_task): Add layout_ field.
5782         (Write_symbols_task::Write_symbols_task): Add layout parameter.
5783         Change caller.
5784         * output.cc (Output_section_headers::Output_section_headers): Add
5785         shstrtab_section parameter.  Change all callers.
5786         (Output_section_headers::do_sized_write): Store overflow values
5787         for section count and section string table section index in
5788         section header zero.
5789         (Output_file_header::do_sized_write): Check for overflow of
5790         section count and section string table section index.
5791         (Output_symtab_xindex::do_write): New function.
5792         (Output_symtab_xindex::endian_do_write): New function.
5793         * output.h (class Output_section_headers): Add shstrtab_section_.
5794         Update declarations.
5795         (class Output_symtab_xindex): Define.
5796         (Output_section::has_out_shndx): New function.
5797         * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_
5798         field.
5799         (Symbol::init_base): Add st_shndx and is_ordinary parameters.
5800         Change all callers.
5801         (Sized_symbol::init): Likewise.
5802         (Symbol::output_section): Check for ordinary symbol.
5803         (Symbol_table::add_from_object): Remove orig_sym parameter.  Add
5804         st_shndx, is_ordinary, and orig_st_shndx parameters.  Change all
5805         callers.
5806         (Symbol_table::add_from_relobj): Add symndx_offset parameter.
5807         Change all callers.  Simplify handling of symbols from sections
5808         not included in the link.
5809         (Symbol_table::add_from_dynobj): Handle ordinary symbol
5810         distinction.
5811         (Weak_alias_sorter::operator()): Assert that symbols are
5812         ordinary.
5813         (Symbol_table::sized_finalize_symbol): Handle ordinary symbol
5814         distinction.
5815         (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex
5816         parameters.  Change all callers.
5817         (Symbol_table::sized_write_globals): Likewise.  Handle ordinary
5818         symbol distinction.  Use SHN_XINDEX when needed.
5819         (Symbol_table::write_section_symbol): Add symtab_xindex
5820         parameter.  Change all callers.
5821         (Symbol_table::sized_write_section_symbol): Likewise.  Use
5822         SHN_XINDEX when needed.
5823         * symtab.h (class Symbol): Add is_ordinary_shndx_ field.  Update
5824         declarations.
5825         (Symbol::shndx): Add is_ordinary parameter.  Change all callers.
5826         (Symbol::is_defined): Check is_ordinary.
5827         (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise.
5828         (Symbol::is_absolute, Symbol::is_common): Likewise.
5829         (class Sized_symbol): Update declarations.
5830         (class Symbol_table): Update declarations.
5831         * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary
5832         parameters.  Change all callers.
5833         (Sized_symbol::override): Likewise.
5834         (Symbol_table::override): Likewise.
5835         (symbol_to_bits): Add is_ordinary parameter.  Change all callers.
5836         (Symbol_table::resolve): Remove orig_sym parameter.  Add st_shndx,
5837         is_ordinary, and orig_st_shndx parameters.  Change all callers.
5838         * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol
5839         to be in an ordinary section.
5840         * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add
5841         object and is_ordinary parameters.  Change all callers.
5842         (Sized_dwarf_line_info::read_relocs): Add object parameter.
5843         Change all callers.  Don't add undefined or non-ordinary symbols
5844         to reloc_map_.
5845         (Sized_dwarf_line_info::read_line_mappings): Add object parameter.
5846         Change all callers.
5847         * dwarf_reader.h (class Sized_dwarf_line_info): Update
5848         declarations.
5849         * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol.
5850         * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links.
5851         (Sized_relobj::relocate_sections): Likewise.
5852         * target-reloc.h (scan_relocs): Adjust section symbol index.
5853         (scan_relocatable_relocs): Likewise.
5854         * i386.cc (Scan::local): Check for ordinary symbols.
5855         * sparc.cc (Scan::local): Likewise.
5856         * x86_64.cc (Scan::local): Likewise.
5857         * testsuite/binary_unittest.cc (Sized_binary_test): Update calls
5858         to symbol_section_and_value.
5859         * testsuite/many_sections_test.cc: New file.
5860         * testsuite/Makefile.am (BUILT_SOURCES): Define.
5861         (check_PROGRAMS): Add many_sections_test.
5862         (many_sections_test_SOURCES): Define.
5863         (many_sections_test_DEPENDENCIES): Define.
5864         (many_sections_test_LDFLAGS): Define.
5865         (BUILT_SOURCES): Add many_sections_define.h.
5866         (many_sections_define.h): New target.
5867         (BUILT_SOURCES): Add many_sections_check.h.
5868         (many_sections_check.h): New target.
5869         (check_PROGRAMS): Add many_sections_r_test.
5870         (many_sections_r_test_SOURCES): Define.
5871         (many_sections_r_test_DEPENDENCIES): Define.
5872         (many_sections_r_test_LDFLAGS): Define.
5873         (many_sections_r_test_LDADD): Define.
5874         (many_sections_r_test.o): New target.
5875         * testsuite/Makefile.in: Rebuild.
5876
5877 2008-04-17  Cary Coutant  <ccoutant@google.com>
5878
5879         * errors.cc (Errors::info): New function.
5880         (gold_info): New function.
5881         * errors.h (Errors::info): New function.
5882         * gold.h (gold_info): New function.
5883         * object.cc (Input_objects::add_object): Print trace output.
5884         * options.cc (options::parse_set): New function.
5885         (General_options::parse_wrap): Deleted.
5886         (General_options::General_options): Deleted initializer.
5887         * options.h (options::String_set): New typedef.
5888         (options::parse_set): New function.
5889         (DEFINE_set): New macro.
5890         (General_options::wrap): Changed to use DEFINE_set. Changed
5891         callers of any_wrap_symbols and is_wrap_symbol.
5892         (General_options::trace, General_options::trace_symbol):
5893         New options.
5894         (General_options::any_wrap_symbols, General_options::is_wrap_symbol)
5895         (General_options::wrap_symbols_): Deleted.
5896         * symtab.cc (Symbol_table::add_from_object): Print trace output.
5897
5898 2008-04-17  David S. Miller  <davem@davemloft.net>
5899
5900         * options.cc (General_options::parse_V): New function.
5901         * options.h: Add entries for -V and -Qy.
5902
5903 2008-04-17  Ian Lance Taylor  <iant@google.com>
5904
5905         * common.cc (Symbol_table::allocate_commons): Remove options
5906         parameter.  Change caller.
5907         (Symbol_table::do_allocate_commons): Remove options parameter.
5908         Change caller.  Just call do_allocate_commons_list twice.
5909         (Symbol_table::do_allocate_commons_list): New function, broken out
5910         of do_allocate_commons.
5911         * common.h (class Allocate_commons_task): Remove options_ field.
5912         Update constructor.
5913         * symtab.cc (Symbol_table::Symbol_table): Initialize
5914         tls_commons_.
5915         (Symbol_table::add_from_object): Put TLS common symbols on
5916         tls_commons_ list.
5917         (Symbol_table::sized_finalize_symbol): Handle STT_TLS symbols
5918         which are IN_OUTPUT_DATA.
5919         * symtab.h (class Symbol_table): Add tls_commons_ field.  Update
5920         allocate_commons and do_allocate_commons declarations.  Declare
5921         do_allocate_commons_list.
5922         * gold.cc (queue_middle_tasks): Update creation of
5923         Allocate_commons_task to not pass options.
5924         * testsuite/Makefile.am (INCLUDES): Add -I.. .
5925         (TLS_TEST_C_FLAGS): New variable.
5926         (tls_test_c_pic.o): New target.
5927         (tls_test_shared.so): Link in tls_test_c_pic.o.
5928         (tls_test_c_pic_ie.o): New target.
5929         (tls_test_ie_shared.so): Link in tls_test_c_pic_ie.o.
5930         (tls_test_DEPENDENCIES, tls_test_LDADD): Add tls_test_c.o.
5931         (tls_test_c.o): New target.
5932         (tls_pic_test_DEPENDENCIES): Add tls_test_c_pic.o.
5933         (tls_pic_test_LDADD): Likewise.
5934         (tls_shared_gd_to_ie_test_DEPENDENCIES): Add tls_test_c_pic.o.
5935         (tls_shared_gd_to_ie_test_LDADD): Likewise.
5936         (tls_test_c_gnu2.o): New target.
5937         (tls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): Add
5938         tls_test_c_gnu2.o.
5939         (tls_shared_gnu2_gd_to_ie_test_LDADD): Likewise.
5940         (tls_test_gnu2_shared.so): Link in tls_test_c_gnu2.o.
5941         (tls_test_shared_nonpic.so): Link in tls_test_c.o.
5942         * testsuite/tls_test.cc: Include "config.h".
5943         (t_last): Call t11_last.
5944         * testsuite/tls_test.h (t11, t11_last): Declare.
5945         * testsuite/tls_test_c.c: New file.
5946         * testsuite/tls_test_main.cc (thread_routine): Call t11.
5947         * configure.ac: Check for OpenMP support.
5948         * configure, config.in, Makefile.in: Rebuild.
5949         * testsuite/Makefile.in: Rebuild.
5950
5951 2008-04-16  Cary Coutant  <ccoutant@google.com>
5952
5953         * i386.cc (Target_i386::define_tls_base_symbol): New function.
5954         (Target_i386::tls_base_symbol_defined_): New field.
5955         (Target_i386::Scan::local): Define _TLS_MODULE_BASE_ symbol.
5956         (Target_i386::Scan::global): Likewise.
5957         * symtab.cc (sized_finalize_symbol): Add check for TLS symbol.
5958         * x86_64.cc (Target_x86_64::define_tls_base_symbol): New function.
5959         (Target_x86_64::tls_base_symbol_defined_): New field.
5960         (Target_x86_64::Scan::local): Define _TLS_MODULE_BASE_ symbol.
5961         (Target_x86_64::Scan::global): Likewise.
5962
5963 2008-04-16  Cary Coutant  <ccoutant@google.com>
5964
5965         * symtab.h (Symbol::is_strong_undefined): Removed unused function.
5966         (Symbol::needs_plt_entry): Allow weak undefined symbols.
5967         (Symbol::needs_dynamic_reloc): Allow weak undefined symbols when
5968         building shared libraries.
5969         * testsuite/Makefile.am (weak_undef_nonpic_test): New target.
5970         (weak_undef_file1_nonpic.o, weak_undef_file2_nonpic.o)
5971         (weak_undef_lib_nonpic.so, alt/weak_undef_lib_nonpic.so): New targets.
5972         * testsuite/Makefile.in: Rebuild.
5973         * testsuite/weak_undef.h: New file.
5974         * testsuite/weak_undef_file1.cc: Add extra test cases.
5975         * testsuite/weak_undef_file2.cc: Likewise.
5976         * testsuite/weak_undef_test.cc: Likewise.
5977
5978 2008-04-16  David S. Miller  <davem@davemloft.net>
5979
5980         * sparc.cc (Target_sparc::Scan): Change from struct to class.
5981         Add issued_non_pic_error_ field.  Declare check_non_pic.
5982         (Target_sparc::Scan::check_non_pic): New function.
5983         (Target_sparc::Scan::local): Call check_non_pic as appropriate.
5984         (Target_sparc::Scan::global): Likewise.
5985
5986         * configure.ac (FN_PTRS_IN_SO_WITHOUT_PIC): Add sparc64.
5987         * configure: Rebuild.
5988
5989         * options.h (DEFINE_enable): New macro.
5990         (new_dtags): New enable option.
5991         (initfirst, interpose, loadfltr, nodefaultlib,
5992         nodelete, nodlopen, nodump): New -z options.
5993         * layout.cc (Layout:finish_dynamic_section): If new
5994         dtags enabled, emit DT_RUNPATH.  Also, emit a
5995         DT_FLAGS_1 containing any specified -z flags.
5996
5997 2008-04-16  Ian Lance Taylor  <iant@google.com>
5998
5999         * copy-relocs.cc: New file.
6000         * copy-relocs.h: New file.
6001         * reloc.cc: Remove Copy_relocs code.
6002         * reloc.h: Likewise.
6003         * reloc-types.h (struct Reloc_types) [both versions]: Add
6004         get_reloc_addend_noerror.
6005         * output.h (class Output_data_reloc<elfcpp::SHT_REL>): Add
6006         variants of add_global which take an addend which must be zero.
6007         * i386.cc: Include "copy-relocs.h".
6008         (class Target_i386): Change type of copy_relocs_ to variable,
6009         update initializer.
6010         (Target_i386::copy_reloc): Rewrite to pass to Copy_relocs class.
6011         Change all callers.
6012         (Target_i386::do_finalize_sections): Change handling of
6013         copy_relocs_.
6014         * sparc.cc: Include "copy-relocs.h".
6015         (class Target_sparc): Change type of copy_relocs_ to variable,
6016         update initializer.
6017         (Target_sparc::copy_reloc): Rewrite to pass to Copy_relocs class.
6018         Change all callers.
6019         (Target_sparc::do_finalize_sections): Change handling of
6020         copy_relocs_.
6021         * x86_64.cc: Include "copy-relocs.h".
6022         (class Target_x86_64): Change type of copy_relocs_ to variable,
6023         update initializer.
6024         (Target_x86_64::copy_reloc): Rewrite to pass to Copy_relocs
6025         class.  Change all callers.
6026         (Target_x86_64::do_finalize_sections): Change handling of
6027         copy_relocs_.
6028         * Makefile.am (CCFILES): Add copy-relocs.cc.
6029         (HFILES): Add copy-relocs.h.
6030
6031         * Makefile.in, aclocal.m4, testsuite/Makefile.in: Rebuild.
6032
6033         * testsuite/script_test_4.sh: Permit leading zeroes.
6034
6035 2008-04-15  Ian Lance Taylor  <iant@google.com>
6036
6037         * script-sections.cc (Script_sections::create_segments): Use
6038         header_size_adjustment even when there is enough room for the
6039         headers.
6040         * testsuite/script_test_4.sh: New file.
6041         * testsuite/script_test_4.t: New file.
6042         * testsuite/Makefile.am (check_SCRIPTS): Add script_test_4.sh.
6043         (check_DATA): Add script_test_4.stdout.
6044         (MOSTLYCLEANFILES): Likewise.
6045         (script_test_4): New target.
6046         (script_test_4.stdout): New target.
6047         * testsuite/Makefile.in: Rebuild.
6048
6049         * sparc.cc: Add definitions for Output_data_plt_sparc class
6050         constants.
6051
6052 2008-04-14  David S. Miller  <davem@davemloft.net>
6053
6054         * sparc.cc: New file.
6055         * Makefile.am (TARGETSOURCES): Add sparc.cc
6056         (ALL_TARGETOBJS): Add sparc.$(OBJEXT)
6057         * configure.tgt: Document targ_extra_size and
6058         targ_extra_big_endian.  Add entries for sparc-* and
6059         sparc64-*.
6060         * configure.ac: Handle targ_extra_size and
6061         targ_extra_big_endian.
6062         * Makefile.in: Rebuild.
6063         * configure: Likewise.
6064         * po/POTFILES.in: Likewise.
6065         * po/gold.pot: Likewise.
6066
6067 2008-04-14  Ian Lance Taylor  <iant@google.com>
6068
6069         * layout.cc (Layout::Layout): Initialize sections_are_attached_.
6070         (Layout::get_output_section): Ignore SHF_WRITE and SHF_EXECINSTR
6071         in the name/type/flags to section mapping.  Don't call
6072         allocate_output_section.
6073         (Layout::choose_output_section): Change parameter from adjust_name
6074         to is_input_section.  Don't permit input sections after sections
6075         are attached to segments.  Don't call allocate_output_section.
6076         (Layout::layout_eh_frame): Call update_flags_for_input_section,
6077         not write_enable_output_section.
6078         (Layout::make_output_section): Don't push to
6079         unattached_section_list_ nor call attach_to_segment.  Call
6080         attach_section_to_segment if sections are attached.
6081         (Layout::attach_sections_to_segments): New function.
6082         (Layout::attach_section_to_segment): New function.
6083         (Layout::attach_allocated_section_to_segment): Rename from
6084         attach_to_segment.  Remove flags parameter.
6085         (Layout::allocate_output_section): Remove function.
6086         (Layout::write_enable_output_section): Remove function.
6087         * layout.h (class Layout): Update for above changes.  Add new
6088         field sections_are_attached_.
6089         * output.h (Output_section::update_flags_for_input_section): New
6090         function.
6091         * output.cc (Output_section::add_input_section): Call
6092         update_flags_for_input_section.
6093         * gold.cc (queue_middle_tasks): Call attach_sections_to_segments.
6094
6095 2008-04-11  Cary Coutant  <ccoutant@google.com>
6096
6097         * i386.cc (Target_i386::got_mod_index_entry): Restore code previously
6098         thought unnecessary.
6099         * x86_64.cc (Target_x86_64::got_mod_index_entry): Likewise.
6100
6101 2008-04-11  Ian Lance Taylor  <iant@google.com>
6102
6103         * output.h (class Output_section_data): Remove inline definition
6104         of set_addralign.
6105         * output.cc (Output_section_data::set_addralign): New function.
6106
6107 2008-04-11  Cary Coutant  <ccoutant@google.com>
6108
6109         Add support for TLS descriptors for i386 and x86_64.
6110         * i386.cc (Target_i386::Relocate::tls_desc_gd_to_ie): New function.
6111         (Target_i386::Relocate::tls_desc_gd_to_le): New function.
6112         (Target_i386::Got_type): Add GOT_TYPE_TLS_NOFFSET and
6113         GOT_TYPE_TLS_DESC.
6114         (Target_i386::got_mod_index_entry): Remove unnecessary code.
6115         (Target_i386::Scan::local): Implement R_386_TLS_GOTDESC and
6116         R_386_TLS_DESC_CALL relocations.  Fix problem with initial-exec
6117         relocations.
6118         (Target_i386::Scan::global): Fix problem with GD-to-IE relaxation.
6119         Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations;
6120         Fix problem with initial-exec relocations.
6121         (Target_i386::Relocate::relocate_tls): Likewise.
6122         (Target_i386::Relocate::tls_gd_to_ie): Fix problem with GD-to-IE
6123         relaxation.
6124         * output.cc (Output_data_dynamic::Dynamic_entry::write): Add
6125         support for section-plus-offset dynamic table entries.
6126         * output.h (Output_data_dynamic::add_section_plus_offset): New function.
6127         (Output_data_dynamic::Dynamic_entry): Add support for
6128         section-plus-offset dynamic table entries.
6129         (Output_data_dynamic::Classification): Likewise.
6130         (Output_data_dynamic::classification_): Renamed offset_.
6131         * x86_64.cc (Target_x86_64::Relocate::tls_desc_gd_to_ie): New function.
6132         (Target_x86_64::Relocate::tls_desc_gd_to_le): New function.
6133         (Target_x86_64::make_plt_section): New function.
6134         (Target_x86_64::reserve_tlsdesc_entries): New function.
6135         (Output_data_plt_x86_64::Output_data_plt_x86_64): Add new parameter.
6136         (Output_data_plt_x86_64::reserve_tlsdesc_entry): New function.
6137         (Output_data_plt_x86_64::has_tlsdesc_entry): New function.
6138         (Output_data_plt_x86_64::get_tlsdesc_got_offset): New function.
6139         (Output_data_plt_x86_64::get_tlsdesc_plt_offset): New function.
6140         (Output_data_plt_x86_64::tlsdesc_plt_entry): New field.
6141         (Output_data_plt_x86_64::set_final_data_size): Move out of line;
6142         add extra PLT entry for TLS descriptors.
6143         (Output_data_plt_x86_64::got_): New field.
6144         (Output_data_plt_x86_64::tlsdesc_got_offset_): New field.
6145         (Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize new
6146         fields.
6147         (Output_data_plt_x86_64::do_write): Write extra PLT entry for TLS
6148         descriptors.
6149         (Target_x86_64::make_plt_entry): Factor out make_plt_section.
6150         (Target_x86_64::got_mod_index_entry): Remove unnecessary code.
6151         (Target_x86_64::Scan::local): Implement R_386_TLS_GOTDESC and
6152         R_386_TLS_DESC_CALL relocations.
6153         (Target_x86_64::Scan::global): Likewise.
6154         (Target_x86_64::do_finalize_sections): Add dynamic table entries
6155         for TLS descriptors.
6156         (Relocate::relocate_tls): Fix problem with GD-to-IE relaxation.
6157         Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations.
6158         (Target_x86_64::Relocate::tls_gd_to_ie): Fix problem with
6159         GD-to-IE relaxation.
6160         * configure.ac: Export new conditional variables TLS_GNU2_DIALECT
6161         and TLS_DESCRIPTORS.
6162         * Makefile.in: Rebuild.
6163         * configure: Rebuild.
6164         * testsuite/Makefile.am (tls_shared_gd_to_ie_test): New target.
6165         (tls_test_shared2.so): New target.
6166         (tls_shared_gd_to_ie_test_SOURCES): New variable.
6167         (tls_shared_gd_to_ie_test_DEPENDENCIES): New variable.
6168         (tls_shared_gd_to_ie_test_LDFLAGS): New variable.
6169         (tls_shared_gd_to_ie_test_LDADD): New variable.
6170         (tls_shared_gnu2_gd_to_ie_test): New target.
6171         (tls_test_gnu2.o, tls_test_file2_gnu2.o, tls_test_gnu2_shared2.so):
6172         New targets.
6173         (tls_shared_gnu2_gd_to_ie_test_SOURCES): New variable.
6174         (ls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): New variable.
6175         (tls_shared_gnu2_gd_to_ie_test_LDFLAGS): New variable.
6176         (tls_shared_gnu2_gd_to_ie_test_LDADD): New variable.
6177         (tls_shared_gnu2_test): New target.
6178         (tls_test_gnu2_shared.so): New target.
6179         (tls_shared_gnu2_test_SOURCES): New variable.
6180         (tls_shared_gnu2_test_DEPENDENCIES): New variable.
6181         (tls_shared_gnu2_test_LDFLAGS): New variable.
6182         (tls_shared_gnu2_test_LDADD): New variable.
6183         * testsuite/Makefile.in: Rebuild.
6184         * testsuite/Makefile.
6185
6186 2008-04-11  Ian Lance Taylor  <iant@google.com>
6187
6188         * testsuite/Makefile.am (justsyms_2r.o): Add dependency on
6189         justsyms.t.
6190         * testsuite/Makefile.in: Rebuild.
6191
6192         * testsuite/script_test_2a.cc (script_test_string_a): Make 8 bytes
6193         long.
6194         * testsuite/script_test_2.cc (main): Adjust test.
6195
6196 2008-04-11  David S. Miller  <davem@davemloft.net>
6197             Ian Lance Taylor  <iant@google.com>
6198
6199         * options.h (General_options): Add entries for '-Y' and
6200         '-relax'.
6201         * options.cc (General_options:finalize): If -Y was used, add those
6202         entries to the library path instead of the default "/lib" and
6203         "/usr/lib".
6204
6205 2008-04-11  David S. Miller  <davem@davemloft.net>
6206
6207         * testsuite/justsyms.t: Start at 0x100.
6208         * testsuite/justsyms_1.cc: Adjust justsyms_string assertion.
6209         * testsuite/script_test_2b.cc (script_test_string_b): Make 8 bytes
6210         long.
6211         * testsuite/script_test_2.cc: Adjust string and section length
6212         checks.
6213
6214 2008-04-09  Ian Lance Taylor  <iant@google.com>
6215
6216         PR gold/5996
6217         * script-sections.cc (Sections_element::allocate_to_segment): Add
6218         orphan parameter.
6219         (Output_section_definition::allocate_to_segment): Likewise.
6220         (Orphan_output_section::allocate_to_segment): Likewise.
6221         (Script_sections::attach_sections_using_phdrs_clause): Don't
6222         propagate non-PT_LOAD segments to orphan sections.
6223         * testsuite/Makefile.am (script_test_3.stdout): Generate using
6224         readelf rather than objdump.
6225         * testsuite/script_test_3.sh: Adjust accordingly.  Test that
6226         .interp section and PT_INTERP segment are the same size.
6227         * testsuite/Makefile.in: Rebuild.
6228
6229         * symtab.cc (Symbol_table::add_from_dynobj): Only look for weak
6230         aliases for symbols defined in the same object.
6231         * testsuite/Makefile.am (check_PROGRAMS): Add weak_alias_test.
6232         (weak_alias_test_SOURCES): New variable.
6233         (weak_alias_test_DEPENDENCIES): New variable.
6234         (weak_alias_test_LDFLAGS): New variable.
6235         (weak_alias_test_LDADD): New variable.
6236         (weak_alias_test_1_pic.o, weak_alias_test_1.so): New targets.
6237         (weak_alias_test_2_pic.o, weak_alias_test_2.so): New targets.
6238         (weak_alias_test_3.o): New target.
6239         (weak_alias_test_4_pic.o, weak_alias_test_4.so): New targets.
6240         * testsuite/weak_alias_test_main.cc: New file.
6241         * testsuite/weak_alias_test_1.cc: New file.
6242         * testsuite/weak_alias_test_2.cc: New file.
6243         * testsuite/weak_alias_test_3.cc: New file.
6244
6245 2008-04-08  Ian Lance Taylor  <iant@google.com>
6246
6247         * options.h (class General_options): Add --noinhibit-exec option.
6248         * main.cc (main): Check --noinhibit-exec.
6249
6250         * options.h (class General_options): Define --wrap as a special
6251         option.  Add wrap_symbols_ field.
6252         (General_options::any_wrap_symbols): New function.
6253         (General_options::is_wrap_symbol): New function.
6254         * options.cc (General_options::parse_wrap): New function.
6255         (General_options::General_options): Initialize wrap_symbols_.
6256         * symtab.cc (Symbol_table::wrap_symbol): New function.
6257         (Symbol_table::add_from_object): Handle --wrap.
6258         * symtab.h (class Symbol_table): Declare wrap_symbol.
6259         * target.h (Target::wrap_char): New function.
6260         (Target::Target_info): Add wrap_char field.
6261         * i386.cc (Target_i386::i386_info): Initialize wrap_char.
6262         * x86_64.cc (Target_x86_64::x86_64_info): Likewise.
6263         * testsuite/testfile.cc (Target_test::test_target_info):
6264         Likewise.
6265
6266         * errors.cc (Errors::undefined_symbol): Mention symbol version if
6267         there is one.
6268
6269         * layout.h (class Layout): Add added_eh_frame_data_ field.
6270         * layout.cc (Layout::Layout): Initialize new field.
6271         (Layout::layout_eh_frame): Don't add eh_frame_data_ to .eh_frame
6272         output section until we find a section we merged successfully.
6273         * object.cc (Sized_relobj::check_eh_frame_flags): Don't require
6274         that the size be non-zero.
6275
6276         * merge.cc (Object_merge_map::get_output_offset): Remove inline
6277         qualifier.
6278
6279 2008-04-08  Craig Silverstein  <csilvers@google.com>
6280
6281         * configure.ac: Export new conditional variable HAVE_ZLIB.
6282         * testsuite/Makefile.am (flagstest_o_specialfile): Condition
6283         on HAVE_ZLIB.
6284         (flagstest_o_specialfile_and_compress_debug_sections): Likewise.
6285         * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
6286
6287 2008-04-07  Ian Lance Taylor  <iant@google.com>
6288
6289         * version.cc (version_string): Set to "1.5".
6290
6291         * x86_64.cc (Target_x86_64::Scan): Change from struct to class.
6292         Add issued_non_pic_error_ field.  Declare check_non_pic.
6293         (Target_x86_64::Scan::check_non_pic): New function.
6294         (Target_x86_64::Scan::local): Call check_non_pic as appropriate.
6295         (Target_x86_64::Scan::global): Likewise.
6296
6297         * output.cc (Output_reloc<SHT_REL>::local_section_offset): Add
6298         addend parameter.  Change caller.  Handle merge sections.
6299         (Output_reloc<SHT_REL>::symbol_value): Change parameter type from
6300         Address to Addend.  Don't add in the result of
6301         local_section_offset, pass down the addend and use the returned
6302         value.
6303         * output.h (class Output_reloc<SHT_REL>): Add Addend typedef.
6304         Update declarations of local_section_offset and symbol_value.
6305         * testsuite/two_file_test_1.cc (t18): New function.
6306         * testsuite/two_file_test_2.cc (f18): New function.
6307         * testsuite/two_file_test_main.cc (main): Call t18.
6308         * testsuite/two_file_test.h (t18, f18): Declare.
6309
6310         * configure.ac: Don't test for objdump, c++filt, or readelf.
6311         * testsuite/Makefile.am: Remove READELF and OBJDUMP_AND_CPPFILT
6312         conditionals.
6313         (TEST_READELF): New variable.
6314         (TEST_OBJDUMP, TEST_CXXFILT, TEST_STRIP): New variables.
6315         (check_PROGRAMS): Add two_file_strip_test.
6316         (two_file_strip_test): New target.
6317         (check_PROGRAMS): Add two_file_same_shared_strip_test.
6318         (two_file_same_shared_strip_test_SOURCES): New variable.
6319         (two_file_same_shared_strip_test_DEPENDENCIES): New variable.
6320         (two_file_same_shared_strip_test_LDFLAGS): New variable.
6321         (two_file_same_shared_strip_test_LDADD): New variable.
6322         (two_file_shared_strip.so): New target.
6323         (ver_test_2.syms, ver_test_4.syms): Use TEST_READELF.
6324         (ver_test_5.syms, ver_test_7.syms): Likewise.
6325         (ver_matching_test.stdout): Use TEST_OBJDUMP and TEST_CXXFILT.
6326         (strip_test_3.stdout): Use TEST_OBJDUMP.
6327         * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
6328
6329 2008-04-04  Cary Coutant  <ccoutant@google.com>
6330
6331         * symtab.h (Symbol::is_weak_undefined): New function.
6332         (Symbol::is_strong_undefined): New function.
6333         (Symbol::is_absolute): New function.
6334         (Symbol::needs_plt_entry): Exclude weak undefined symbols.
6335         (Symbol::needs_dynamic_reloc): Exclude weak undefined and
6336         absolute symbols.
6337         * testsuite/Makefile.am (check_PROGRAMS): Add weak_undef_test.
6338         (weak_undef_test): New target.
6339         * testsuite/Makefile.in: Rebuild.
6340         * testsuite/weak_undef_file1.cc: New file.
6341         * testsuite/weak_undef_file2.cc: New file.
6342         * testsuite/weak_undef_test.cc: New file.
6343
6344 2008-04-03  Craig Silverstein  <csilvers@google.com>
6345
6346         * compressed_output.h (class Output_compressed_section): Use
6347         unsigned buffer.
6348         * compressed_output.cc (zlib_compress): Use unsigned buffers,
6349         add zlib header.
6350         (zlib_compressed_suffix): Removed.
6351         (Output_compressed_section::set_final_data_size): Use unsigned
6352         buffers.
6353         * testsuite/Makefile.am (flagstest_compress_debug_sections):
6354         Fix linker invocation.
6355         (flagstest_o_specialfile_and_compress_debug_sections):
6356         Likewise.
6357         * testsuite/Makefile.in: Regenerated.
6358
6359 2008-04-02  David S. Miller  <davem@davemloft.net>
6360
6361         *  dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog,
6362         Sized_dwarf_line_info::process_one_opcode): Use Swap_unaligned.
6363
6364 2008-04-02  Craig Silverstein  <csilvers@google.com>
6365
6366         * TODO: New file.
6367
6368 2008-04-02  Ian Lance Taylor  <iant@google.com>
6369
6370         * fileread.cc (File_read::find_view): Add byteshift and vshifted
6371         parameters.  Update for new key type to views_.  Change all
6372         callers.
6373         (File_read::read): Adjust for byteshift in returned view.
6374         (File_read::add_view): New function, broken out of
6375         find_and_make_view.
6376         (File_read::make_view): New function, broken out of
6377         find_and_make_view.
6378         (File_read::find_or_make_view): Add offset and aligned
6379         parameters.  Rewrite accordingly.  Change all callers.
6380         (File_read::get_view): Add offset and aligned parameters.  Adjust
6381         for byteshift in return value.
6382         (File_read::get_lasting_view): Likewise.
6383         * fileread.h (class File_read): Update declarations.
6384         (class File_read::View): Add byteshift_ field.  Add byteshift to
6385         constructor.  Add byteshift method.
6386         * archive.h (Archive::clear_uncached_views): New function.
6387         (Archive::get_view): Add aligned parameter.  Change all callers.
6388         * object.h (Object::get_view): Add aligned parameter.  Change all
6389         callers.
6390         (Object::get_lasting_view): Likewise.
6391
6392         * fileread.cc (File_read::release): Don't call clear_views if
6393         there are multiple objects.
6394         * fileread.h (File_read::clear_uncached_views): New function.
6395         * archive.cc (Add_archive_symbols::run): Call clear_uncached_views
6396         on the archive.
6397
6398 2008-03-31  Cary Coutant  <ccoutant@google.com>
6399
6400         Add thin archive support.
6401         * archive.cc (Archive::armagt): New const.
6402         (Archive::setup): Remove task parameter and calls to unlock.
6403         (Archive::unlock_nested_archives): New function.
6404         (Archive::read_header): Add nested_off parameter. Change
6405         all callers.
6406         (Archive::interpret_header): Likewise.
6407         (Archive::include_all_members): Change to handle thin
6408         archives.
6409         (Archive::include_member): Likewise.
6410         * archive.h (Archive::Archive): Add new parameters and
6411         initializers.
6412         (Archive::armagt): New const.
6413         (Archive::setup): Remove task parameter.
6414         (Archive::unlock_nested_archives): New function.
6415         (Archive::read_header): Add nested_off parameter.
6416         (Archive::interpret_header): Likewise.
6417         (Archive::Nested_archive_table): New typedef.
6418         (Archive::is_thin_archive_): New field.
6419         (Archive::nested_archives_): New field.
6420         (Archive::options_): New field.
6421         (Archive::dirpath_): New field.
6422         (Archive::task_): New field.
6423         * readsyms.cc (Read_symbols::do_read_symbols): Add check
6424         for thin archives.  Pass additional parameters to
6425         Archive::Archive.  Unlock the archive file after calling
6426         Archive::setup.
6427
6428 2008-03-29  Ian Lance Taylor  <iant@google.com>
6429
6430         * symtab.cc (Symbol_table::do_define_as_constant): Don't force a
6431         version symbol to be local.
6432         * testsuite/ver_test_4.sh: New file.
6433         * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_4.sh.
6434         (check_DATA): Add ver_test_4.syms.
6435         (ver_test_4.syms): New target.
6436         * testsuite/Makefile.in: Rebuild.
6437
6438         * output.cc
6439         (Output_section::Input_section_sort_entry::has_priority): New
6440         function.
6441         (Output_section::Input_section_sort_entry::match_file_name): New
6442         function.
6443         (Output_section::Input_section_sort_entry::match_section_name):
6444         Remove.
6445         (Output_section::Input_section_sort_entry::match_section_name_prefix):
6446         Remove.
6447         (Output_section::Input_section_sort_entry::match_section_file):
6448         Remove.
6449         (Output_section::Input_section_sort_compare::operator()): Rewrite
6450         using new Input_section_sort_entry functions.  Sort crtbegin and
6451         crtend first.  Sort sections with no priority before sections with
6452         a priority.
6453         * testsuite/initpri1.c (d3): Check j != 4.
6454         (cd5): New constructor/destructor function.
6455         (main): Check j != 2.
6456
6457         * symtab.cc (Symbol_table::add_from_object): If we don't use the
6458         new symbol when resolving, don't call set_is_default.
6459         * testsuite/ver_test_7.cc: New file.
6460         * testsuite/ver_test_7.sh: New file.
6461         * testsuite/Makefile.am (ver_test_7.so): New target.
6462         (ver_test_7.o): New target.
6463         (check_SCRIPTS): Add ver_test_7.sh.
6464         (check_DATA): Add ver_test_7.syms.
6465         (ver_test_7.syms): New target.
6466
6467 2008-03-28  Ian Lance Taylor  <iant@google.com>
6468
6469         * layout.cc (Layout::layout): If we see an input section with a
6470         name that needs sorting, set the must_sort flag for the output
6471         section.
6472         (Layout::make_output_section): If the name of the output section
6473         indicates that it might require sorting, set the may_sort flag.
6474         * output.h (Output_section::may_sort_attached_input_sections): New
6475         function.
6476         (Output_section::set_may_sort_attached_input_sections): New
6477         function.
6478         (Output_section::must_sort_attached_input_sections): New
6479         function.
6480         (Output_section::set_must_sort_attached_input_sections): New
6481         function.
6482         (class Output_section): Declare Input_section_sort_entry.  Define
6483         Input_section_sort_compare.  Declare
6484         sort_attached_input_sections.  Add new fields:
6485         may_sort_attached_input_sections_,
6486         must_sort_attached_input_sections_,
6487         attached_input_sections_are_sorted_.
6488         * output.cc (Output_section::Output_section): Initialize new
6489         fields.
6490         (Output_section::add_input_section): Add an entry to
6491         input_sections_ if may_sort or must_sort are true.
6492         (Output_section::set_final_data_size): Call
6493         sort_attached_input_sections if necessary.
6494         (Output_section::Input_section_sort_entry): Define new class.
6495         (Output_section::Input_section_sort_compare::operator()): New
6496         function.
6497         (Output_section::sort_attached_input_sections): New function.
6498         * configure.ac: Check whether the compiler supports constructor
6499         priorities.  Define a CONSTRUCTOR_PRIORITY automake conditional.
6500         * testsuite/initpri1.c: New file.
6501         * testsuite/Makefile.am (check_PROGRAMS): Add initpri1 if
6502         CONSTRUCTOR_PRIORITY.
6503         (initpri1_SOURCES, initpri1_DEPENDENCIES): New variables.
6504         (initpri1_LDFLAGS): New variable.
6505         * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
6506
6507 2008-03-27  Ian Lance Taylor  <iant@google.com>
6508
6509         * common.cc (Sort_commons::operator): Correct sorting algorithm.
6510         * testsuite/common_test_1.c: New file.
6511         * testsuite/Makefile.am (check_PROGRAMS): Add common_test_1.
6512         (common_test_1_SOURCES): New variable.
6513         (common_test_1_DEPENDENCIES): New variable.
6514         (common_test_1_LDFLAGS): New variable.
6515
6516         * symtab.cc (Symbol_table::add_from_object): Handle saw_undefined_
6517         and commons_ correctly when NAME/VERSION does not override
6518         NAME/NULL.
6519         * testsuite/ver_test_6.c: New file.
6520         * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_6
6521         (ver_test_6_SOURCES, ver_test_6_DEPENDENCIES): New variables.
6522         (ver_test_6_LDFLAGS, ver_test_6_LDADD): New variables.
6523
6524 2008-03-26  Ian Lance Taylor  <iant@google.com>
6525
6526         * symtab.cc (Symbol_table::add_from_relobj): Don't set the version
6527         of an undefined symbol from a version script.
6528         * testsuite/Makefile.am (ver_test_5.so): New target.
6529         (ver_test_5.o): New target.
6530         (check_SCRIPTS): Add ver_test_5.sh.
6531         (check_DATA): Add ver_test_5.syms.
6532         (ver_test_5.syms): New target.
6533         * testsuite/ver_test_5.cc: New file.
6534         * testsuite/ver_test_5.script: New file.
6535         * testsuite/ver_test_5.sh: New file.
6536         * Makefile.in, testsuite/Makefile.in: Rebuild.
6537
6538         PR gold/5986
6539         Fix problems building gold with gcc 4.3.0.
6540         * gold.h (TEMPLATE_ATTRIBUTE_PRINTF_4): Define.
6541         (gold_error_at_location, gold_warning_at_location): Use it.
6542         * configure.ac: Check whether we can compile and use a template
6543         function with a printf attribute.
6544         * x86_64.cc (Target_x86_64::do_code_fill): Swap out a 32-bit value
6545         when jumping over bytes.
6546         * object.cc: Instantiate Object::read_section_data.
6547         * debug.h: Include <cstring>
6548         * dwarf_reader.cc: Include <algorithm>
6549         * main.cc: Include <cstring>.
6550         * options.cc: Include <cstring>.
6551         * output.cc: Include <cstring>.
6552         * script.cc: Include <cstring>.
6553         * script.h: Include <string>.
6554         * symtab.cc: Include <cstring> and <algorithm>.
6555         * target-select.cc: Include <cstring>.
6556         * version.cc: Include <string>.
6557         * testsuite/testmain.cc: Include <cstdlib>.
6558         * configure, config.in: Rebuild.
6559
6560 2008-03-25  Ian Lance Taylor  <iant@google.com>
6561
6562         * options.cc: Include "../bfd/bfdver.h".
6563         (options::help): Print bug reporting address.
6564
6565         * version.cc (print_version): Adjust output for current value of
6566         BFD_VERSION_STRING.
6567
6568         * NEWS: New file.
6569
6570         * options.cc (options::help): Print list of supported targets.
6571         * target-select.h: Include <vector>.
6572         (class Target_selector): Make machine_, size_, and is_big_endian_
6573         fields const.  Add bfd_name_ and instantiated_target_ fields.
6574         (Target_selector::Target_selector): Add bfd_name parameter.
6575         (Target_selector::recognize): Make non-virtual, call
6576         do_recognize.
6577         (Target_selector::recognize_by_name): Make non-virtual, call
6578         do_recognize_by_name.
6579         (Target_selector::supported_names): New function.
6580         (Target_selector::bfd_name): New function.
6581         (Target_selector::do_instantiate_target): New pure virtual
6582         function.
6583         (Target_selector::do_recognize): New virtual function.
6584         (Target_selector::do_recognize_by_name): New virtual function.
6585         (Target_selector::instantiate_target): New private function.
6586         (supported_target_names): Declare.
6587         * target-select.cc (Target_selector::Target_selector): Update for
6588         new parameter and fields.
6589         (select_target_by_name): Check that the name matches before
6590         calling recognize_by_name.
6591         (supported_target_names): New function.
6592         * i386.cc (class Target_selector_i386): Update Target_selector
6593         constructor call.  Remove recognize and recognize_by_name.  Add
6594         do_instantiate_target.
6595         * x86_64.cc (class Target_selector_x86_64): Likewise.
6596         * testsuite/testfile.cc (class Target_selector_test): Update for
6597         changes to Target_selector.
6598
6599         * README: Rewrite, with some notes on unsupported features.
6600
6601 2008-03-24  Cary Coutant  <ccoutant@google.com>
6602
6603         * i386.cc (Target_i386::Got_type): New enum declaration.
6604         (Target_i386::Scan::local): Updated callers of Output_data_got
6605         member functions.
6606         (Target_i386::Scan::global): Likewise.
6607         (Target_i386::Relocate::relocate): Likewise.
6608         (Target_i386::Relocate::relocate_tls): Likewise.
6609         * object.h (Got_offset_list): New class.
6610         (Sized_relobj::local_has_got_offset): Added got_type parameter.
6611         (Sized_relobj::local_got_offset): Likewise.
6612         (Sized_relobj::set_local_got_offset): Likewise.
6613         (Sized_relobj::local_has_tls_got_offset): Removed.
6614         (Sized_relobj::local_tls_got_offset): Removed.
6615         (Sized_relobj::set_local_tls_got_offset): Removed.
6616         (Sized_relobj::Local_got_offsets): Changed to store a list of offsets.
6617         * output.cc (Output_data_got::add_global): Added got_type parameter.
6618         (Output_data_got::add_global_with_rel): Likewise.
6619         (Output_data_got::add_global_with_rela): Likewise.
6620         (Output_data_got::add_global_pair_with_rel): New function.
6621         (Output_data_got::add_global_pair_with_rela): New function.
6622         (Output_data_got::add_local): Added got_type parameter.
6623         (Output_data_got::add_local_with_rel): Likewise.
6624         (Output_data_got::add_local_with_rela): Likewise.
6625         (Output_data_got::add_local_pair_with_rel): New function.
6626         (Output_data_got::add_local_pair_with_rela): New function.
6627         (Output_data_got::add_global_tls): Removed.
6628         (Output_data_got::add_global_tls_with_rel): Removed.
6629         (Output_data_got::add_global_tls_with_rela): Removed.
6630         (Output_data_got::add_local_tls): Removed.
6631         (Output_data_got::add_local_tls_with_rel): Removed.
6632         (Output_data_got::add_local_tls_with_rela): Removed.
6633         * output.h (Output_data_got::add_global): Added got_type parameter.
6634         (Output_data_got::add_global_with_rel): Likewise.
6635         (Output_data_got::add_global_with_rela): Likewise.
6636         (Output_data_got::add_global_pair_with_rel): New function.
6637         (Output_data_got::add_global_pair_with_rela): New function.
6638         (Output_data_got::add_local): Added got_type parameter.
6639         (Output_data_got::add_local_with_rel): Likewise.
6640         (Output_data_got::add_local_with_rela): Likewise.
6641         (Output_data_got::add_local_pair_with_rel): New function.
6642         (Output_data_got::add_local_pair_with_rela): New function.
6643         (Output_data_got::add_global_tls): Removed.
6644         (Output_data_got::add_global_tls_with_rel): Removed.
6645         (Output_data_got::add_global_tls_with_rela): Removed.
6646         (Output_data_got::add_local_tls): Removed.
6647         (Output_data_got::add_local_tls_with_rel): Removed.
6648         (Output_data_got::add_local_tls_with_rela): Removed.
6649         * resolve.cc (Symbol::override_base_with_special): Removed
6650         reference to has_got_offset_ field.
6651         * symtab.cc (Symbol::init_fields): Replaced initialization
6652         of got_offset_ with got_offsets_.  Removed initialization
6653         of has_got_offset_
6654         * symtab.h (Symbol::has_got_offset): Aded got_type parameter.
6655         (Symbol::got_offset): Likewise.
6656         (Symbol::set_got_offset): Likewise.
6657         (Symbol::has_tls_got_offset): Removed.
6658         (Symbol::tls_got_offset): Removed.
6659         (Symbol::set_tls_got_offset): Removed.
6660         (Symbol::got_offset_): Removed.
6661         (Symbol::tls_mod_got_offset_): Removed.
6662         (Symbol::tls_pair_got_offset_): Removed.
6663         (Symbol::got_offsets_): New field.
6664         (Symbol::has_got_offset): Removed.
6665         (Symbol::has_tls_mod_got_offset): Removed.
6666         (Symbol::has_tls_pair_got_offset): Removed.
6667         * x86_64.cc (Target_x86_64::Got_type): New enum declaration.
6668         (Target_x86_64::Scan::local): Updated callers of Output_data_got
6669         member functions.
6670         (Target_x86_64::Scan::global): Likewise.
6671         (Target_x86_64::Relocate::relocate): Likewise.
6672         (Target_x86_64::Relocate::relocate_tls): Likewise.
6673
6674 2008-03-25  Ben Elliston  <bje@au.ibm.com>
6675
6676         * yyscript.y: Fix spelling error in comment.
6677
6678 2008-03-24  Ian Lance Taylor  <iant@google.com>
6679
6680         * options.h (class General_options): Define build_id option.
6681         * layout.h (class Layout): Declare write_build_id, create_note,
6682         create_build_id.  Add build_id_note_ member.
6683         * layout.cc: Include <cerrno>, <fcntl.h>, <unistd.h>,
6684         "libiberty.h", "md5.h", "sha1.h".
6685         (Layout::Layout): Initialize eh_frame_data_,
6686         eh_frame_hdr_section_, and build_id_note_.
6687         (Layout::finalize): Call create_build_id.
6688         (Layout::create_note): New function, broken out of
6689         Layout::create_gold_note.
6690         (Layout::create_gold_note): Call create_note.
6691         (Layout::create_build_id): New function.
6692         (Layout::write_build_id): New function.
6693         (Close_task_runner::run): Call write_build_id.
6694
6695         * x86_64.cc: Correct license to GPLv3.
6696
6697 2008-03-23  Ian Lance Taylor  <iant@google.com>
6698
6699         * options.cc: Include "demangle.h".
6700         (parse_optional_string): New function.
6701         (parse_long_option): Handle takes_optional_argument.
6702         (parse_short_option): Update dash_z initializer.  Handle
6703         takes_optional_argument.
6704         (General_options::General_options): Initialize do_demangle_.
6705         (General_options::finalize): Set do_demangle_.  Handle demangling
6706         style.
6707         * options.h (parse_optional_string): Declare.
6708         (struct One_option): Add optional_arg field.  Update constructor.
6709         Update call constructor calls.  Add takes_optional_argument
6710         function.
6711         (DEFINE_var): Add optional_arg__ parameter.  Change all callers.
6712         (DEFINE_optional_string): Define.
6713         (General_options::demangle): Change from DEFINE_bool to
6714         DEFINE_optional_string.
6715         (General_options::no_demangle): New function.
6716         (General_options::do_demangle): New function.
6717         (General_options::set_do_demangle): New function.
6718         (General_options::execstack_status_): Move definition to end of
6719         class definition.
6720         (General_options::static_): Likewise.
6721         (General_options::do_demangle_): New field.
6722         * object.cc (big_endian>::get_symbol_location_info): Call
6723         Options::do_demangle, not Options::demangle.
6724         * symtab.cc (demangle): Likewise.
6725
6726 2008-03-22  Ian Lance Taylor  <iant@google.com>
6727
6728         * gold.h: Include <cstddef> and <sys/types.h>
6729         * options.h: Include <cstring>.
6730
6731 2008-03-21  Ian Lance Taylor  <iant@google.com>
6732
6733         * Added source code to GNU binutils.