OSDN Git Service

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