OSDN Git Service

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