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