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