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