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