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