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