elfcpp:/
[external/binutils.git] / gold / ChangeLog
1 2009-03-01  Ian Lance Taylor  <iant@google.com>
2
3         * configure.ac: Check for byteswap.h.
4         * configure: Rebuild.
5         * config.in: Rebuild.
6
7 2009-03-01  Mikolaj Zalewski  <mikolajz@google.com>
8
9         * layout.cc (Layout::find_or_add_kept_section): New function.
10         (Layout::add_comdat): Removed.
11         * layout.h (struct Kept_section): Move out of class Layout.
12         Remove trailing underscores from field names.  Add group_sections
13         field.  Rename group_ field to is_group.  Change all uses.
14         (class Layout): Declare find_or_add_kept_section, not add_comdat.
15         * object.cc (Sized_relobj::Sized_relobj): Don't initialize
16         comdat_groups_ field.
17         (Sized_relobj::include_section_group): Use
18         find_or_add_kept_section and Kept_section::group_sections.
19         (Sized_relobj::include_linkonce_section): Likewise.
20         * object.cc (class Sized_relobj): Don't define Comdat_group or
21         Comdat_group_table.  Remove find_comdat_group and
22         add_comdat_group.  Remove comdat_groups_ field.
23         * plugin.cc (include_comdat_group): Use
24         Layout::find_or_add_kept_section.
25
26 2009-02-28  Ian Lance Taylor  <iant@google.com>
27
28         * README: --gc-sections and map files are now supported.  Document
29         some build requirements.
30
31         PR 6992
32         * symtab.cc (Symbol_table::sized_write_section_symbol): In a
33         relocatable link set the value of the section symbol to zero.
34         * object.cc (Sized_relobj::do_finalize_local_symbols): In a
35         relocatable link don't include the section address in the local
36         symbol value.
37
38 2009-02-27  Ian Lance Taylor  <iant@google.com>
39
40         PR 6811
41         * options.h (class Search_directory): Add is_system_directory.
42         (class General_options): Declare is_in_system_directory.
43         * options.cc (get_relative_sysroot): Make static.
44         (get_default_sysroot): Make static.
45         (General_optoins::is_in_system_directory): New function.
46         * fileread.cc (Input_file::is_in_system_directory): New function.
47         * fileread.h (class Input_file): Declare is_in_system_directory.
48         * object.h (class Object): Add is_in_system_directory.
49         (class Input_objects): Remove system_library_directory_ field.
50         * object.cc (Input_objects::add_object): Don't set
51         system_library_directory_.
52         (input_objects::found_in_system_library_directory): Remove.
53         * symtab.cc (Symbol_table::write_globals): Remove input_objects
54         parameter.  Change all callers.
55         (Symbol_table::sized_write_globals): Likewise.
56         (Symbol_table::warn_about_undefined_dynobj_symbol): Likewise.
57         Call Object::is_in_system_directory.
58         * symtab.h (class Symbol_table): Update declarations.
59
60         PR 5990
61         * descriptors.h (Open_descriptor): Add is_on_stack field.
62         * descriptors.cc (Descriptors::open): If the descriptor is on the
63         top of the stack, remove it.  Initialize is_on_stack field.
64         (Descriptors::release): Only add pod to stack if it is not on the
65         stack already.
66         (Descriptors::close_some_descriptor): Clear stack_next and
67         is_on_stack fields.
68
69         PR 7091
70         * output.cc (Output_section::find_starting_output_address): Rename
71         from starting_output_address; add PADDR parameter; change return
72         type.
73         * output.h (class Output_section): Declare
74         find_starting_output_address instead of starting_output_address.
75         * object.cc (Sized_relobj::do_finalize_local_symbols): Handle a
76         section symbol for which we can't find a merge section.
77
78         PR 9836
79         * symtab.cc (Symbol_table::add_from_object): If the visibility is
80         hidden or internal, force the symbol to be local.
81         * resolve.cc (Symbol::override_visibility): Define.
82         (Symbol::override_base): Use override_visibility.
83         (Symbol_table::resolve): Likewise.
84         (Symbol::override_base_with_special): Likewise.
85         (Symbol_table::override_with_special): If the visibility is hidden
86         or internal, force the symbol to be local.
87         * symtab.h (class Symbol): Add set_visibility and
88         override_visibility.
89         * testsuite/ver_test_1.sh: New file.
90         * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh.
91         (check_DATA): Add ver_test_1.syms.
92         (ver_test_1.syms): New target.
93         * testsuite/Makefile.in: Rebuild.
94
95 2009-02-25  Cary Coutant  <ccoutant@google.com>
96
97         * layout.cc (Layout::choose_output_section): Don't rename sections
98         when using a linker script that has a SECTIONS clause.
99         * Makefile.in: Regenerate.
100
101         * testsuite/Makefile.am (script_test_5.sh): New test case.
102         * testsuite/Makefile.in: Regenerate.
103         * testsuite/script_test_5.cc: New file.
104         * testsuite/script_test_5.sh: New file.
105         * testsuite/script_test_5.t: New file.
106
107 2009-02-13  Rafael Avila de Espindola  <espindola@google.com>
108
109         * archive.cc (Archive::include_member): Update calls to add_symbols.
110         * dynobj.cc (Sized_dynobj<size, big_endian>::make_version_map): Add
111         the Layout argument.
112         * dynobj.h (do_add_symbols): Add the Layout argument.
113         * object.cc (Sized_relobj<size, big_endian>::do_add_symbols): Add the
114         Layout argument.
115         * object.h (Object::add_symbols): Add the Layout argument.
116         (Object::do_add_symbols): Add the Layout argument.
117         (Sized_relobj::do_add_symbols): Add the Layout argument.
118         * plugin.cc (Sized_pluginobj<size, big_endian>::do_add_symbols):
119         Unify the two versions.
120         (Add_plugin_symbols): Remove.
121         * plugin.h (Pluginobj::add_symbols, Pluginobj::do_add_symbols): Remove.
122         (Sized_pluginobj::do_add_symbols): Unify the two versions.
123         (Add_plugin_symbols): Remove.
124         * readsyms.cc (Read_symbols::do_read_symbols): Update call to
125         Add_symbols. Use Add_symbols instead of Add_plugin_symbols.
126         (Add_symbols::run): Make it work with Pulginobj.
127
128 2009-02-06  Ian Lance Taylor  <iant@google.com>
129
130         * object.cc (Sized_relobj::do_layout): Make info message start
131         with lower case letter.
132
133 2009-02-06  Mikolaj Zalewski  <mikolajz@google.com>
134
135         * binary.cc: Fix file comment.
136
137         * options.h (enum Incremental_disposition): Define.
138         (class General_options): Add new options: --incremental,
139         --incremental_changed, --incremental_unchanged,
140         --incremental_unknown.  Add incremental_disposition_ and
141         implicit_incremental_ fields.
142         (General_options::incremental_disposition): New function.
143         (class Position_dependent_options): Add incremental_disposition
144         option.
145         (Position_dependent_options::copy_from_options): Set incremental
146         dispositions.
147         * options.cc (General_options::parse_incremental_changed): New
148         function.
149         (General_options::parse_incremental_unchanged): New function.
150         (General_options::parse_incremental_unknown): New function.
151         (General_options::General_options): Initialize new fields
152         incremental_disposition_ and implicit_incremental_.
153         (General_options::finalize): Check for uasge of --incremental-*
154         without --incremental.
155
156 2009-02-06  Chris Demetriou  <cgd@google.com>
157
158         * gold.h (gold_undefined_symbol): Change to take only a Symbol
159         pointer and to report location as the file name associated with
160         the symbol.
161         (gold_undefined_symbol_at_location): New function to replace the
162         old gold_undefined_symbol functionality.
163         * target-reloc.h (relocate_section): Update to use
164         gold_undefined_symbol_at_location.
165         * symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
166         Call gold_undefined_symbol function rather than gold_error.
167         * errors.h (Errors::undefined_symbol): Take location as a
168         string, rather than calculating it from a relocation.
169         * errors.cc (Errors::fatal): Print "fatal error:" before the
170         formatted message.
171         (Errors::error, Errors::error_at_location): Print "error: "
172         before the formatted message.
173         (Errors::undefined_symbol): Take location as a string, rather
174         than calculating it from a relocation.
175         (gold_undefined_symbol_at_location): New function akin to
176         old gold_undefined_symbol, calculates location from relocation.
177         (gold_undefined_symbol): Change to take only a Symbol pointer
178         and to report location as the file name associated with the symbol.
179         * testsuite/debug_msg.sh: Update for changed error messages.
180         * testsuite/undef_symbol.sh: Likewise.
181
182 2009-02-04  Duncan Sands  <baldrick@free.fr>
183
184         PR 9812
185         * reduced_debug_output.h
186         (Output_reduced_debug_abbrev_section::failed): Use format for
187         gold_warning.
188         (Output_reduced_debug_info_section::faild): Likewise.
189
190 2009-01-31  Mikolaj Zalewski  <mikolajz@google.com>
191
192         * script.cc (Lazy_demangler): New class.
193         (Version_script_info::get_symbol_version_helper): Demangle a
194         symbol only once.
195
196 2009-01-29  Cary Coutant  <ccoutant@google.com>
197
198         * i386.cc (Target_i386::Relocate::relocate): Recognize non-PIC calls
199         to __tls_get_addr.
200         * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
201
202 2009-01-28  Ian Lance Taylor  <iant@google.com>
203
204         * version.cc (version_string): Bump to 1.9.
205
206         * gold.h: Include <cstring> and <stdint.h>.
207         * version.cc: Include <cstdio>.
208         * object.cc (Sized_relobj::do_layout): Initialize gc_sd to avoid a
209         warning.
210         * reduced_debug_output.cc (insert_into_vector): Rename from
211         Insert_into_vector; change all callers.  Use Swap_unaligned to
212         avoid aliasing issue; remove union since it is unnecessary.
213
214 2009-01-27  Sriraman Tallam  <tmsriram@google.com>
215
216         * Makefile.am (CCFILES): Add gc.cc.
217         (HFILES): Add gc.h.
218         * Makefile.in: Regenerate.
219         * gold.cc (Gc_runner): New class.
220         (queue_initial_tasks): Call garbage collection related tasks
221         when corresponding options are invoked.
222         (queue_middle_gc_tasks): New function.
223         (queue_middle_tasks): Reorder tasks to allow relocs to be read and
224         processed early before laying out sections during garbage collection.
225         * gold.h (queue_middle_gc_tasks): New function.
226         (is_prefix_of): Move from "layout.cc".
227         * i386.cc (Target_i386::gc_process_relocs): New function.
228         * layout.cc (is_prefix_of): Remove. Move to "gold.h"
229         * main.cc (main): Create object of class "Garbage_collection".
230         * object.cc (Relobj::copy_symbols_data): New function.
231         (Relobj::is_section_name_included): New function.
232         (Sized_relobj::do_layout): Allow this function to be called twice 
233         during garbage collection and defer layout of section during the 
234         first call.
235         * object.h (Relobj::get_symbols_data): New function.
236         (Relobj::is_section_name_included): New function.
237         (Relobj::copy_symbols_data): New function.
238         (Relobj::set_symbols_data): New function.
239         (Relobj::get_relocs_data): New function.
240         (Relobj::set_relocs_data): New function.
241         (Relobj::is_output_section_offset_invalid): New pure virtual function.
242         (Relobj::gc_process_relocs): New function.
243         (Relobj::do_gc_process_relocs): New pure virtual function.
244         (Relobj::sd_): New data member.
245         (Sized_relobj::is_output_section_offset_invalid): New function.
246         (Sized_relobj::do_gc_process_relocs): New function.
247         * options.h (General_options::gc_sections): Modify to not be a no-op.
248         (General_options::print_gc_sections): New option.
249         * plugin.cc (Plugin_finish::run): Remove function call to
250         Plugin_manager::layout_deferred_objects.  Move it to "gold.cc".
251         * powerpc.cc (Target_powerpc::gc_process_relocs): New function.
252         * reloc.cc (Read_relocs::run): Add task to process relocs and
253         determine unreferenced sections when doing garbage collection.
254         (Gc_process_relocs): New class.
255         (Sized_relobj::do_gc_process_relocs): New function.
256         (Sized_relobj::do_scan_relocs): Don't try to scan the relocs for
257         sections that are garbage collected.
258         * reloc.h (Gc_process_relocs): New class.
259         * sparc.cc (Target_sparc::gc_process_relocs): New function.
260         * symtab.cc (Symbol::should_add_dynsym_entry): Do not add entries for
261         symbols whose corresponding sections are garbage collected.
262         (Symbol_table::Symbol_table): Add new parameter for the garbage
263         collection object.
264         (Symbol_table::gc_mark_undef_symbols): New function.
265         (Symbol_table::gc_mark_symbol_for_shlib): New function.
266         (Symbol_table::gc_mark_dyn_syms): New function.
267         (Symbol_table::resolve): Do not treat symbols seen in dynamic objects
268         as garbage.
269         (Symbol_table::add_from_object): Likewise.
270         (Symbol_table::add_from_relobj): When building shared objects, do not
271         treat externally visible symbols as garbage.
272         (Symbol_table::sized_finalize_symbol): Do not check dynamic symbol
273         table information for static and relocatable links.
274         * symtab.h (Symbol_table::set_gc): New function.
275         (Symbol_table::gc): New function.
276         (Symbol_table::gc_mark_undef_symbols): New function.
277         (Symbol_table::gc_mark_symbol_for_shlib): New function.
278         (Symbol_table::gc_mark_dyn_syms): New function.
279         (Symbol_table::gc_): New data member.
280         * target.h (Sized_target::gc_process_relocs): New pure virtual 
281         function.
282         * x86_64.cc (Target_x86_64::gc_process_relocs): New function.
283         * testsuite/testfile.cc (Target_test::gc_process_relocs): New function.
284
285 2009-01-20  Chris Faylor <me.sourceware@sourceware.org>
286
287         * options.h (General_options::gc_sections): Define as a no-op for now.
288         (General_options::no_keep_memory): Ditto.
289         (General_options::Bshareable): Define.
290         * options.cc (General_options::finalize): Honor -Bshareable.
291
292 2009-01-20  Andreas Schwab  <schwab@suse.de>
293
294         * powerpc.cc (Powerpc_relocate_functions::rel16_ha): Don't try to
295         read the value in the contents, since we don't use it.  Use the
296         template endianness when writing.
297         (Relocate::relocate): Use it for R_PPC_REL16_HA.
298
299 2009-01-19  Andreas Schwab  <schwab@suse.de>
300
301         * configure.tgt (powerpc64-*): Fix targ_obj.
302
303 2009-01-15  Ian Lance Taylor  <iant@google.com>
304
305         * object.cc (Sized_relobj::write_local_symbols): Don't write out
306         local symbols when stripping all symbols.
307
308 2009-01-14  Cary Coutant  <ccoutant@google.com>
309
310         * output.cc (Output_reloc): Add explicit instantiations.
311
312 2009-01-14  Cary Coutant  <ccoutant@google.com>
313
314         * archive.cc (Archive::get_elf_object_for_member): Remove call
315         to File_read::claim_for_plugin.
316         * descriptors.cc (Descriptors::open): Remove reference to
317         is_claimed.
318         (Descriptors::claim_for_plugin): Remove.
319         * descriptors.h (Descriptors::claim_for_plugin): Remove.
320         (Descriptors::is_claimed): Remove.
321         (claim_descriptor_for_plugin): Remove.
322         * fileread.cc (File_read::claim_for_plugin): Remove.
323         * fileread.h (File_read::claim_for_plugin): Remove.
324         (File_read::descriptor): Reopen descriptor if necessary.
325         * plugin.cc  (Plugin::load): Add two new APIs to transfer vector.
326         (Plugin_manager::all_symbols_read): Add task parameter. Change
327         all callers.
328         (Plugin_manager::get_input_file): New function.
329         (Plugin_manager::release_input_file): New function.
330         (Pluginobj::Pluginobj): Add filesize parameter and initialize
331         corresponding data member.
332         (Sized_pluginobj::Sized_pluginobj): Add filesize parameter
333         and pass to base constructor. Change all callers.
334         (get_input_file, release_input_file): New functions.
335         (make_sized_plugin_object): Add filesize parameter. Change all callers.
336         * plugin.h (Plugin_manager::Plugin_manager): Initialize task_ member.
337         (Plugin_manager::all_symbols_read): Add task parameter.
338         (Plugin_manager::get_input_file): New function.
339         (Plugin_manager::release_input_file): New function.
340         (Plugin_manager::task_): New data member.
341         (Pluginobj::Pluginobj): Add filesize parameter.
342         (Pluginobj::filename): New function.
343         (Pluginobj::descriptor): New function.
344         (Pluginobj::filesize): New function.
345         (Pluginobj::filesize_): New data member.
346         (Sized_pluginobj::Sized_pluginobj): Add filesize parameter.
347         * readsyms.cc (Read_symbols::do_read_symbols): Remove call to
348         File_read::claim_for_plugin; use Object::unlock to unlock the file.
349
350         * testsuite/Makefile.am (plugin_test_4): New test case for plugins
351         with archive libraries.
352         * testsuite/Makefile.in: Regenerate.
353         * testsuite/plugin_test.c (struct sym_info): New type.
354         (get_input_file, release_input_file): New static variables.
355         (onload): Capture new transfer vector entries.
356         (claim_file_hook): Stop reading at end of file according to filesize.
357         Factor out parsing of readelf output into separate function.
358         (all_symbols_read_hook): Exercise get_input_file and release_input_file
359         APIs and get the source file name from the symbol table.  Convert
360         source file name to corresponding object file name.  Print info
361         message when adding new input files.
362         (parse_readelf_line): New function.
363         * testsuite/plugin_test_1.sh: Add checks for new info messages.
364         * testsuite/plugin_test_2.sh: Likewise.
365         * testsuite/plugin_test_3.sh: Likewise.
366         * testsuite/plugin_test_4.sh: New test case.
367
368 2009-01-07  Ian Lance Taylor  <iant@google.com>
369
370         * version.cc (version_string): Bump to 1.8.
371
372 2008-12-23  Cary Coutant  <ccoutant@google.com>
373
374         * gold.cc (gold_exit): Call plugin cleanup handlers on exit.
375         * plugin.cc (Plugin_manager::finish): Rename as
376         layout_deferred_objects.  Move cleanup to separate function.
377         (Plugin_manager::cleanup): New function.
378         (Plugin_finish::run): Call layout_deferred_objects and cleanup
379         separately.
380         * plugin.h (Plugin_manager::finish): Rename as
381         layout_deferred_objects.
382         (Plugin_manager::cleanup): New function.
383         (Plugin_manager::cleanup_done): New field.
384
385 2008-12-23  Cary Coutant  <ccoutant@google.com>
386
387         * plugin.cc (is_visible_from_outside): New function.
388         (Pluginobj::get_symbol_resolution_info): Call is_visible_from_outside
389         so we don't return "IR only" status for exported symbols or -r links.
390
391         * testsuite/Makefile.am (plugin_test_3): New test case.
392         * testsuite/Makefile.in: Regenerate.
393         * testsuite/plugin_test_3.sh: New file.
394
395 2008-12-22  Cary Coutant  <ccoutant@google.com>
396
397         * object.cc (Sized_relobj::layout_section): New function.
398         (Sized_relobj::do_layout): Defer layout of input sections until after
399         plugin has provided replacement files.
400         (Sized_relobj::do_layout_deferred_sections): New function.
401         * object.h (Relobj::set_section_offset): Remove virtual keyword.
402         (Relobj::layout_deferred_sections): New function.
403         (Relobj::do_layout_deferred_sections): New function.
404         (Sized_relobj::do_layout_deferred_sections): New function.
405         (Sized_relobj::layout_section): New function.
406         (Sized_relobj::Deferred_layout): New structure.
407         (Sized_relobj::deferred_layout_): New field.
408         * plugin.cc (Plugin_manager::finish): Renamed, was cleanup.
409         Change all callers.  Layout deferred sections.
410         (class Plugin_finish): Renamed, was Plugin_cleanup.  Change all
411         references.
412         (Plugin_hook::run): Move code from do_plugin_hook inline.
413         (Plugin_hook::do_plugin_hook): Remove.
414         * plugin.h (Plugin_manager::Plugin_manager): Add missing initializers.
415         (Plugin_manager::finish): Renamed, was cleanup.
416         (Plugin_manager::should_defer_layout): New function.
417         (Plugin_manager::add_deferred_layout_object): New function.
418         (Plugin_manager::Deferred_layout_list): New type.
419         (Plugin_manager::deferred_layout_objects_): New field.
420         (Plugin_hook::do_plugin_hook): Remove.
421
422 2008-12-17  Ian Lance Taylor  <iant@google.com>
423
424         * options.h (class General_options): Add --no case for
425         --export-dynamic.
426
427 2008-12-16  Cary Coutant  <ccoutant@google.com>
428
429         * plugin.cc (Plugin::load): Move LDPT_MESSAGE to front of transfer
430         vector.
431         (Plugin_manager::claim_file): Create plugin object even if
432         plugin did not call the add_symbols callback.
433         (Plugin_obj::get_symbol_resolution_info): Guard against plugin
434         asking for more symbols than were added.
435         * testsuite/Makefile.am (plugin_test_1): Add test case with
436         no global symbols.
437         (empty.syms): New target.
438         * testsuite/Makefile.in: Regenerate.
439         * testsuite/plugin_test.c (claim_file_hook): Add new debug
440         message. Don't call add_symbols if no globals.
441         (all_symbols_read_hook): Don't provide replacement for empty
442         claimed file.
443
444 2008-12-12  Ian Lance Taylor  <iant@google.com>
445
446         * target-reloc.h (Default_scan_relocatable_relocs): Only discard
447         r_type == 0 for a local symbol with r_sym == 0.
448         (scan_relocatable_relocs): Pass r_sym to
449         local_non_section_strategy.
450         * reloc.cc (Emit_relocs_strategy::local_non_section_strategy): Add
451         r_sym parameter.
452
453         * configure.ac: Update test for TLS descriptors: they are
454         supported as of glibc 2.9.
455         * configure: Rebuild.
456
457 2008-12-11  Ian Lance Taylor  <iant@google.com>
458
459         PR 7091
460         * target-reloc.h (Default_scan_relocatable_relocs): For each
461         function, map r_type == 0 to RELOC_DISCARD.
462
463 2008-12-10  Cary Coutant  <ccoutant@google.com>
464
465         * layout.cc (Layout::add_comdat): Allow COMDAT group from a replacement
466         object to override a kept COMDAT group from a plugin object.
467
468 2008-12-09  Ian Lance Taylor  <iant@google.com>
469
470         PR 7088
471         * yyscript.y (file_cmd): Handle INPUT.
472
473         * testsuite/initpri1.c: Change all declarations to be full
474         prototypes by adding void, to avoid compiler warnings.
475
476 2008-12-05  Rafael Avila de Espindola  <espindola@google.com>
477
478         * options.cc (General_options::parse_plugin_opt): New.
479         (General_options::add_plugin): The argument now is just the filename.
480         (General_options::add_plugin_option): New.
481         * options.h (plugin_opt): New.
482         (add_plugin): Change argument name.
483         (add_plugin_option): New.
484         * plugin.cc (Plugin::load): Don't parse the plugin option.
485         * plugin.h (Plugin::Plugin): Rename argument. Init filename_.
486         (Plugin::add_option): New.
487         (Plugin::args_): Change type.
488         (Plugin::filename_): New.
489         (Plugin_manager::add_plugin_option): New.
490         * testsuite/Makefile.am (plugin_test_1): Use new syntax.
491         * testsuite/Makefile.in: Regenerate.
492
493 2008-12-05  Cary Coutant  <ccoutant@google.com>
494
495         * layout.cc (Layout::include_section): Check for SHF_EXCLUDE.
496         Handle --strip-lto-sections option.
497         * options.h (strip_lto_sections): New option.
498
499 2008-12-01  Cary Coutant  <ccoutant@google.com>
500
501         * plugin.cc (ld_plugin_message): Change format parameter to const.
502         Fix mismatch between new[] and delete.
503
504 2008-11-14  Cary Coutant  <ccoutant@google.com>
505
506         * reloc.cc (Sized_relobj::do_read_relocs): Use constant invalid_address
507         instead of -1U.
508
509 2008-11-05  Craig Silverstein  <csilvers@google.com>
510
511         * options.cc (General_options::parse_dynamic_list): New function.
512         * options.h (General_options): New flags dynamic_list,
513         dynamic_list_data, dynamic_list_cpp_new, and
514         dynamic_list_cpp_typeinfo.  New variable dynamic_list_.
515         (General_options::in_dynamic_list): New function.
516         * script.cc (Lex::Mode): New enum DYNAMIC_LIST.
517         (Lex::can_start_name): Add support for DYNAMIC_LIST mode.
518         (Lex::can_continue_name): Likewise.
519         (yylex): Likewise.
520         (read_script_file): New parameter script_options.
521         (read_dynamic_list): New function.
522         (Script_options::define_dynamic_list): New function.
523         (dynamic_list_keyword_parsecodes): New variable.
524         (dynamic_list_keywords): New variable.
525         * script.h (Script_options::define_dynamic_list): New function
526         prototype.
527         (read_dynamic_list): New function prototype.
528         * symtab.cc (strprefix): New macro.
529         (Symbol::should_add_dynsym_entry): Support dynamic_list,
530         dynamic_list_data, dynamic_list_cpp_new, and
531         dynamic_list_cpp_typeinfo.
532         * yyscript.y (PARSING_DYNAMIC_LIST): New token.
533         (dynamic_list_expr): New rule.
534         (dynamic_list_nodes): Likewise.
535         (dynamic_list_node): Likewise.
536         * testsuite/Makefile.am (dynamic_list): New test.
537         * testsuite/Makefile.in: Regenerated.
538         * testsuite/dynamic_list.t: New file.
539         * testsuite/dynamic_list.sh: New file.
540
541 2008-11-05  Craig Silverstein  <csilvers@google.com>
542
543         * testsuite/tls_test_c.c: Add prototype for t11 and t11_last.
544         * testsuite/tls_test_c.c (t11): Add explicit "void" to prototype.
545         (t11_last): Likewise.
546         * testsuite/ver_test_6.c (main): Likewise.
547
548 2008-10-07  Cary Coutant  <ccoutant@google.com>
549
550         * options.c (General_options::finalize): Add check for -static and
551         -shared.
552         * gold.cc (queue_middle_tasks): Assert that list of dynamic objects
553         is not empty.
554
555 2008-10-02  Cary Coutant  <ccoutant@google.com>
556
557         * plugin.cc (make_sized_plugin_object): Fix conditional
558         compilation to work when not all targets are enabled.
559
560 2008-09-29  Cary Coutant  <ccoutant@google.com>
561
562         * archive.cc (Archive::get_file_and_offset): Use filename instead
563         of name to get library path.
564         (Archive::include_member): Unlock external member of a thin archive.
565
566         * testsuite/Makefile.am (TEST_AR): New variable.
567         (thin_archive_test_1): New test.
568         (thin_archive_test_2): New test.
569         * testsuite/Makefile.in: Regenerate.
570         * testsuite/thin_archive_main.cc: New file.
571         * testsuite/thin_archive_test_1.cc: New file.
572         * testsuite/thin_archive_test_2.cc: New file.
573         * testsuite/thin_archive_test_3.cc: New file.
574         * testsuite/thin_archive_test_4.cc: New file.
575
576 2008-09-29  Cary Coutant  <ccoutant@google.com>
577
578         * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.
579         * object.cc (Sized_relobj::do_layout): Use constant invalid_address
580         instead of -1U.
581         (Sized_relobj::do_finalize_local_symbols): Likewise.
582         (Sized_relobj::map_to_kept_section): Likewise.
583         * object.h (Sized_relobj::invalid_address): New constant.
584         (Sized_relobj::do_output_section_offset): Check for invalid_address
585         and return -1ULL.
586         * output.cc (Output_reloc::local_section_offset): Use constant
587         invalid_address instead of -1U.
588         (Output_reloc::get_address): Likewise.
589         (Output_section::output_address): Change -1U to -1ULL.
590         * output.h (Output_reloc::invalid_address): New constant.
591         * reloc.cc (Sized_relobj::write_sections): Use constant
592         invalid_address instead of -1U.
593         (Sized_relobj::relocate_sections): Likewise.
594         * symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
595         values for merge sections.
596         * target-reloc.h (relocate_for_relocatable): Use constant
597         invalid_address instead of -1U.
598
599 2008-09-19  Cary Coutant  <ccoutant@google.com>
600
601         Add plugin functionality for link-time optimization (LTO).
602         * configure.ac (plugins): Add --enable-plugins option.
603         * configure: Regenerate.
604         * config.in: Regenerate.
605         * Makefile.am (LIBDL): New variable.
606         (CCFILES): Add plugin.cc.
607         (HFILES): Add plugin.h.
608         (ldadd_var): Add LIBDL.
609         * Makefile.in: Regenerate.
610
611         * archive.cc: Include "plugin.h".
612         (Archive::setup): Don't preread archive symbols when using a plugin.
613         (Archive::get_file_and_offset): Add memsize parameter.  Change callers.
614         (Archive::get_elf_object_for_member): Call plugin hooks for claiming
615         files.
616         (Archive::include_member): Add symbols from plugin objects.
617         * archive.h (Archive::get_file_and_offset): Add memsize parameter.
618         * descriptors.cc (Descriptors::open): Check for file descriptors
619         abandoned by plugins.
620         (Descriptors::claim_for_plugin): New function.
621         * descriptors.h (Descriptors::claim_for_plugin): New function.
622         (Open_descriptor::is_claimed): New field.
623         (claim_descriptor_for_plugin): New function.
624         * fileread.cc (File_read::claim_for_plugin): New function.
625         * fileread.h (File_read::claim_for_plugin): New function.
626         (File_read::descriptor): New function.
627         * gold.cc: Include "plugin.h".
628         (queue_initial_tasks): Add task to call plugin hooks for generating
629         new object files.
630         * main.cc: Include "plugin.h".
631         (main): Load plugin libraries.
632         * object.h (Pluginobj): Declare.
633         (Object::pluginobj): New function.
634         (Object::do_pluginobj): New function.
635         (Object::set_target): New function.
636         * options.cc: Include "plugin.h".
637         (General_options::parse_plugin): New function.
638         (General_options::General_options): Initialize plugins_ field.
639         (General_options::add_plugin): New function.
640         * options.h (Plugin_manager): Declare.
641         (General_options): Add --plugin option.
642         (General_options::has_plugins): New function.
643         (General_options::plugins): New function.
644         (General_options::add_plugin): New function.
645         (General_options::plugins_): New field.
646         * plugin.cc: New file.
647         * plugin.h: New file.
648         * readsyms.cc: Include "plugin.h".
649         (Read_symbols::do_read_symbols): Check for archive before checking
650         for ELF file.  Call plugin hooks to claim files.
651         * resolve.cc (Symbol_table::resolve): Record when symbol is referenced
652         from a real object file; force override when processing replacement
653         files.
654         * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field.
655         (Symbol::init_base_object): Likewise.
656         (Symbol::init_base_output_data): Likewise.
657         (Symbol::init_base_output_segment): Likewise.
658         (Symbol::init_base_constant): Likewise.
659         (Symbol::init_base_undefined): Likewise.
660         (Symbol::output_section): Assert that object is not a plugin.
661         (Symbol_table::add_from_pluginobj): New function.
662         (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as
663         undefined.
664         (Symbol_table::sized_write_globals): Likewise.
665         (Symbol_table::add_from_pluginobj): Instantiate template.
666         * symtab.h (Sized_pluginobj): Declare.
667         (Symbol::in_real_elf): New function.
668         (Symbol::set_in_real_elf): New function.
669         (Symbol::in_real_elf_): New field.
670         (Symbol_table::add_from_pluginobj): New function.
671
672         * testsuite/Makefile.am (AM_CFLAGS): New variable.
673         (LIBDL): New variable.
674         (LDADD): Add LIBDL.
675         (check_PROGRAMS): Add plugin_test_1 and plugin_test_2.
676         (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh.
677         (check_DATA): Add plugin_test_1.err and plugin_test_2.err.
678         (MOSTLYCLEANFILES): Likewise.
679         * testsuite/Makefile.in: Regenerate.
680         * testsuite/plugin_test.c: New file.
681         * testsuite/plugin_test_1.sh: New file.
682         * testsuite/plugin_test_2.sh: New file.
683
684 2008-09-16  Ian Lance Taylor  <iant@google.com>
685
686         * target-reloc.h (relocate_section): Check whether a symbol is
687         defined by the ABI before reporting an undefined symbol error.
688         * target.h (Target::is_defined_by_abi): Make parameter const.
689         (Target::do_is_defined_by_abi): Likewise.
690         * i386.cc (Target_i386::do_is_defined_by_abi): Likewise.
691         * powerpc.cc (Target_powerpc::do_is_defined_by_abi): Likewise.
692         * sparc.cc (Target_sparc::do_is_defined_by_abi): Likewise.
693         * x86_64.cc (Target_x86_64::do_is_defined_by_abi): Likewise.
694         * testsuite/Makefile.am (tls_test_shared.so): Add -Wl,-z,defs.
695         * testsuite/Makefile.in: Rebuild.
696
697         * fileread.cc (make_view): Add casts to avoid warning.
698
699 2008-09-16  Alexandre Oliva  <aoliva@redhat.com>
700
701         * i386.cc (Target_i386::define_tls_base_symbol): Update comments.
702         * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
703
704 2008-09-16  Alexandre Oliva  <aoliva@redhat.com>
705
706         * options.h (General_options::output_is_executable): New.
707         (General_options::output_is_pie): New.
708         * i386.cc (Target_i386::define_tls_base_symbol): Use SEGMENT_START
709         for shared libraries.
710         * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
711
712 2008-09-11  Chris Demetriou  <cgd@google.com>
713
714         * options.h (origin): New -z option.
715         * layout.cc (Layout:finish_dynamic_section): If "-z origin"
716         is specified, set DF_ORIGIN in DT_FLAGS and set DF_1_ORIGIN
717         in DT_FLAGS_1.
718
719 2008-09-05  Cary Coutant  <ccoutant@google.com>
720
721         * fileread.cc (File_read::make_view): Add check for attempt to map
722         beyond end of file.
723
724 2008-09-05  Cary Coutant  <ccoutant@google.com>
725
726         * symtab.cc (Symbol_table::add_from_dynobj): Fix typos in
727         explicit instantiations.
728
729 2008-08-28  Kris Van Hees  <kris.van.hees@oracle.com>
730
731         PR gold/6858
732         * options.cc (General_options::finalize): Allow undefined symbols
733         in shlibs if linking -shared.
734
735         PR gold/6859
736         * symtab.cc (Symbol::init_base_undefined): Mark explicitly undefined
737         symbols as not needing a dynsym entry.
738
739 2008-08-20  Craig Silverstein  <csilvers@google.com>
740
741         * fileread.cc (File_read::open): Do not lock the file unless it
742         was successfully opened.
743
744 2008-08-14  Cary Coutant  <ccoutant@google.com>
745
746         * x86_64.cc (Target_x86_64::Relocate::relocat_tls):
747         Use addend for DTPOFF32, DTPOFF64, and TPOFF32 relocs.
748         * testsuite/tls_test.cc (struct int128): 128-bit struct
749         for testing TLS relocs with non-zero addend.
750         (v12): New TLS variable.
751         (t12): New test.
752         (t_last): Add check for v12.
753         * testsuite/tls_test.h (t12): New function.
754         * testsuite/tls_test_main.cc (thread_routine): Call new test.
755
756 2008-08-13  Ian Lance Taylor  <iant@google.com>
757
758         * layout.cc (Layout::attach_allocated_section_to_segment): Don't
759         set tls_segment_ or relro_segment_.
760         (Layout::make_output_segment): Set tls_segment_ and relro_segment_
761         when appropriate.
762         * output.h (Output_section::clear_is_relro): New function.
763         * output.cc (Output_segment::add_output_section): Handle SHF_TLS
764         sections specially even when output_data_ is empty.
765         (Output_segment::maximum_alignment): When first section is relro,
766         only force alignment for PT_LOAD segments.
767         * script.cc (script_data_segment_align): New function.
768         (script_data_segment_relro_end): New function.
769         * script-c.h (script_data_segment_align): Declare.
770         (script_data_segment_relro_end): Declare.
771         * script-sections.h (class Script_sections): Declare
772         data_segment_align and data_segment_relro_end.  Add fields
773         segment_align_index_ and saw_relro_end_.
774         * script-sections.cc (class Sections_element): Add set_is_relro
775         virtual function.  Add new bool* parameter to place_orphan_here.
776         Add get_output_section virtual function.
777         (class Output_section_definition): Add set_is_relro.  Add new
778         bool* parameter to place_orphan_here.  Add get_output_section.
779         Add is_relro_ field.
780         (Output_section_definition::Output_section_definition): Initialize
781         evaluated_address_, evaluated_load_address, evaluated_addralign_,
782         and is_relro_ fields.
783         (Output_section_definition::place_orphan_here): Add is_relro
784         parameter.
785         (Output_section_definition::set_section_addresses): Set relro for
786         output section.
787         (Output_section_definition::alternate_constraint): Likewise.
788         (class Orphan_output_section): Add new bool* parameter to
789         place_orphan_here.  Add get_output_section.
790         (Orphan_output_section::place_orphan_here): Add is_relro
791         parameter.
792         (Script_sections::Script_sections): Initialize
793         data_segment_align_index_ and saw_relro_end_.
794         (Script_sections::data_segment_align): New function.
795         (Script_sections::data_segment_relro_end): New function.
796         (Script_sections::place_orphan): Set or clear is_relro.
797         (Script_sections::set_section_addresses): Force alignment of first
798         TLS section.
799         * yyscript.y (exp): Call script_data_segment_align and
800         script_data_segment_relro_end.
801         * testsuite/relro_script_test.t: New file.
802         * testsuite/relro_test.cc (using_script): Declare.
803         (t1, t2): Test using_script.
804         * testsuite/Makefile.am (check_PROGRAMS): Add relro_script_test.
805         (relro_script_test_SOURCES): Define.
806         (relro_script_test_DEPENDENCIES): Define.
807         (relro_script_test_LDFLAGS): Define.
808         (relro_script_test_LDADD): Define.
809         (relro_script_test.so): New target.
810         * testsuite/Makefile.in: Rebuild.
811
812 2008-08-06  Cary Coutant <ccoutant@google.com>
813
814         * archive.cc (Archive::total_archives, Archive::total_members)
815         (Archive::total_members_loaded): New variables.
816         (Archive::setup): Add parameter.  Add option to preread
817         archive symbols.
818         (Archive::read_armap): Add counter.
819         (Archive::get_file_and_offset): New function.
820         (Archive::get_elf_object_for_member): New function.
821         (Archive::read_all_symbols): New function.
822         (Archive::read_symbols): New function.
823         (Archive::add_symbols): Add counters.
824         (Archive::include_all_members): Use armap to find members if it's
825         already built.
826         (Archive::include_member): Skip reading symbols if already read.
827         Factored code into Archive::get_file_and_offset and
828         Archive::get_elf_object_for_member.  Changed call to
829         Mapfile::report_include_archive_member.
830         (Archive::print_stats): New function.
831         * archive.h: Declare Object and Read_symbols_data classes.
832         (Archive::Archive): Add initializers for new members.
833         (Archive::setup): Add parameter.
834         (Archive::print_stats): New function.
835         (Archive::total_archives, Archive::total_members)
836         (Archive::total_members_loaded): New variables.
837         (Archive::get_file_and_offset): New function.
838         (Archive::get_elf_object_for_member): New function.
839         (Archive::read_all_symbols): New function.
840         (Archive::read_symbols): New function.
841         (Archive::Archive_member): New class.
842         (Archive::members_): New member.
843         (Archive::num_members_): New member.
844         * main.cc: Include archive.h.
845         (main): Call Archive::print_stats.
846         * mapfile.cc (Mapfile::report_include_archive_member): Delete
847         archive parameter; member_name is now the fully-decorated name.
848         * mapfile.h (Mapfile::report_include_archive_member): Likewise.
849         * options.h: (General_options): Add --preread-archive-symbols option.
850         * readsyms.cc (Read_symbols::do_read_symbols): Change call to
851         Archive::setup.
852
853 2008-08-04  Ian Lance Taylor  <iant@google.com>
854
855         * symtab.h (Symbol::use_plt_offset): New function.
856         * i386.cc (Relocate::relocate): Call Symbol::use_plt_offset.
857         * powerpc.cc (Relocate::relocate): Likewise.
858         * sparc.cc (Relocate::relocate): Likewise.
859         * x86_64.cc (Relocate::relocate): Likewise.
860         * testsuite/weak_plt.sh: New test.
861         * testsuite/weak_plt_main.cc: New test.
862         * testsuite/weak_plt_shared.cc: New test.
863         * testsuite/Makefile.am (check_SCRIPTS): Add weak_plt.sh.
864         (check_PROGRAMS): Add weak_plt.
865         (check_DATA): Add weak_plt_shared.so.
866         (weak_plt_main_pic.o, weak_plt): New targets.
867         (weak_plt_shared_pic.o, weak_plt_shared.so): New targets.
868         * testsuite/Makefile.in: Rebuild.
869
870         * testsuite/Makefile.am (weak_alias_test_1.so): Depend upon
871         gcctestdir/ld.
872         (weak_alias_test_2.so, weak_alias_test_4.so): Likewise.
873         * testsuite/Makefile.in: Rebuild.
874
875 2008-08-04  Alan Modra  <amodra@bigpond.net.au>
876
877         * Makefile.am (POTFILES.in): Set LC_ALL=C.
878         * Makefile.in: Regenerate.
879         * po/POTFILES.in: Regenerate.
880
881 2008-07-29  Ian Lance Taylor  <iant@google.com>
882
883         * script.cc (Script_options::finalize_symbols): Finalize SECTIONS
884         symbols before other symbols.
885         * testsuite/script_test_2.cc (test_addr): Declare.
886         (test_addr_alias): Declare.
887         (main): Check that test_addr and test_addr_alias have the right
888         values.
889         * testsuite/script_test_2.t: Define test_addr_alias and
890         test_addr.
891
892 2008-07-24  Ian Lance Taylor  <iant@google.com>
893
894         PR 5990
895         * descriptors.cc: New file.
896         * descriptors.h: New file.
897         * gold-threads.h (class Hold_optional_lock): New class.
898         * fileread.cc: Include "descriptors.h".
899         (File_read::~File_read): Release descriptor rather than closing
900         it.
901         (File_read::open) [file]: Call open_descriptor rather than open.
902         Set is_descriptor_opened_.
903         (File_read::open) [memory]: Assert that descriptor is not open.
904         (File_read::reopen_descriptor): New function.
905         (File_read::release): Release descriptor.
906         (File_read::do_read): Make non-const.  Reopen descriptor.
907         (File_read::read): Make non-const.
908         (File_read::make_view): Reopen descriptor.
909         (File_read::do_readv): Likewise.
910         * fileread.h (class File_read): Add is_descriptor_opened_ field.
911         Update declarations.
912         * layout.cc: Include "descriptors.h".
913         (Layout::create_build_id): Use open_descriptor rather than open.
914         * output.cc: Include "descriptors.h".
915         (Output_file::open): Use open_descriptor rather than open.
916         * archive.cc (Archive::const_iterator): Change Archive to be
917         non-const.
918         (Archive::begin, Archive::end): Make non-const.
919         (Archive::count_members): Likewise.
920         * archive.h (class Archive): Update declarations.
921         * object.h (Object::read): Make non-const.
922         * Makefile.am (CCFILES): Add descriptors.cc.
923         (HFILES): Add descriptors.h.
924         * Makefile.in: Rebuild.
925
926         PR 6716
927         * gold.h: Always include <clocale>.  Add Solaris workarounds
928         following code in binutils/sysdep.h.
929
930         PR 6048
931         * ehframe.cc (Eh_frame::add_ehframe_input_section): Check whether
932         this->eh_frame_hdr_ is NULL before using it.
933
934         * dynobj.cc (Versions::Versions): Update comment.
935
936         * dynobj.cc (Versions::Versions): If there is an soname, use it as
937         the base version name.
938
939         * stringpool.cc (Stringpool_template::add_with_length): Set key to
940         array size plus one.
941         (Stringpool_template::set_string_offsets): Subtract one from key
942         before using it as an array index.
943         (Stringpool_template::get_offset_with_length): Likewise.
944         (Stringpool_template::write_to_buffer): Likewise.
945         * stringpool.h (Stringpool_template::get_offset_from_key):
946         Likewise.
947
948 2008-07-23  Ian Lance Taylor  <iant@google.com>
949
950         PR 6658
951         * object.h (Merged_symbol_value::value): Do our best to handle a
952         negative addend.
953
954         PR 6647
955         * script.cc (Version_script_info::get_versions): Don't add empty
956         version tag to return value.
957         (Version_script_info::get_symbol_version_helper): Change return
958         type to bool.  Add pversion parameter.  Change all callers.
959         (script_register_vers_node): Don't require a non-NULL tag.
960         * script.h (class Version_script_info): Update declarations.
961         (Version_script_info::get_symbol_version): Change return type to
962         bool.  Add version parameter.  Change all callers.
963         * symtab.cc (Sized_symbol::add_from_relobj): Rework version
964         handling.  Handle an empty version from a version script.
965         (Symbol_table::define_special_symbol): Likewise.
966         * testsuite/ver_test_10.script: New file.
967         * testsuite/ver_test_10.sh: New file.
968         * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_10.sh.
969         (check_DATA): Add ver_test_10.syms.
970         (ver_test_10.syms, ver_test_10.so): New target.
971         * testsuite/Makefile.in: Rebuild.
972
973 2008-07-23  Simon Baldwin  <simonb@google.com>
974
975         * symtab.cc (Symbol_table::sized_write_symbol): Only set st_size
976         to zero for undefined symbols from dynamic libraries.
977
978 2008-07-23  Ian Lance Taylor  <iant@google.com>
979
980         * symtab.cc (Symbol_table::resolve): Remove version parameter.
981         Change all callers.
982         * symtab.h (class Symbol_table): Update declaration.
983         * testsuite/ver_test_9.cc: New file.
984         * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_9.
985         (ver_test_9_SOURCES, ver_test_9_DEPENDENCIES): Define.
986         (ver_test_9_LDFLAGS, ver_test_9_LDADD): Define.
987         (ver_test_9.so, ver_test_9.o): New targets.
988         * testsuite/Makefile.in: Rebuild.
989
990 2008-07-22  Ian Lance Taylor  <iant@google.com>
991
992         * options.h (class General_options): Define --check-sections.
993         * layout.cc (Layout::set_segment_offsets): Handle
994         --check-sections.
995
996         * options.h (class General_options): Define -n/--nmagic and
997         -N/--omagic.
998         * options.cc (General_options::finalize): For -n/--nmagic or
999         -N/--omagic, set -static.
1000         * layout.cc (Layout::attach_allocated_section_to_segment): If
1001         -N/--omagic, don't put read-only and read-write sections in
1002         different segments.
1003         (Layout::find_first_load_seg): If -N/--omagic, don't insist on
1004         finding a read-only segment.
1005         (Layout::set_segment_offsets): If -N/--omagic or -n/--nmagic,
1006         don't set the minimum segment alignment to the common page size,
1007         and don't set the file offset to the address modulo the page size.
1008         * script-sections.cc (Script_sections::create_segments): If
1009         -n/--omagic, don't put read-only and read-write sections in
1010         different segments.
1011
1012         * cref.cc: New file.
1013         * cref.h: New file.
1014         * options.h (class General_options): Add --print-symbol-counts.
1015         * main.cc (main): Issue defined symbol report if requested.
1016         * archive.cc (Archive::interpret_header): Make into a const member
1017         function.
1018         (Archive::add_symbols): Call Input_objects::archive_start and
1019         archive_stop.
1020         (Archive::const_iterator): Define new class.
1021         (Archive::begin, Archive::end): New functions.
1022         (Archive::include_all_members): Rewrite to use iterator.
1023         (Archive::count_members): New function.
1024         * archive.h (class Archive): Update declarations.
1025         (Archive::filename): New function.
1026         * object.cc: Include "cref.h".
1027         (Sized_relobj::Sized_relobj): Initialize defined_count_.
1028         (Sized_relobj::do_get_global_symbol_counts): New function.
1029         (Input_objects::add_object): Add object to cross-referencer.
1030         (Input_objects::archive_start): New function.
1031         (Input_objects::archive_stop): New function.
1032         (Input_objects::print_symbol_counts): New function.
1033         * object.h: Declare Cref and Archive.
1034         (Object::get_global_symbol_counts): New function.
1035         (Object::do_get_global_symbol_counts): New pure virtual function.
1036         (class Sized_relobj): Add defined_count_ field.  Update
1037         declarations.
1038         (class Input_objects): Add cref_ field.  Update constructor.
1039         Update declarations.
1040         * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and
1041         defined_count_.
1042         (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing
1043         symbol counts.
1044         (Sized_dynobj::do_get_global_symbol_counts): New function.
1045         * dynobj.h (class Sized_dynobj): Add fields symbols_ and
1046         defined_count_.  Update declarations.  Define Symbols typedef.
1047         * symtab.cc (Symbol_table::add_from_relobj): Add defined
1048         parameter.  Change all callers.
1049         (Symbol_table::add_from_dynobj): Add sympointers and defined
1050         parameters.  Change all callers.
1051         * symtab.h (class Symbol_table): Update declarations.
1052         * Makefile.am (CCFILES): Add cref.cc.
1053         (HFILES): Add cref.h.
1054         * Makefile.in: Rebuild.
1055
1056 2008-07-22  Simon Baldwin  <simonb@google.com>
1057
1058         * symtab.cc (Symbol_table::sized_write_symbol): Set symbol size
1059         to zero when writing undefined symbols.
1060
1061 2008-07-22  Ian Lance Taylor  <iant@google.com>
1062
1063         * output.cc (Output_section::add_input_section): Don't try to
1064         merge empty merge sections.
1065
1066 2008-07-21  Craig Silverstein  <csilvers@google.com>
1067
1068         * symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
1069         Include symbol version in error message.
1070
1071 2008-07-20  Chris Demetriou  <cgd@google.com>
1072
1073         * configure.ac (gold_cv_c_random_seed): New configured variable.
1074         (RANDOM_SEED_CFLAGS): New substituted variable.
1075         * Makefile.am (AM_CFLAGS, AM_CXXFLAGS): Add $(RANDOM_SEED_CFLAGS).
1076         * configure: Rebuild.
1077         * Makefile.in: Likewise.
1078         * testsuite/Makefile.in: Likewise.
1079
1080 2008-07-18  Ian Lance Taylor  <iant@google.com>
1081
1082         * symtab.cc (Symbol_table::add_from_object): Rewrite the case
1083         where we see NAME/NULL and NAME/VERSION  as separate symbols.
1084         * testsuite/ver_test_main.cc (main): Call t4.
1085         (t4, t4_2a): Define.
1086         * testsuite/ver_test_2.cc (t4_2): Define.
1087         * testsuite/ver_test_2.script: Put t4_2a in VER2.
1088         * testsuite/ver_test_4.cc (t4_2a): Define.
1089         * testsuite/ver_test_4.script: Put t4_2a in VER2.
1090         * testsuite/ver_test.h (t4, t4_2, t4_2a): Declare.
1091
1092 2008-07-17  Ian Lance Taylor  <iant@google.com>
1093
1094         * dynobj.cc (Versions::add_def): If we give an error about a
1095         missing version, go ahead and create the version anyhow.
1096
1097 2008-07-10  Ian Lance Taylor  <iant@google.com>
1098
1099         Handle output sections with more than 0x7fffffff bytes.
1100         * object.h (class Relobj): Change map_to_output_ to
1101         output_sections_, and just keep a section pointer.  Change all
1102         uses.  Move comdat group support to Sized_relobj.
1103         (Relobj::is_section_specially_mapped): Remove.
1104         (Relobj::output_section): Remove poff parameter.  Change all
1105         callers.
1106         (Relobj::output_section_offset): New function.
1107         (Relobj::set_section_offset): Rewrite.
1108         (Relobj::map_to_output): Remove.
1109         (Relobj::output_sections): New function.
1110         (Relobj::do_output_section_offset): New pure virtual function.
1111         (Relobj::do_set_section_offset): Likewise.
1112         (class Sized_relobj): Add section_offsets_ field.  Add comdat
1113         group support from Relobj.  Update declarations.
1114         (Sized_relobj::get_output_section_offset): New function.
1115         (Sized_relobj::do_output_section_offset): New function.
1116         (Sized_relobj::do_set_section_offset): New function.
1117         * object.cc (Relobj::output_section_address): Remove.
1118         (Sized_relobj::Sized_relobj): Initialize new fields.
1119         (Sized_relobj::include_section_group): Cast find_kept_object to
1120         Sized_relobj.
1121         (Sized_relobj::include_linkonce_section): Likewise.
1122         (Sized_relobj::do_layout): Use separate arrays for output section
1123         and output offset.
1124         (Sized_relobj::do_count_local_symbols): Change map_to_output to
1125         output_sections.
1126         (Sized_relobj::do_finalize_local_symbols): Change map_to_output to
1127         output_sections and section_offsets.
1128         (Sized_relobj::write_local_symbols): Likewise.
1129         (map_to_kept_section): Compute output address directly.
1130         * reloc.cc (Sized_relobj::do_read_relocs): Change map_to_output to
1131         output_sections and section_offsets.
1132         (Sized_relobj::write_sections): Likewise.
1133         (Sized_relobj::relocate_sections): Likewise.
1134         * symtab.cc (sized_finalize_symbol): Use output_section_offset.
1135         * output.h (class Output_reloc): Update declarations.  Change
1136         u2_.relobj to Sized_relobj*.
1137         (class Output_data_reloc): Change add functions to use
1138         Sized_relobj*.
1139         * output.cc (Output_reloc::Output_reloc): Change relobj to
1140         Sized_relobj*.
1141         (Output_reloc::local_section_offset): Change return type to
1142         Elf_Addr.  Use get_output_section_offset.
1143         (Output_reloc::get_address): Likewise.
1144         (Output_section::is_input_address_mapped): Don't call
1145         is_section_specially_mapped.
1146         (Output_section::output_offset): Likewise.
1147         (Output_section::output_address): Likewise.
1148         (Output_section::starting_output_address): Likewise.
1149         * copy-relocs.cc (Copy_relocs::copy_reloc): Change object
1150         parameter to Sized_relobj*.
1151         (Copy_relocs::need_copy_reloc): Likewise.
1152         (Copy_relocs::save): Likewise.
1153         * copy-relocs.h (class Copy_relocs): Update declarations.
1154         (class Copy_relocs::Copy_reloc_entry): Change constructor to use
1155         Sized_relobj*.  Change relobj_ field to Sized_relobj*.
1156         * target-reloc.h (relocate_for_relocatable): Change
1157         offset_in_output_section type to Elf_Addr.  Change code that uses
1158         it as well.
1159         * layout.cc (Layout::layout): Always set *off.
1160         * mapfile.cc (Mapfile::print_input_section): Use
1161         output_section_offset.
1162         * i386.cc (Target_i386::copy_reloc): Change object parameter to
1163         Sized_relobj*.
1164         * powerpc.cc (Target_powerpc::copy_reloc): Likewise.
1165         * sparc.cc (Target_sparc::copy_reloc): Likewise.
1166         * x86_64.cc (Target_x86_64::copy_reloc): Likewise.
1167
1168 2008-07-03  Ian Lance Taylor  <iant@google.com>
1169
1170         * layout.cc (Layout::include_section): Do not discard unrecognized
1171         SHT_STRTAB sections.
1172
1173 2008-06-30  Craig Silverstein  <csilvers@cs.stanford.edu>
1174
1175         * script.cc (Lex::can_continue_name): Make '?' allowable in
1176         version-script names.
1177         * testsuite/version_script.map: Change glob pattern to use '?'
1178
1179 2008-06-30  Manish Singh  <yosh@gimp.org>
1180
1181         PR 6585
1182         * symtab.cc (Symbol_table::add_undefined_symbols_from_command_line):
1183         Correct typo.
1184
1185 2008-06-30  Ian Lance Taylor  <iant@google.com>
1186
1187         PR 6660
1188         PR 6682
1189         * powerpc.cc (Powerpc_relocate_functions::addr16_ha) [both
1190         versions]: Don't try to read the value in the contents, since we
1191         don't use it.  Use the template endianness when writing.
1192
1193 2008-06-25  Cary Coutant  <ccoutant@google.com>
1194
1195         * fileread.cc (File_read::make_view): Assert on zero-length view.
1196         * object.cc (Sized_relobj::do_read_symbols): Don't try to read
1197         symbol table when there are no symbols to read.
1198
1199 2008-06-23  Craig Silverstein  <csilvers@google.com>
1200
1201         * version.cc (version_string): Bump to 1.7
1202
1203 2008-06-18  Craig Silverstein  <csilvers@google.com>
1204
1205         * powerpc.cc (Powerpc_relocate_functions::addr16_ha): cast
1206         constant 0xFFFF to type Valtype.
1207         (Powerpc_relocate_functions::rel16_ha): Likewise.
1208
1209 2008-06-17  Ian Lance Taylor  <iant@google.com>
1210
1211         * output.h (Output_section::Input_section): Initialize p2align_ to
1212         zero for Output_section_data constructors.
1213         (Output_section::Input_section::addralign): If not an input
1214         section, return the alignment of the Output_section_data.
1215         * testsuite/copy_test.cc: New file.
1216         * testsuite/copy_test_1.cc: New file.
1217         * testsuite/copy_test_2.cc: New file.
1218         * testsuite/Makefile.am (check_PROGRAMS): Add copy_test.
1219         (copy_test_SOURCES, copy_test_DEPENDENCIES): New variables.
1220         (copy_test_LDFLAGS, copy_test_LDADD): New variables.
1221         (copy_test_1_pic.o, copy_test_1.so): New targets.
1222         (copy_test_2_pic.o, copy_test_2.so): New targets.
1223         * testsuite/Makefile.in: Rebuild.
1224
1225         * script-sections.cc (Script_sections::place_orphan): Initialize
1226         local variable exact.
1227
1228 2008-06-13  David Edelsohn  <edelsohn@gnu.org>
1229
1230         * powerpc.cc (Output_data_plt_powerpc::do_write): 8 + 4 = 0xC.
1231
1232 2008-06-12  David Edelsohn  <edelsohn@gnu.org>
1233             David S. Miller  <davem@davemloft.net>
1234
1235         * powerpc.cc: New file.
1236         * Makefile.am (TARGETSOURCES): Add powerpc.cc
1237         (ALL_TARGETOBJS): Add powerpc.$(OBJEXT)
1238         * configure.tgt: Add entries for powerpc-* and powerpc64-*.
1239         * Makefile.in: Rebuild.
1240
1241 2008-06-09  Ian Lance Taylor  <iant@google.com>
1242
1243         * testsuite/relro_test.cc: Include <cstdio>, <cstdlib>, and
1244         <exception>.
1245         (throwing, orig_terminate): New static variables.
1246         (terminate_handler): New static function.
1247         (t2): Set terminate handler.
1248
1249 2008-06-05  Kris Van Hees  <kris.van.hees@oracle.com>
1250
1251         PR 6584
1252         * binary.cc (Binary_to_elf::sized_convert): Fix .data
1253         alignment.
1254
1255 2008-05-30  Cary Coutant  <ccoutant@google.com>
1256
1257         * archive.cc (Archive::include_all_members) Correct to step
1258         over symbol table and extended name table in thin archives.
1259
1260 2008-05-29  Kris Van Hees  <kris.van.hees@oracle.com>
1261
1262         PR 6407
1263         * target-reloc.h (relocate_for_relocatable): Fix new_offset
1264         calculation.
1265
1266 2008-05-28  Caleb Howe  <cshowe@google.com>
1267
1268         * reduced_debug_output.cc: New file.
1269         * reduced_debug_output.h: New file.
1270         * options.h (class General_options): Add --strip-debug-non-line.
1271         * options.cc (General_options::finalize): Add strip_debug_non_line
1272         to the strip heirarchy.
1273         * layout.h (class Layout): Add debug_abbrev_ and debug_info_
1274         fields.
1275         * layout.cc: Include "reduced_debug_output.h".
1276         (Layout::Layout): Initialize new fields.
1277         (line_only_debug_sections): New static array.
1278         (is_lines_only_debug_sections): New static inline function.
1279         (Layout::include_section): Handle --strip-debug-non-line.
1280         (Layout::make_output_section): If --strip-debug-non-line, build
1281         new output sections for .debug_abbrev and .debug_info.
1282         * dwarf_reader.cc (read_unsigned_LEB_128): Move to namespace
1283         gold.  Warn about possible overflow.
1284         (read_signed_LEB_128): Likewise.
1285         * dwarf_reader.h: (read_unsigned_LEB_128): Declare.
1286         (read_signed_LEB_128): Declare.
1287         * Makefile.am (CCFILES): Add reduced_debug_output.cc.
1288         (HFILES): Add reduced_debug_output.h.
1289         * Makefile.in: Rebuild.
1290
1291 2008-05-21  Ian Lance Taylor  <iant@google.com>
1292
1293         * mapfile.cc: New file.
1294         * mapfile.h: New file.
1295         * options.h (class General_options): Add -M/--print-map and -Map.
1296         * options.cc (General_options::finalize): Make -M equivalent to
1297         -Map -.
1298         * main.cc: Include <cstdio> and "mapfile.h".
1299         (main): Open mapfile if requested.
1300         * gold.cc (class Middle_runner): Add mapfile_ field.  Update
1301         constructor.  Change caller.
1302         (queue_initial_tasks): Add mapfile parameter.  Change caller.
1303         (queue_middle_tasks): Likewise.
1304         * gold.h (queue_initial_tasks, queue_middle_tasks): Update
1305         declarations.
1306         * archive.cc: Include "mapfile.h".
1307         (Archive::add_symbols): Add mapfile parameter.  Change all
1308         callers.  Pass mapfile, symbol, and reason to include_member.
1309         (Archive::include_all_members): Add mapfile parameter.  Change all
1310         callers.
1311         (Archive::include_member): Add mapfile, sym, and why parameters.
1312         Change all callers.  Report inclusion to map file.
1313         * archive.h: Include "fileread.h".
1314         (class Archive): Update declarations.
1315         (Archive::file): New const method.
1316         (class Add_archive_symbols): Add mapfile_ field.  Update
1317         constructor.  Change all callers.
1318         * readsyms.h (class Read_symbols): Likewise.
1319         (class Finish_group): Likewise.
1320         (class Read_script): Likewise.
1321         * common.cc: Include "mapfile.h".
1322         (Symbol_table::allocate_commons): Add mapfile parameter.  Change
1323         all callers.
1324         (Symbol_table::do_allocate_commons): Likewise.
1325         (Symbol_table::do_allocate_commons_list): Likewise.  Report common
1326         symbol allocation to mapfile.
1327         * common.h (class Allocate_commons_task): Add mapfile_ field.
1328         Update constructor.  Change all callers.
1329         * symtab.h (class Symbol_table): Update declarations.
1330         * layout.cc: Include "mapfile.h".
1331         (Layout_task_runner::run): Print information to mapfile.
1332         (Layout::create_gold_note): Change Output_data_fixed_space to
1333         Output_data_zero_fill.
1334         (Layout::create_build_id): Likewise.
1335         (Layout::print_to_mapfile): New function.
1336         * layout.h (class Layout_task_runner): Add mapfile_ field.  Update
1337         constructor.  Change caller.
1338         (class Layout): Declare print_to_mapfile.
1339         * output.cc (Output_section::Input_section::print_to_mapfile): New
1340         function.
1341         (Output_section::add_input_section): If producing a map, always
1342         add to input_sections_ list.
1343         (Output_section::do_print_to_mapfile): New function.
1344         (Output_segment::print_sections_to_mapfile): New function.
1345         (Output_segment::print_section_list_to_mapfile): New function.
1346         * output.h: Include "mapfile.h".
1347         (Output_data::print_to_mapfile): New function.
1348         (Output_data::do_print_to_mapfile): New virtual function.
1349         (Output_segment_headers::do_print_to_mapfile): New function.
1350         (Output_file_header::do_print_to_mapfile): New function.
1351         (Output_data_const::do_print_to_mapfile): New function.
1352         (class Output_data_const_buffer): Add map_name_ field.  Update
1353         constructor.  Change all callers.  Add do_print_to_mapfile
1354         function.
1355         (class Output_data_fixed_space): Likewise.
1356         (class Output_data_space): Likewise.
1357         (class Output_data_zero_fill): New class.
1358         (Output_data_strtab::do_print_to_mapfile): New function.
1359         (Output_data_reloc_base::do_print_to_mapfile): New function.
1360         (Output_relocatable_relocs::do_print_to_mapfile): New function.
1361         (Output_data_group::do_print_to_mapfile): New function.
1362         (Output_data_got::do_print_to_mapfile): New function.
1363         (Output_data_dynamic::do_print_to_mapfile): New function.
1364         (Output_symtab_xindex::do_print_to_mapfile): New function.
1365         (class Output_section): Declare do_print_to_mapflie.  Declare
1366         print_to_mapfile in Input_section.
1367         (class Output_segment): Declare new functions.
1368         * object.h (Sized_relobj::symbol_count): New function.
1369         * script-sections.cc
1370         (Output_section_element_dot_assignment::set_section_addresses):
1371         Change Output_data_fixed_space to Output_data_zero_fill.
1372         (Output_data_expression::do_print_to_mapfile): New function.
1373         * script.cc (read_input_script): Add mapfile parameter.  Change
1374         all callers.
1375         * script.h (read_input_script): Update declaration.
1376         * ehframe.h (Eh_frame_hdr::do_print_to_mapfile): New function.
1377         (Eh_frame::do_print_to_mapfile): New function.
1378         * merge.h (Output_merge_data::do_print_to_mapfile): New function.
1379         (Output_merge_string::do_print_to_mapfile): New function.
1380         * i386.cc (Output_data_plt_i386::do_print_to_mapfile): New
1381         function.
1382         * sparc.cc (Output_data_plt_sparc::do_print_to_mapfile): New
1383         function.
1384         * x86_64.cc (Output_data_plt_x86_64::do_print_to_mapfile): New
1385         function.
1386         * Makefile.am (CCFILES): Add mapfile.cc.
1387         (HFILES): Add mapfile.h.
1388         * Makefile.in: Rebuild.
1389
1390 2008-05-19  Ian Lance Taylor  <iant@google.com>
1391
1392         * options.h (class General_options): Add -z relro.
1393         * layout.cc (Layout::Layout): Initialize relro_segment_.
1394         (Layout::add_output_section_data): Return the output section.
1395         (Layout::make_output_section): Rcognize relro sections and mark
1396         them appropriately.
1397         (Layout::attach_allocated_section_to_segment): Put relro sections
1398         in a PT_GNU_RELRO segment.
1399         (Layout::create_initial_dynamic_sections): Mark the .dynamic
1400         section as relro.
1401         (Layout::segment_precedes): Sort PT_GNU_RELRO segments after
1402         PT_TLS segments.
1403         (Layout::linkonce_mapping): Map d.rel.ro.local to
1404         .data.rel.ro.local.
1405         (Layout::output_section_name): Us .data.rel.ro.local for any
1406         section which begins with that.
1407         * layout.h (class Layout): Update add_output_section_data
1408         declaration.  Add relro_segment_ field.
1409         * output.cc (Output_section::Output_section): Initialize is_relro_
1410         and is_relro_local_ fields.
1411         (Output_segment::add_output_section): Group relro sections.
1412         (Output_segment::is_first_section_relro): New function.
1413         (Output_segment::maximum_alignment): If there is a relro section,
1414         align the segment to the common page size.
1415         (Output_segment::set_section_addresses): Track whether we are
1416         looking at relro sections.  If the last section is a relro
1417         section, align to the common page size.
1418         (Output_segment::set_section_list_addresses): Add in_relro
1419         parameter.  Change all callers.  Align to the page size when
1420         moving from relro to non-relro section.
1421         (Output_segment::set_offset): Align memsz of a PT_GNU_RELRO
1422         segment.
1423         * output.h (class Output_section): Add is_relro_ and
1424         is_relro_local_ fields.
1425         (Output_section::is_relro): New function.
1426         (Output_section::set_is_relro): New function.
1427         (Output_section::is_relro_local): New function.
1428         (Output_section::set_is_relro_local): New function.
1429         (class Output_segment): Update declarations.
1430         * i386.cc (Target_i386::got_section): Mark .got section as relro.
1431         * sparc.cc (Target_sparc::got_section): Likewise.
1432         * x86_64.cc (Target_x86_64::got_section): Likewise.
1433         * testsuite/relro_test_main.cc: New file.
1434         * testsuite/relro_test.cc: New file.
1435         * testsuite/Makefile.am (check_PROGRAMS): Add relro_test.
1436         (relro_test_SOURCES, relro_test_DEPENDENCIES): New variables.
1437         (relro_test_LDFLAGS, relro_test_LDADD): New variables.
1438         (relro_test.so, relro_test_pic.o): New targets.
1439         * testsuite/Makefile.in: Rebuild.
1440
1441 2008-05-16  Ian Lance Taylor  <iant@google.com>
1442
1443         * output.cc (Output_segment::add_output_section): Remove front
1444         parameter.
1445         * output.h (class Output_segment): Remove
1446         add_initial_output_section and overloaded add_output_section.
1447         Update declaration of remaining add_output_section.
1448         * layout.cc (Layout::create_interp): Call add_output_section
1449         rather than add_initial_output_section.
1450         (Layout::finish_dynamic_section): Likewise.
1451
1452         * i386.cc (Target_i386::Relocate::relocate_tls): Set dynamic type
1453         for TLS_GOTDESC and TLS_DESC_CALL.  Only optimize TLS_LDO_32 if we
1454         know the dynamic type.
1455         * x86_64.cc (Target_x86_64::Relocate): Add saw_tls_block_reloc_
1456         field.  Initialize it in constructor.
1457         (Target_x86_64::Relocate::relocate_tls): Record that we saw a TLS
1458         block reloc for TLSGD, GOTPC32_TLSDESC, TLSDESC_CALL, and TLSLD.
1459         Only optimize DTPOFF32 and DTPOFF64 if we have seen a TLS block
1460         reloc.
1461
1462         * output.cc (Output_reloc::get_address): Change return type to
1463         Elf_Addr.
1464         * output.h (class Output_reloc): Update get_address declaration.
1465         * x86_64.cc (Output_data_plt_x86_64::do_write): Use 64-bit types
1466         for section addresses.
1467
1468 2008-05-09  Ian Lance Taylor  <iant@google.com>
1469
1470         PR 6493
1471         * gold.cc (gold_nomem): Use return value of write.
1472
1473 2008-05-08  Ian Lance Taylor  <iant@google.com>
1474
1475         * symtab.c (Symbol::init_base_output_data): Add version
1476         parameter.  Change all callers.
1477         (Symbol::init_base_output_segment): Likewise.
1478         (Symbol::init_base_constant): Likewise.
1479         (Symbol::init_base_undefined): Likewise.
1480         (Sized_symbol::init_output_data): Likewise.
1481         (Sized_symbol::init_output_segment): Likewise.
1482         (Sized_symbol::init_constant): Likewise.
1483         (Sized_symbol::init_undefined): Likewise.
1484         (Symbol_table::do_define_in_output_data): If the new symbol has a
1485         version, mark it as the default.
1486         (Symbol_table::do_define_in_output_segment): Likewise.
1487         (Symbol_table::do_define_as_constant): Likewise.
1488         * symtab.h (class Symbol): Update declarations.
1489         (class Sized_symbol): Likewise.
1490         * resolve.cc (Symbol::override_version): New function.
1491         (Symbol::override_base): Call override_version.
1492         (Symbol::override_base_with_special): Likewise.
1493         * testsuite/ver_script_8.script: New file.
1494         * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_8.
1495         (ver_test_8_SOURCES, ver_test_8_DEPENDENCIES): Define.
1496         (ver_test_8_LDFLAGS, ver_test_8_LDADD): Define.
1497         (ver_test_8_1.so, ver_test_8_2.so): New targets.
1498
1499 2008-05-06  Ian Lance Taylor  <iant@google.com>
1500
1501         PR 6049
1502         * options.h (DEFINE_set): Add VARNAME_begin and VARNAME_end
1503         functions.
1504         (class General_options): Remove existing --undefined, and add
1505         --no-undefined instead.  Add new --undefined as synonym for -u.
1506         * archive.cc (Archive::add_symbols): Check whether symbol was
1507         named with -u.
1508         * gold.cc (queue_middle_tasks): Add -u symbols to symbol table.
1509         * symtab.h (class Symbol): Rename CONSTANT to IS_CONSTANT; change
1510         all uses.  Add IS_UNDEFINED.  Update declarations to split
1511         different versions of init_base.  Declare init_base_undefined.
1512         (Symbol::is_defined): Handle IS_UNDEFINED.
1513         (Symbol::is_undefined): Likewise.
1514         (Symbol::is_weak_undefined): Call is_undefined.
1515         (Symbol::is_absolute): Handle IS_CONSTANT.
1516         (class Sized_symbol): Update declarations to split different
1517         versions of init.  Declare init_undefined.
1518         (class Symbol_table): Declare new functions.
1519         * symtab.cc (Symbol::init_base_object): Rename from init_base.
1520         Change all callers.
1521         (Symbol::init_base_output_data): Likewise.
1522         (Symbol::init_base_output_segment): Likewise.
1523         (Symbol::init_base_constant): Likewise.
1524         (Symbol::init_base_undefined): New function.
1525         (Sized_symbol::init_object): Rename from init.  Change all
1526         callers.
1527         (Sized_symbol::init_output_data): Likewise.
1528         (Sized_symbol::init_output_segment): Likewise.
1529         (Sized_symbol::init_constant): Likewise.
1530         (Sized_symbol::init_undefined): New function.
1531         (Symbol_table::add_undefined_symbols_from_command_line): New
1532         function.
1533         (Symbol_table::do_add_undefined_symbols_from_command_line): New
1534         function.
1535         (Symbol::final_value_is_known): Handle IS_UNDEFINED.
1536         (Symbol::output_section): Likewise.
1537         (Symbol::set_output_section): Likewise.
1538         (Symbol_table::sized_finalize_symbol): Likewise.
1539         (Symbol_table::sized_write_globals): Likewise.
1540         * resolve.cc (Symbol_table::should_override): Likewise.
1541         (Symbol::override_base_with_special): Likewise.
1542
1543         * symtab.cc (Symbol_table::add_from_dynobj): If we see a protected
1544         symbol, change it to have default visibility.
1545         * testsuite/protected_1.cc: New file.
1546         * testsuite/protected_2.cc: New file.
1547         * testsuite/protected_3.cc: New file.
1548         * testsuite/protected_main_1.cc: New file.
1549         * testsuite/protected_main_2.cc: New file.
1550         * testsuite/protected_main_3.cc: New file.
1551         * testsuite/Makefile.am (check_PROGRAMS): Add protected_1.
1552         (protected_1_SOURCES, protected_1_DEPENDENCIES): Define.
1553         (protected_1_LDFLAGS, protected_1_LDADD): Define.
1554         (protected_1.so): New target.
1555         (protected_1_pic.o, protected_2_pic.o): New targets.
1556         (protected_3_pic.o): New target.
1557         (check_PROGRAMS): Add protected_2.
1558         (protected_2_SOURCES, protected_2_DEPENDENCIES): Define.
1559         (protected_2_LDFLAGS, protected_2_LDADD): Define.
1560         * testsuite/Makefile.in: Rebuild.
1561
1562         * options.h (DEFINE_var): Add set_user_set_##varname__.
1563         (DEFINE_bool_alias): New macro.
1564         (class General_options): Define -Bstatic using DEFINE_bool_alias
1565         rather than DEFINE_special.  Add --undefined as an alias for -z
1566         defs.
1567         * options.cc (General_options::parse_Bstatic): Remove.
1568
1569         * options.h (class General_options): Add --fatal-warnings.
1570         * main.cc (main): Implement --fatal-warnings.
1571         * errors.h (Errors::warning_count): New function.
1572
1573         * options.h (class General_options): Add -Bsymbolic-functions.
1574         * symtab.h (Symbol::is_preemptible): Check for
1575         -Bsymbolic-functions.
1576
1577 2008-05-05  Ian Lance Taylor  <iant@google.com>
1578
1579         * options.h (DEFINE_bool): For DASH_Z, create the negative option
1580         as noVARNAME rather than no-VARNAME.
1581         (class General_options): Add option -z combreloc.
1582         * output.h (class Output_reloc) [SHT_REL]: Declare compare and
1583         get_address.
1584         (Output_reloc::sort_before) [SHT_REL]: New function.
1585         (Output_reloc::sort_before) [SHT_RELA]: New function.
1586         (class Output_data_reloc_base): Add sort_relocs_ field.  Define
1587         Sort_relocs_comparison.
1588         (Output_data_reloc_base::Output_data_reloc_base): Add sort_relocs
1589         parameter.  Change all callers.
1590         (Output_data_reloc::Output_data_reloc) [both versions]: Add
1591         sort_relocs parameter.  Change all callers.
1592         * output.cc (Output_reloc::get_address): New function, broken out
1593         of write_rel.
1594         (Output_reloc::write_rel): Call it.
1595         (Output_reloc::compare): New function.
1596         (Output_data_reloc_base::do_write): Optionally sort relocs.
1597
1598         * configure.ac: If targ_extra_obj is set, link it in.
1599         * configure.tgt: Initialize all variables.
1600         (x86_64*): Set targ_extra_obj and targ_extra_size.
1601         * configure: Rebuild.
1602
1603         * object.cc (Sized_relobj::include_section_group): Adjust section
1604         indexes read from group data.  Build vector to pass to
1605         layout_group.
1606         * layout.cc (Layout::layout_group): Add flags and shndxes
1607         parameters.  Remove contents parameter.  Change caller.  Update
1608         explicit instantiations.
1609         * layout.h (class Layout): Update layout_group declaration.
1610         * output.cc (Output_data_group::Output_data_group): Add flags and
1611         input_shndxes parameters.  Remove contents parameter.  Change
1612         caller.
1613         (Output_data_group::do_write): Change input_sections_ to
1614         input_shndxes_.
1615         * output.h (class Output_data_group): Update constructor
1616         declaration.  Rename input_sections_ to input_shndxes_.
1617         * testsuite/many_sections_test.cc: Add template.
1618
1619 2008-04-30  Cary Coutant  <ccoutant@google.com>
1620
1621         * target-reloc.h (relocate_section): Fix dead-pointer bug.
1622
1623         * layout.cc (Layout::include_section): Refactored check for debug
1624         info section.
1625         (Layout::add_comdat): Add new parameters.  Change type
1626         of signature parameter.  Add object and shndx to signatures table.
1627         (Layout::find_kept_object): New function.
1628         * layout.h: Include <cstring>.
1629         (Layout::is_debug_info_section): New function.
1630         (Layout::add_comdat): Add new parameters.
1631         (Layout::find_kept_object): New function.
1632         (Layout::Kept_section): New struct.
1633         (Layout::Signatures): Change type of map range.
1634         * object.cc (Relobj::output_section_address): New function.
1635         (Sized_relobj::include_section_group): Add new parameters.  Change
1636         calls to Layout::add_comdat.  Change to build table of kept comdat
1637         groups and table mapping discarded sections to kept sections.
1638         (Sized_relobj::include_linkonce_section): Likewise.  Add new parameter.
1639         (Sized_relobj::do_layout): Change calls to include_section_group and
1640         include_linkonce_section.
1641         (Sized_relobj::do_finalize_local_symbols): Do not set local symbol
1642         value to zero when section is discarded.
1643         (Sized_relobj::map_to_kept_section): New function.
1644         * object.h (Relobj::output_section_address): New function.
1645         (Relobj::Comdat_group): New type.
1646         (Relobj::find_comdat_group): New function.
1647         (Relobj::Comdat_group_table): New type.
1648         (Relobj::Kept_comdat_section): New type.
1649         (Relobj::Kept_comdat_section_table): New type.
1650         (Relobj::add_comdat_group): New function.
1651         (Relobj::set_kept_comdat_section): New function.
1652         (Relobj::get_kept_comdat_section): New function.
1653         (Relobj::comdat_groups_): New field.
1654         (Relobj::kept_comdat_sections_): New field.
1655         (Symbol_value::input_value): Update comment.
1656         (Sized_relobj::map_to_kept_section) New function.
1657         (Sized_relobj::include_linkonce_section): Add new parameter.
1658         * target-reloc.h (Comdat_behavior): New type.
1659         (get_comdat_behavior): New function.
1660         (relocate_section): Add code to map a discarded section to the
1661         corresponding kept section when applying a relocation.
1662
1663 2008-04-30  Craig Silverstein  <csilvers@google.com>
1664
1665         * dwarf_reader.cc (next_generation_count): New static var.
1666         (Addr2line_cache_entry): New struct.
1667         (addr2line_cache): New static var.
1668         (Dwarf_line_info::one_addr2line): Added caching.
1669         (Dwarf_line_info::clear_addr2line_cache): New function.
1670         * dwarf_reader.h (Dwarf_line_info::one_addr2line): Add
1671         cache-size parameter.
1672         (Dwarf_line_info::one_addr2line_cache): New function.
1673         * symtab.cc (Symbol_table::detect_odr_violations): Pass
1674         new cache-size argument to one_addr2line(), and clear cache.
1675
1676 2008-04-28  Cary Coutant  <ccoutant@google.com>
1677
1678         * i386.cc (Relocate::relocate): Fix typos for R_386_PC16 and
1679         R_386_PC8 relocations.
1680
1681 2008-04-23  Ian Lance Taylor  <iant@google.com>
1682
1683         * object.cc (Sized_relobj::include_section_group): Check for
1684         invalid section group.
1685
1686         * object.cc (make_elf_object): Correct test for 64-bit ELF file
1687         header size.
1688
1689         * readsyms.cc (Read_symbols::do_read_symbols): Use get_view rather
1690         than read for file header.
1691         * archive.cc (Archive::include_member): Likewise.
1692
1693 2008-04-23  Paolo Bonzini  <bonzini@gnu.org>
1694
1695         * aclocal.m4: Regenerate.
1696         * configure: Regenerate.
1697
1698 2008-04-19  Ian Lance Taylor  <iant@google.com>
1699
1700         * version.cc (version_string): Bump to 1.6.
1701
1702         * testsuite/Makefile.am (many_sections_r_test): New target.
1703         (many_sections_r_test_SOURCES): Remove.
1704         (many_sections_r_test_DEPENDENCIES): Remove.
1705         (many_sections_r_test_LDFLAGS): Remove.
1706         (many_sections_r_test_LDADD): Remove.
1707
1708         * object.cc (Sized_relobj::do_add_symbols): Always pass
1709         local_symbol_count_ to add_from_relobj.
1710
1711         * testsuite/Makefile.am (many_sections_check.h): Only check one in
1712         every thousand variables.
1713         * testsuite/Makefile.in: Rebuild.
1714
1715         * object.cc (Xindex::initialize_symtab_xindex): New function.
1716         (Xindex::read_symtab_xindex): New function.
1717         (Xindex::sym_xindex_to_shndx): New function.
1718         (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if
1719         available.
1720         (Sized_relobj::do_initialize_xindex): New function.
1721         (Sized_relobj::do_read_symbols): Adjust section links.
1722         (Sized_relobj::symbol_section_and_value): Add is_ordinary
1723         parameter.  Change all callers.
1724         (Sized_relobj::include_section_group): Adjust section links and
1725         symbol section indexes.
1726         (Sized_relobj::do_layout): Adjust section links.
1727         (Sized_relobj::do_count_local_symbols): Adjust section links and
1728         symbol section indexes.
1729         (Sized_relobj::do_finalize_local_symbols): Distinguish between
1730         ordinary and special symbols.
1731         (Sized_relobj::write_local_symbols): Add symtab_xindex and
1732         dynsym_xindex parameters.  Change all callers.  Adjust section
1733         links.  Use SHN_XINDEX when needed.
1734         (Sized_relobj::get_symbol_location_info): Adjust section links.
1735         Don't get fooled by special symbols.
1736         * object.h (class Xindex): Define.
1737         (class Object): Add xindex_ parameter.  Declare virtual functoin
1738         do_initialize_xindex.
1739         (Object::adjust_sym_shndx): New function.
1740         (Object::set_xindex): New protected function.
1741         (class Symbol_value): Add is_ordinary_shndx_ field.
1742         (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_.
1743         (Symbol_value::value): Assert ordinary section.
1744         (Symbol_value::initialize_input_to_output_map): Likewise.
1745         (Symbol_value::set_input_shndx): Add is_ordinary parameter.
1746         Change all callers.
1747         (Symbol_value::input_shndx): Add is_ordinary parameter.  Change
1748         all callers.
1749         (class Sized_relobj): Update declarations.
1750         (Sized_relobj::local_symbol_input_shndx): Add is_ordinary
1751         parameter.  Change all callers.
1752         (Sized_relobj::adjust_shndx): New function.
1753         * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_
1754         field.
1755         (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx
1756         parameter.  Change all callers.  Pick up SHT_DYNSYM_SHNDX section
1757         for SHT_DYNSYM section if available.  Set dynsym_shndx_ field.
1758         (Sized_dynobj::read_dynsym_section): Adjust section links.
1759         (Sized_dynobj::read_dynamic): Likewise.
1760         (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field.  Adjust
1761         section links.
1762         (Sized_dynobj::do_initialize_xindex): New function.
1763         * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field.  Declare
1764         do_initialize_xindex.
1765         (Sized_dynobj::adjust_shndx): New function.
1766         * layout.cc (Layout::Layout): Initialize symtab_xindex_ and
1767         dynsym_xindex_ fields.
1768         (Layout::finalize): Add a call to set_section_indexes before
1769         creating the symtab sections.
1770         (Layout::set_section_indexes): Don't do anything if the section
1771         already has a section index.
1772         (Layout::create_symtab_sections): Add shnum parameter.  Change
1773         caller.  Create .symtab_shndx section if needed.
1774         (Layout::create_shdrs): Add shstrtab_section parameter.  Change
1775         caller.
1776         (Layout::allocated_output_section_count): New function.
1777         (Layout::create_dynamic_symtab): Create .dynsym_shndx section if
1778         needed.
1779         * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_
1780         fields.  Update declarations.
1781         (Layout::symtab_xindex): New function.
1782         (Layout::dynsym_xindex): New function.
1783         (class Write_symbols_task): Add layout_ field.
1784         (Write_symbols_task::Write_symbols_task): Add layout parameter.
1785         Change caller.
1786         * output.cc (Output_section_headers::Output_section_headers): Add
1787         shstrtab_section parameter.  Change all callers.
1788         (Output_section_headers::do_sized_write): Store overflow values
1789         for section count and section string table section index in
1790         section header zero.
1791         (Output_file_header::do_sized_write): Check for overflow of
1792         section count and section string table section index.
1793         (Output_symtab_xindex::do_write): New function.
1794         (Output_symtab_xindex::endian_do_write): New function.
1795         * output.h (class Output_section_headers): Add shstrtab_section_.
1796         Update declarations.
1797         (class Output_symtab_xindex): Define.
1798         (Output_section::has_out_shndx): New function.
1799         * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_
1800         field.
1801         (Symbol::init_base): Add st_shndx and is_ordinary parameters.
1802         Change all callers.
1803         (Sized_symbol::init): Likewise.
1804         (Symbol::output_section): Check for ordinary symbol.
1805         (Symbol_table::add_from_object): Remove orig_sym parameter.  Add
1806         st_shndx, is_ordinary, and orig_st_shndx parameters.  Change all
1807         callers.
1808         (Symbol_table::add_from_relobj): Add symndx_offset parameter.
1809         Change all callers.  Simplify handling of symbols from sections
1810         not included in the link.
1811         (Symbol_table::add_from_dynobj): Handle ordinary symbol
1812         distinction.
1813         (Weak_alias_sorter::operator()): Assert that symbols are
1814         ordinary.
1815         (Symbol_table::sized_finalize_symbol): Handle ordinary symbol
1816         distinction.
1817         (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex
1818         parameters.  Change all callers.
1819         (Symbol_table::sized_write_globals): Likewise.  Handle ordinary
1820         symbol distinction.  Use SHN_XINDEX when needed.
1821         (Symbol_table::write_section_symbol): Add symtab_xindex
1822         parameter.  Change all callers.
1823         (Symbol_table::sized_write_section_symbol): Likewise.  Use
1824         SHN_XINDEX when needed.
1825         * symtab.h (class Symbol): Add is_ordinary_shndx_ field.  Update
1826         declarations.
1827         (Symbol::shndx): Add is_ordinary parameter.  Change all callers.
1828         (Symbol::is_defined): Check is_ordinary.
1829         (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise.
1830         (Symbol::is_absolute, Symbol::is_common): Likewise.
1831         (class Sized_symbol): Update declarations.
1832         (class Symbol_table): Update declarations.
1833         * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary
1834         parameters.  Change all callers.
1835         (Sized_symbol::override): Likewise.
1836         (Symbol_table::override): Likewise.
1837         (symbol_to_bits): Add is_ordinary parameter.  Change all callers.
1838         (Symbol_table::resolve): Remove orig_sym parameter.  Add st_shndx,
1839         is_ordinary, and orig_st_shndx parameters.  Change all callers.
1840         * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol
1841         to be in an ordinary section.
1842         * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add
1843         object and is_ordinary parameters.  Change all callers.
1844         (Sized_dwarf_line_info::read_relocs): Add object parameter.
1845         Change all callers.  Don't add undefined or non-ordinary symbols
1846         to reloc_map_.
1847         (Sized_dwarf_line_info::read_line_mappings): Add object parameter.
1848         Change all callers.
1849         * dwarf_reader.h (class Sized_dwarf_line_info): Update
1850         declarations.
1851         * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol.
1852         * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links.
1853         (Sized_relobj::relocate_sections): Likewise.
1854         * target-reloc.h (scan_relocs): Adjust section symbol index.
1855         (scan_relocatable_relocs): Likewise.
1856         * i386.cc (Scan::local): Check for ordinary symbols.
1857         * sparc.cc (Scan::local): Likewise.
1858         * x86_64.cc (Scan::local): Likewise.
1859         * testsuite/binary_unittest.cc (Sized_binary_test): Update calls
1860         to symbol_section_and_value.
1861         * testsuite/many_sections_test.cc: New file.
1862         * testsuite/Makefile.am (BUILT_SOURCES): Define.
1863         (check_PROGRAMS): Add many_sections_test.
1864         (many_sections_test_SOURCES): Define.
1865         (many_sections_test_DEPENDENCIES): Define.
1866         (many_sections_test_LDFLAGS): Define.
1867         (BUILT_SOURCES): Add many_sections_define.h.
1868         (many_sections_define.h): New target.
1869         (BUILT_SOURCES): Add many_sections_check.h.
1870         (many_sections_check.h): New target.
1871         (check_PROGRAMS): Add many_sections_r_test.
1872         (many_sections_r_test_SOURCES): Define.
1873         (many_sections_r_test_DEPENDENCIES): Define.
1874         (many_sections_r_test_LDFLAGS): Define.
1875         (many_sections_r_test_LDADD): Define.
1876         (many_sections_r_test.o): New target.
1877         * testsuite/Makefile.in: Rebuild.
1878
1879 2008-04-17  Cary Coutant  <ccoutant@google.com>
1880
1881         * errors.cc (Errors::info): New function.
1882         (gold_info): New function.
1883         * errors.h (Errors::info): New function.
1884         * gold.h (gold_info): New function.
1885         * object.cc (Input_objects::add_object): Print trace output.
1886         * options.cc (options::parse_set): New function.
1887         (General_options::parse_wrap): Deleted.
1888         (General_options::General_options): Deleted initializer.
1889         * options.h (options::String_set): New typedef.
1890         (options::parse_set): New function.
1891         (DEFINE_set): New macro.
1892         (General_options::wrap): Changed to use DEFINE_set. Changed
1893         callers of any_wrap_symbols and is_wrap_symbol.
1894         (General_options::trace, General_options::trace_symbol):
1895         New options.
1896         (General_options::any_wrap_symbols, General_options::is_wrap_symbol)
1897         (General_options::wrap_symbols_): Deleted.
1898         * symtab.cc (Symbol_table::add_from_object): Print trace output.
1899
1900 2008-04-17  David S. Miller  <davem@davemloft.net>
1901
1902         * options.cc (General_options::parse_V): New function.
1903         * options.h: Add entries for -V and -Qy.
1904
1905 2008-04-17  Ian Lance Taylor  <iant@google.com>
1906
1907         * common.cc (Symbol_table::allocate_commons): Remove options
1908         parameter.  Change caller.
1909         (Symbol_table::do_allocate_commons): Remove options parameter.
1910         Change caller.  Just call do_allocate_commons_list twice.
1911         (Symbol_table::do_allocate_commons_list): New function, broken out
1912         of do_allocate_commons.
1913         * common.h (class Allocate_commons_task): Remove options_ field.
1914         Update constructor.
1915         * symtab.cc (Symbol_table::Symbol_table): Initialize
1916         tls_commons_.
1917         (Symbol_table::add_from_object): Put TLS common symbols on
1918         tls_commons_ list.
1919         (Symbol_table::sized_finalize_symbol): Handle STT_TLS symbols
1920         which are IN_OUTPUT_DATA.
1921         * symtab.h (class Symbol_table): Add tls_commons_ field.  Update
1922         allocate_commons and do_allocate_commons declarations.  Declare
1923         do_allocate_commons_list.
1924         * gold.cc (queue_middle_tasks): Update creation of
1925         Allocate_commons_task to not pass options.
1926         * testsuite/Makefile.am (INCLUDES): Add -I.. .
1927         (TLS_TEST_C_FLAGS): New variable.
1928         (tls_test_c_pic.o): New target.
1929         (tls_test_shared.so): Link in tls_test_c_pic.o.
1930         (tls_test_c_pic_ie.o): New target.
1931         (tls_test_ie_shared.so): Link in tls_test_c_pic_ie.o.
1932         (tls_test_DEPENDENCIES, tls_test_LDADD): Add tls_test_c.o.
1933         (tls_test_c.o): New target.
1934         (tls_pic_test_DEPENDENCIES): Add tls_test_c_pic.o.
1935         (tls_pic_test_LDADD): Likewise.
1936         (tls_shared_gd_to_ie_test_DEPENDENCIES): Add tls_test_c_pic.o.
1937         (tls_shared_gd_to_ie_test_LDADD): Likewise.
1938         (tls_test_c_gnu2.o): New target.
1939         (tls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): Add
1940         tls_test_c_gnu2.o.
1941         (tls_shared_gnu2_gd_to_ie_test_LDADD): Likewise.
1942         (tls_test_gnu2_shared.so): Link in tls_test_c_gnu2.o.
1943         (tls_test_shared_nonpic.so): Link in tls_test_c.o.
1944         * testsuite/tls_test.cc: Include "config.h".
1945         (t_last): Call t11_last.
1946         * testsuite/tls_test.h (t11, t11_last): Declare.
1947         * testsuite/tls_test_c.c: New file.
1948         * testsuite/tls_test_main.cc (thread_routine): Call t11.
1949         * configure.ac: Check for OpenMP support.
1950         * configure, config.in, Makefile.in: Rebuild.
1951         * testsuite/Makefile.in: Rebuild.
1952
1953 2008-04-16  Cary Coutant  <ccoutant@google.com>
1954
1955         * i386.cc (Target_i386::define_tls_base_symbol): New function.
1956         (Target_i386::tls_base_symbol_defined_): New field.
1957         (Target_i386::Scan::local): Define _TLS_MODULE_BASE_ symbol.
1958         (Target_i386::Scan::global): Likewise.
1959         * symtab.cc (sized_finalize_symbol): Add check for TLS symbol.
1960         * x86_64.cc (Target_x86_64::define_tls_base_symbol): New function.
1961         (Target_x86_64::tls_base_symbol_defined_): New field.
1962         (Target_x86_64::Scan::local): Define _TLS_MODULE_BASE_ symbol.
1963         (Target_x86_64::Scan::global): Likewise.
1964
1965 2008-04-16  Cary Coutant  <ccoutant@google.com>
1966
1967         * symtab.h (Symbol::is_strong_undefined): Removed unused function.
1968         (Symbol::needs_plt_entry): Allow weak undefined symbols.
1969         (Symbol::needs_dynamic_reloc): Allow weak undefined symbols when
1970         building shared libraries.
1971         * testsuite/Makefile.am (weak_undef_nonpic_test): New target.
1972         (weak_undef_file1_nonpic.o, weak_undef_file2_nonpic.o)
1973         (weak_undef_lib_nonpic.so, alt/weak_undef_lib_nonpic.so): New targets.
1974         * testsuite/Makefile.in: Rebuild.
1975         * testsuite/weak_undef.h: New file.
1976         * testsuite/weak_undef_file1.cc: Add extra test cases.
1977         * testsuite/weak_undef_file2.cc: Likewise.
1978         * testsuite/weak_undef_test.cc: Likewise.
1979
1980 2008-04-16  David S. Miller  <davem@davemloft.net>
1981
1982         * sparc.cc (Target_sparc::Scan): Change from struct to class.
1983         Add issued_non_pic_error_ field.  Declare check_non_pic.
1984         (Target_sparc::Scan::check_non_pic): New function.
1985         (Target_sparc::Scan::local): Call check_non_pic as appropriate.
1986         (Target_sparc::Scan::global): Likewise.
1987
1988         * configure.ac (FN_PTRS_IN_SO_WITHOUT_PIC): Add sparc64.
1989         * configure: Rebuild.
1990
1991         * options.h (DEFINE_enable): New macro.
1992         (new_dtags): New enable option.
1993         (initfirst, interpose, loadfltr, nodefaultlib,
1994         nodelete, nodlopen, nodump): New -z options.
1995         * layout.cc (Layout:finish_dynamic_section): If new
1996         dtags enabled, emit DT_RUNPATH.  Also, emit a
1997         DT_FLAGS_1 containing any specified -z flags.
1998
1999 2008-04-16  Ian Lance Taylor  <iant@google.com>
2000
2001         * copy-relocs.cc: New file.
2002         * copy-relocs.h: New file.
2003         * reloc.cc: Remove Copy_relocs code.
2004         * reloc.h: Likewise.
2005         * reloc-types.h (struct Reloc_types) [both versions]: Add
2006         get_reloc_addend_noerror.
2007         * output.h (class Output_data_reloc<elfcpp::SHT_REL>): Add
2008         variants of add_global which take an addend which must be zero.
2009         * i386.cc: Include "copy-relocs.h".
2010         (class Target_i386): Change type of copy_relocs_ to variable,
2011         update initializer.
2012         (Target_i386::copy_reloc): Rewrite to pass to Copy_relocs class.
2013         Change all callers.
2014         (Target_i386::do_finalize_sections): Change handling of
2015         copy_relocs_.
2016         * sparc.cc: Include "copy-relocs.h".
2017         (class Target_sparc): Change type of copy_relocs_ to variable,
2018         update initializer.
2019         (Target_sparc::copy_reloc): Rewrite to pass to Copy_relocs class.
2020         Change all callers.
2021         (Target_sparc::do_finalize_sections): Change handling of
2022         copy_relocs_.
2023         * x86_64.cc: Include "copy-relocs.h".
2024         (class Target_x86_64): Change type of copy_relocs_ to variable,
2025         update initializer.
2026         (Target_x86_64::copy_reloc): Rewrite to pass to Copy_relocs
2027         class.  Change all callers.
2028         (Target_x86_64::do_finalize_sections): Change handling of
2029         copy_relocs_.
2030         * Makefile.am (CCFILES): Add copy-relocs.cc.
2031         (HFILES): Add copy-relocs.h.
2032
2033         * Makefile.in, aclocal.m4, testsuite/Makefile.in: Rebuild.
2034
2035         * testsuite/script_test_4.sh: Permit leading zeroes.
2036
2037 2008-04-15  Ian Lance Taylor  <iant@google.com>
2038
2039         * script-sections.cc (Script_sections::create_segments): Use
2040         header_size_adjustment even when there is enough room for the
2041         headers.
2042         * testsuite/script_test_4.sh: New file.
2043         * testsuite/script_test_4.t: New file.
2044         * testsuite/Makefile.am (check_SCRIPTS): Add script_test_4.sh.
2045         (check_DATA): Add script_test_4.stdout.
2046         (MOSTLYCLEANFILES): Likewise.
2047         (script_test_4): New target.
2048         (script_test_4.stdout): New target.
2049         * testsuite/Makefile.in: Rebuild.
2050
2051         * sparc.cc: Add definitions for Output_data_plt_sparc class
2052         constants.
2053
2054 2008-04-14  David S. Miller  <davem@davemloft.net>
2055
2056         * sparc.cc: New file.
2057         * Makefile.am (TARGETSOURCES): Add sparc.cc
2058         (ALL_TARGETOBJS): Add sparc.$(OBJEXT)
2059         * configure.tgt: Document targ_extra_size and
2060         targ_extra_big_endian.  Add entries for sparc-* and
2061         sparc64-*.
2062         * configure.ac: Handle targ_extra_size and
2063         targ_extra_big_endian.
2064         * Makefile.in: Rebuild.
2065         * configure: Likewise.
2066         * po/POTFILES.in: Likewise.
2067         * po/gold.pot: Likewise.
2068
2069 2008-04-14  Ian Lance Taylor  <iant@google.com>
2070
2071         * layout.cc (Layout::Layout): Initialize sections_are_attached_.
2072         (Layout::get_output_section): Ignore SHF_WRITE and SHF_EXECINSTR
2073         in the name/type/flags to section mapping.  Don't call
2074         allocate_output_section.
2075         (Layout::choose_output_section): Change parameter from adjust_name
2076         to is_input_section.  Don't permit input sections after sections
2077         are attached to segments.  Don't call allocate_output_section.
2078         (Layout::layout_eh_frame): Call update_flags_for_input_section,
2079         not write_enable_output_section.
2080         (Layout::make_output_section): Don't push to
2081         unattached_section_list_ nor call attach_to_segment.  Call
2082         attach_section_to_segment if sections are attached.
2083         (Layout::attach_sections_to_segments): New function.
2084         (Layout::attach_section_to_segment): New function.
2085         (Layout::attach_allocated_section_to_segment): Rename from
2086         attach_to_segment.  Remove flags parameter.
2087         (Layout::allocate_output_section): Remove function.
2088         (Layout::write_enable_output_section): Remove function.
2089         * layout.h (class Layout): Update for above changes.  Add new
2090         field sections_are_attached_.
2091         * output.h (Output_section::update_flags_for_input_section): New
2092         function.
2093         * output.cc (Output_section::add_input_section): Call
2094         update_flags_for_input_section.
2095         * gold.cc (queue_middle_tasks): Call attach_sections_to_segments.
2096
2097 2008-04-11  Cary Coutant  <ccoutant@google.com>
2098
2099         * i386.cc (Target_i386::got_mod_index_entry): Restore code previously
2100         thought unnecessary.
2101         * x86_64.cc (Target_x86_64::got_mod_index_entry): Likewise.
2102
2103 2008-04-11  Ian Lance Taylor  <iant@google.com>
2104
2105         * output.h (class Output_section_data): Remove inline definition
2106         of set_addralign.
2107         * output.cc (Output_section_data::set_addralign): New function.
2108
2109 2008-04-11  Cary Coutant  <ccoutant@google.com>
2110
2111         Add support for TLS descriptors for i386 and x86_64.
2112         * i386.cc (Target_i386::Relocate::tls_desc_gd_to_ie): New function.
2113         (Target_i386::Relocate::tls_desc_gd_to_le): New function.
2114         (Target_i386::Got_type): Add GOT_TYPE_TLS_NOFFSET and
2115         GOT_TYPE_TLS_DESC.
2116         (Target_i386::got_mod_index_entry): Remove unnecessary code.
2117         (Target_i386::Scan::local): Implement R_386_TLS_GOTDESC and
2118         R_386_TLS_DESC_CALL relocations.  Fix problem with initial-exec
2119         relocations.
2120         (Target_i386::Scan::global): Fix problem with GD-to-IE relaxation.
2121         Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations;
2122         Fix problem with initial-exec relocations.
2123         (Target_i386::Relocate::relocate_tls): Likewise.
2124         (Target_i386::Relocate::tls_gd_to_ie): Fix problem with GD-to-IE
2125         relaxation.
2126         * output.cc (Output_data_dynamic::Dynamic_entry::write): Add
2127         support for section-plus-offset dynamic table entries.
2128         * output.h (Output_data_dynamic::add_section_plus_offset): New function.
2129         (Output_data_dynamic::Dynamic_entry): Add support for
2130         section-plus-offset dynamic table entries.
2131         (Output_data_dynamic::Classification): Likewise.
2132         (Output_data_dynamic::classification_): Renamed offset_.
2133         * x86_64.cc (Target_x86_64::Relocate::tls_desc_gd_to_ie): New function.
2134         (Target_x86_64::Relocate::tls_desc_gd_to_le): New function.
2135         (Target_x86_64::make_plt_section): New function.
2136         (Target_x86_64::reserve_tlsdesc_entries): New function.
2137         (Output_data_plt_x86_64::Output_data_plt_x86_64): Add new parameter.
2138         (Output_data_plt_x86_64::reserve_tlsdesc_entry): New function.
2139         (Output_data_plt_x86_64::has_tlsdesc_entry): New function.
2140         (Output_data_plt_x86_64::get_tlsdesc_got_offset): New function.
2141         (Output_data_plt_x86_64::get_tlsdesc_plt_offset): New function.
2142         (Output_data_plt_x86_64::tlsdesc_plt_entry): New field.
2143         (Output_data_plt_x86_64::set_final_data_size): Move out of line;
2144         add extra PLT entry for TLS descriptors.
2145         (Output_data_plt_x86_64::got_): New field.
2146         (Output_data_plt_x86_64::tlsdesc_got_offset_): New field.
2147         (Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize new
2148         fields.
2149         (Output_data_plt_x86_64::do_write): Write extra PLT entry for TLS
2150         descriptors.
2151         (Target_x86_64::make_plt_entry): Factor out make_plt_section.
2152         (Target_x86_64::got_mod_index_entry): Remove unnecessary code.
2153         (Target_x86_64::Scan::local): Implement R_386_TLS_GOTDESC and
2154         R_386_TLS_DESC_CALL relocations.
2155         (Target_x86_64::Scan::global): Likewise.
2156         (Target_x86_64::do_finalize_sections): Add dynamic table entries
2157         for TLS descriptors.
2158         (Relocate::relocate_tls): Fix problem with GD-to-IE relaxation.
2159         Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations.
2160         (Target_x86_64::Relocate::tls_gd_to_ie): Fix problem with
2161         GD-to-IE relaxation.
2162         * configure.ac: Export new conditional variables TLS_GNU2_DIALECT
2163         and TLS_DESCRIPTORS.
2164         * Makefile.in: Rebuild.
2165         * configure: Rebuild.
2166         * testsuite/Makefile.am (tls_shared_gd_to_ie_test): New target.
2167         (tls_test_shared2.so): New target.
2168         (tls_shared_gd_to_ie_test_SOURCES): New variable.
2169         (tls_shared_gd_to_ie_test_DEPENDENCIES): New variable.
2170         (tls_shared_gd_to_ie_test_LDFLAGS): New variable.
2171         (tls_shared_gd_to_ie_test_LDADD): New variable.
2172         (tls_shared_gnu2_gd_to_ie_test): New target.
2173         (tls_test_gnu2.o, tls_test_file2_gnu2.o, tls_test_gnu2_shared2.so):
2174         New targets.
2175         (tls_shared_gnu2_gd_to_ie_test_SOURCES): New variable.
2176         (ls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): New variable.
2177         (tls_shared_gnu2_gd_to_ie_test_LDFLAGS): New variable.
2178         (tls_shared_gnu2_gd_to_ie_test_LDADD): New variable.
2179         (tls_shared_gnu2_test): New target.
2180         (tls_test_gnu2_shared.so): New target.
2181         (tls_shared_gnu2_test_SOURCES): New variable.
2182         (tls_shared_gnu2_test_DEPENDENCIES): New variable.
2183         (tls_shared_gnu2_test_LDFLAGS): New variable.
2184         (tls_shared_gnu2_test_LDADD): New variable.
2185         * testsuite/Makefile.in: Rebuild.
2186         * testsuite/Makefile.
2187
2188 2008-04-11  Ian Lance Taylor  <iant@google.com>
2189
2190         * testsuite/Makefile.am (justsyms_2r.o): Add dependency on
2191         justsyms.t.
2192         * testsuite/Makefile.in: Rebuild.
2193
2194         * testsuite/script_test_2a.cc (script_test_string_a): Make 8 bytes
2195         long.
2196         * testsuite/script_test_2.cc (main): Adjust test.
2197
2198 2008-04-11  David S. Miller  <davem@davemloft.net>
2199             Ian Lance Taylor  <iant@google.com>
2200
2201         * options.h (General_options): Add entries for '-Y' and
2202         '-relax'.
2203         * options.cc (General_options:finalize): If -Y was used, add those
2204         entries to the library path instead of the default "/lib" and
2205         "/usr/lib".
2206
2207 2008-04-11  David S. Miller  <davem@davemloft.net>
2208
2209         * testsuite/justsyms.t: Start at 0x100.
2210         * testsuite/justsyms_1.cc: Adjust justsyms_string assertion.
2211         * testsuite/script_test_2b.cc (script_test_string_b): Make 8 bytes
2212         long.
2213         * testsuite/script_test_2.cc: Adjust string and section length
2214         checks.
2215
2216 2008-04-09  Ian Lance Taylor  <iant@google.com>
2217
2218         PR gold/5996
2219         * script-sections.cc (Sections_element::allocate_to_segment): Add
2220         orphan parameter.
2221         (Output_section_definition::allocate_to_segment): Likewise.
2222         (Orphan_output_section::allocate_to_segment): Likewise.
2223         (Script_sections::attach_sections_using_phdrs_clause): Don't
2224         propagate non-PT_LOAD segments to orphan sections.
2225         * testsuite/Makefile.am (script_test_3.stdout): Generate using
2226         readelf rather than objdump.
2227         * testsuite/script_test_3.sh: Adjust accordingly.  Test that
2228         .interp section and PT_INTERP segment are the same size.
2229         * testsuite/Makefile.in: Rebuild.
2230
2231         * symtab.cc (Symbol_table::add_from_dynobj): Only look for weak
2232         aliases for symbols defined in the same object.
2233         * testsuite/Makefile.am (check_PROGRAMS): Add weak_alias_test.
2234         (weak_alias_test_SOURCES): New variable.
2235         (weak_alias_test_DEPENDENCIES): New variable.
2236         (weak_alias_test_LDFLAGS): New variable.
2237         (weak_alias_test_LDADD): New variable.
2238         (weak_alias_test_1_pic.o, weak_alias_test_1.so): New targets.
2239         (weak_alias_test_2_pic.o, weak_alias_test_2.so): New targets.
2240         (weak_alias_test_3.o): New target.
2241         (weak_alias_test_4_pic.o, weak_alias_test_4.so): New targets.
2242         * testsuite/weak_alias_test_main.cc: New file.
2243         * testsuite/weak_alias_test_1.cc: New file.
2244         * testsuite/weak_alias_test_2.cc: New file.
2245         * testsuite/weak_alias_test_3.cc: New file.
2246
2247 2008-04-08  Ian Lance Taylor  <iant@google.com>
2248
2249         * options.h (class General_options): Add --noinhibit-exec option.
2250         * main.cc (main): Check --noinhibit-exec.
2251
2252         * options.h (class General_options): Define --wrap as a special
2253         option.  Add wrap_symbols_ field.
2254         (General_options::any_wrap_symbols): New function.
2255         (General_options::is_wrap_symbol): New function.
2256         * options.cc (General_options::parse_wrap): New function.
2257         (General_options::General_options): Initialize wrap_symbols_.
2258         * symtab.cc (Symbol_table::wrap_symbol): New function.
2259         (Symbol_table::add_from_object): Handle --wrap.
2260         * symtab.h (class Symbol_table): Declare wrap_symbol.
2261         * target.h (Target::wrap_char): New function.
2262         (Target::Target_info): Add wrap_char field.
2263         * i386.cc (Target_i386::i386_info): Initialize wrap_char.
2264         * x86_64.cc (Target_x86_64::x86_64_info): Likewise.
2265         * testsuite/testfile.cc (Target_test::test_target_info):
2266         Likewise.
2267
2268         * errors.cc (Errors::undefined_symbol): Mention symbol version if
2269         there is one.
2270
2271         * layout.h (class Layout): Add added_eh_frame_data_ field.
2272         * layout.cc (Layout::Layout): Initialize new field.
2273         (Layout::layout_eh_frame): Don't add eh_frame_data_ to .eh_frame
2274         output section until we find a section we merged successfully.
2275         * object.cc (Sized_relobj::check_eh_frame_flags): Don't require
2276         that the size be non-zero.
2277
2278         * merge.cc (Object_merge_map::get_output_offset): Remove inline
2279         qualifier.
2280
2281 2008-04-08  Craig Silverstein  <csilvers@google.com>
2282
2283         * configure.ac: Export new conditional variable HAVE_ZLIB.
2284         * testsuite/Makefile.am (flagstest_o_specialfile): Condition
2285         on HAVE_ZLIB.
2286         (flagstest_o_specialfile_and_compress_debug_sections): Likewise.
2287         * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
2288
2289 2008-04-07  Ian Lance Taylor  <iant@google.com>
2290
2291         * version.cc (version_string): Set to "1.5".
2292
2293         * x86_64.cc (Target_x86_64::Scan): Change from struct to class.
2294         Add issued_non_pic_error_ field.  Declare check_non_pic.
2295         (Target_x86_64::Scan::check_non_pic): New function.
2296         (Target_x86_64::Scan::local): Call check_non_pic as appropriate.
2297         (Target_x86_64::Scan::global): Likewise.
2298
2299         * output.cc (Output_reloc<SHT_REL>::local_section_offset): Add
2300         addend parameter.  Change caller.  Handle merge sections.
2301         (Output_reloc<SHT_REL>::symbol_value): Change parameter type from
2302         Address to Addend.  Don't add in the result of
2303         local_section_offset, pass down the addend and use the returned
2304         value.
2305         * output.h (class Output_reloc<SHT_REL>): Add Addend typedef.
2306         Update declarations of local_section_offset and symbol_value.
2307         * testsuite/two_file_test_1.cc (t18): New function.
2308         * testsuite/two_file_test_2.cc (f18): New function.
2309         * testsuite/two_file_test_main.cc (main): Call t18.
2310         * testsuite/two_file_test.h (t18, f18): Declare.
2311
2312         * configure.ac: Don't test for objdump, c++filt, or readelf.
2313         * testsuite/Makefile.am: Remove READELF and OBJDUMP_AND_CPPFILT
2314         conditionals.
2315         (TEST_READELF): New variable.
2316         (TEST_OBJDUMP, TEST_CXXFILT, TEST_STRIP): New variables.
2317         (check_PROGRAMS): Add two_file_strip_test.
2318         (two_file_strip_test): New target.
2319         (check_PROGRAMS): Add two_file_same_shared_strip_test.
2320         (two_file_same_shared_strip_test_SOURCES): New variable.
2321         (two_file_same_shared_strip_test_DEPENDENCIES): New variable.
2322         (two_file_same_shared_strip_test_LDFLAGS): New variable.
2323         (two_file_same_shared_strip_test_LDADD): New variable.
2324         (two_file_shared_strip.so): New target.
2325         (ver_test_2.syms, ver_test_4.syms): Use TEST_READELF.
2326         (ver_test_5.syms, ver_test_7.syms): Likewise.
2327         (ver_matching_test.stdout): Use TEST_OBJDUMP and TEST_CXXFILT.
2328         (strip_test_3.stdout): Use TEST_OBJDUMP.
2329         * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
2330
2331 2008-04-04  Cary Coutant  <ccoutant@google.com>
2332
2333         * symtab.h (Symbol::is_weak_undefined): New function.
2334         (Symbol::is_strong_undefined): New function.
2335         (Symbol::is_absolute): New function.
2336         (Symbol::needs_plt_entry): Exclude weak undefined symbols.
2337         (Symbol::needs_dynamic_reloc): Exclude weak undefined and
2338         absolute symbols.
2339         * testsuite/Makefile.am (check_PROGRAMS): Add weak_undef_test.
2340         (weak_undef_test): New target.
2341         * testsuite/Makefile.in: Rebuild.
2342         * testsuite/weak_undef_file1.cc: New file.
2343         * testsuite/weak_undef_file2.cc: New file.
2344         * testsuite/weak_undef_test.cc: New file.
2345
2346 2008-04-03  Craig Silverstein  <csilvers@google.com>
2347
2348         * compressed_output.h (class Output_compressed_section): Use
2349         unsigned buffer.
2350         * compressed_output.cc (zlib_compress): Use unsigned buffers,
2351         add zlib header.
2352         (zlib_compressed_suffix): Removed.
2353         (Output_compressed_section::set_final_data_size): Use unsigned
2354         buffers.
2355         * testsuite/Makefile.am (flagstest_compress_debug_sections):
2356         Fix linker invocation.
2357         (flagstest_o_specialfile_and_compress_debug_sections):
2358         Likewise.
2359         * testsuite/Makefile.in: Regenerated.
2360
2361 2008-04-02  David S. Miller  <davem@davemloft.net>
2362
2363         *  dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog,
2364         Sized_dwarf_line_info::process_one_opcode): Use Swap_unaligned.
2365
2366 2008-04-02  Craig Silverstein  <csilvers@google.com>
2367
2368         * TODO: New file.
2369
2370 2008-04-02  Ian Lance Taylor  <iant@google.com>
2371
2372         * fileread.cc (File_read::find_view): Add byteshift and vshifted
2373         parameters.  Update for new key type to views_.  Change all
2374         callers.
2375         (File_read::read): Adjust for byteshift in returned view.
2376         (File_read::add_view): New function, broken out of
2377         find_and_make_view.
2378         (File_read::make_view): New function, broken out of
2379         find_and_make_view.
2380         (File_read::find_or_make_view): Add offset and aligned
2381         parameters.  Rewrite accordingly.  Change all callers.
2382         (File_read::get_view): Add offset and aligned parameters.  Adjust
2383         for byteshift in return value.
2384         (File_read::get_lasting_view): Likewise.
2385         * fileread.h (class File_read): Update declarations.
2386         (class File_read::View): Add byteshift_ field.  Add byteshift to
2387         constructor.  Add byteshift method.
2388         * archive.h (Archive::clear_uncached_views): New function.
2389         (Archive::get_view): Add aligned parameter.  Change all callers.
2390         * object.h (Object::get_view): Add aligned parameter.  Change all
2391         callers.
2392         (Object::get_lasting_view): Likewise.
2393
2394         * fileread.cc (File_read::release): Don't call clear_views if
2395         there are multiple objects.
2396         * fileread.h (File_read::clear_uncached_views): New function.
2397         * archive.cc (Add_archive_symbols::run): Call clear_uncached_views
2398         on the archive.
2399
2400 2008-03-31  Cary Coutant  <ccoutant@google.com>
2401
2402         Add thin archive support.
2403         * archive.cc (Archive::armagt): New const.
2404         (Archive::setup): Remove task parameter and calls to unlock.
2405         (Archive::unlock_nested_archives): New function.
2406         (Archive::read_header): Add nested_off parameter. Change
2407         all callers.
2408         (Archive::interpret_header): Likewise.
2409         (Archive::include_all_members): Change to handle thin
2410         archives.
2411         (Archive::include_member): Likewise.
2412         * archive.h (Archive::Archive): Add new parameters and
2413         initializers.
2414         (Archive::armagt): New const.
2415         (Archive::setup): Remove task parameter.
2416         (Archive::unlock_nested_archives): New function.
2417         (Archive::read_header): Add nested_off parameter.
2418         (Archive::interpret_header): Likewise.
2419         (Archive::Nested_archive_table): New typedef.
2420         (Archive::is_thin_archive_): New field.
2421         (Archive::nested_archives_): New field.
2422         (Archive::options_): New field.
2423         (Archive::dirpath_): New field.
2424         (Archive::task_): New field.
2425         * readsyms.cc (Read_symbols::do_read_symbols): Add check
2426         for thin archives.  Pass additional parameters to
2427         Archive::Archive.  Unlock the archive file after calling
2428         Archive::setup.
2429
2430 2008-03-29  Ian Lance Taylor  <iant@google.com>
2431
2432         * symtab.cc (Symbol_table::do_define_as_constant): Don't force a
2433         version symbol to be local.
2434         * testsuite/ver_test_4.sh: New file.
2435         * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_4.sh.
2436         (check_DATA): Add ver_test_4.syms.
2437         (ver_test_4.syms): New target.
2438         * testsuite/Makefile.in: Rebuild.
2439
2440         * output.cc
2441         (Output_section::Input_section_sort_entry::has_priority): New
2442         function.
2443         (Output_section::Input_section_sort_entry::match_file_name): New
2444         function.
2445         (Output_section::Input_section_sort_entry::match_section_name):
2446         Remove.
2447         (Output_section::Input_section_sort_entry::match_section_name_prefix):
2448         Remove.
2449         (Output_section::Input_section_sort_entry::match_section_file):
2450         Remove.
2451         (Output_section::Input_section_sort_compare::operator()): Rewrite
2452         using new Input_section_sort_entry functions.  Sort crtbegin and
2453         crtend first.  Sort sections with no priority before sections with
2454         a priority.
2455         * testsuite/initpri1.c (d3): Check j != 4.
2456         (cd5): New constructor/destructor function.
2457         (main): Check j != 2.
2458
2459         * symtab.cc (Symbol_table::add_from_object): If we don't use the
2460         new symbol when resolving, don't call set_is_default.
2461         * testsuite/ver_test_7.cc: New file.
2462         * testsuite/ver_test_7.sh: New file.
2463         * testsuite/Makefile.am (ver_test_7.so): New target.
2464         (ver_test_7.o): New target.
2465         (check_SCRIPTS): Add ver_test_7.sh.
2466         (check_DATA): Add ver_test_7.syms.
2467         (ver_test_7.syms): New target.
2468
2469 2008-03-28  Ian Lance Taylor  <iant@google.com>
2470
2471         * layout.cc (Layout::layout): If we see an input section with a
2472         name that needs sorting, set the must_sort flag for the output
2473         section.
2474         (Layout::make_output_section): If the name of the output section
2475         indicates that it might require sorting, set the may_sort flag.
2476         * output.h (Output_section::may_sort_attached_input_sections): New
2477         function.
2478         (Output_section::set_may_sort_attached_input_sections): New
2479         function.
2480         (Output_section::must_sort_attached_input_sections): New
2481         function.
2482         (Output_section::set_must_sort_attached_input_sections): New
2483         function.
2484         (class Output_section): Declare Input_section_sort_entry.  Define
2485         Input_section_sort_compare.  Declare
2486         sort_attached_input_sections.  Add new fields:
2487         may_sort_attached_input_sections_,
2488         must_sort_attached_input_sections_,
2489         attached_input_sections_are_sorted_.
2490         * output.cc (Output_section::Output_section): Initialize new
2491         fields.
2492         (Output_section::add_input_section): Add an entry to
2493         input_sections_ if may_sort or must_sort are true.
2494         (Output_section::set_final_data_size): Call
2495         sort_attached_input_sections if necessary.
2496         (Output_section::Input_section_sort_entry): Define new class.
2497         (Output_section::Input_section_sort_compare::operator()): New
2498         function.
2499         (Output_section::sort_attached_input_sections): New function.
2500         * configure.ac: Check whether the compiler supports constructor
2501         priorities.  Define a CONSTRUCTOR_PRIORITY automake conditional.
2502         * testsuite/initpri1.c: New file.
2503         * testsuite/Makefile.am (check_PROGRAMS): Add initpri1 if
2504         CONSTRUCTOR_PRIORITY.
2505         (initpri1_SOURCES, initpri1_DEPENDENCIES): New variables.
2506         (initpri1_LDFLAGS): New variable.
2507         * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
2508
2509 2008-03-27  Ian Lance Taylor  <iant@google.com>
2510
2511         * common.cc (Sort_commons::operator): Correct sorting algorithm.
2512         * testsuite/common_test_1.c: New file.
2513         * testsuite/Makefile.am (check_PROGRAMS): Add common_test_1.
2514         (common_test_1_SOURCES): New variable.
2515         (common_test_1_DEPENDENCIES): New variable.
2516         (common_test_1_LDFLAGS): New variable.
2517
2518         * symtab.cc (Symbol_table::add_from_object): Handle saw_undefined_
2519         and commons_ correctly when NAME/VERSION does not override
2520         NAME/NULL.
2521         * testsuite/ver_test_6.c: New file.
2522         * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_6
2523         (ver_test_6_SOURCES, ver_test_6_DEPENDENCIES): New variables.
2524         (ver_test_6_LDFLAGS, ver_test_6_LDADD): New variables.
2525
2526 2008-03-26  Ian Lance Taylor  <iant@google.com>
2527
2528         * symtab.cc (Symbol_table::add_from_relobj): Don't set the version
2529         of an undefined symbol from a version script.
2530         * testsuite/Makefile.am (ver_test_5.so): New target.
2531         (ver_test_5.o): New target.
2532         (check_SCRIPTS): Add ver_test_5.sh.
2533         (check_DATA): Add ver_test_5.syms.
2534         (ver_test_5.syms): New target.
2535         * testsuite/ver_test_5.cc: New file.
2536         * testsuite/ver_test_5.script: New file.
2537         * testsuite/ver_test_5.sh: New file.
2538         * Makefile.in, testsuite/Makefile.in: Rebuild.
2539
2540         PR gold/5986
2541         Fix problems building gold with gcc 4.3.0.
2542         * gold.h (TEMPLATE_ATTRIBUTE_PRINTF_4): Define.
2543         (gold_error_at_location, gold_warning_at_location): Use it.
2544         * configure.ac: Check whether we can compile and use a template
2545         function with a printf attribute.
2546         * x86_64.cc (Target_x86_64::do_code_fill): Swap out a 32-bit value
2547         when jumping over bytes.
2548         * object.cc: Instantiate Object::read_section_data.
2549         * debug.h: Include <cstring>
2550         * dwarf_reader.cc: Include <algorithm>
2551         * main.cc: Include <cstring>.
2552         * options.cc: Include <cstring>.
2553         * output.cc: Include <cstring>.
2554         * script.cc: Include <cstring>.
2555         * script.h: Include <string>.
2556         * symtab.cc: Include <cstring> and <algorithm>.
2557         * target-select.cc: Include <cstring>.
2558         * version.cc: Include <string>.
2559         * testsuite/testmain.cc: Include <cstdlib>.
2560         * configure, config.in: Rebuild.
2561
2562 2008-03-25  Ian Lance Taylor  <iant@google.com>
2563
2564         * options.cc: Include "../bfd/bfdver.h".
2565         (options::help): Print bug reporting address.
2566
2567         * version.cc (print_version): Adjust output for current value of
2568         BFD_VERSION_STRING.
2569
2570         * NEWS: New file.
2571
2572         * options.cc (options::help): Print list of supported targets.
2573         * target-select.h: Include <vector>.
2574         (class Target_selector): Make machine_, size_, and is_big_endian_
2575         fields const.  Add bfd_name_ and instantiated_target_ fields.
2576         (Target_selector::Target_selector): Add bfd_name parameter.
2577         (Target_selector::recognize): Make non-virtual, call
2578         do_recognize.
2579         (Target_selector::recognize_by_name): Make non-virtual, call
2580         do_recognize_by_name.
2581         (Target_selector::supported_names): New function.
2582         (Target_selector::bfd_name): New function.
2583         (Target_selector::do_instantiate_target): New pure virtual
2584         function.
2585         (Target_selector::do_recognize): New virtual function.
2586         (Target_selector::do_recognize_by_name): New virtual function.
2587         (Target_selector::instantiate_target): New private function.
2588         (supported_target_names): Declare.
2589         * target-select.cc (Target_selector::Target_selector): Update for
2590         new parameter and fields.
2591         (select_target_by_name): Check that the name matches before
2592         calling recognize_by_name.
2593         (supported_target_names): New function.
2594         * i386.cc (class Target_selector_i386): Update Target_selector
2595         constructor call.  Remove recognize and recognize_by_name.  Add
2596         do_instantiate_target.
2597         * x86_64.cc (class Target_selector_x86_64): Likewise.
2598         * testsuite/testfile.cc (class Target_selector_test): Update for
2599         changes to Target_selector.
2600
2601         * README: Rewrite, with some notes on unsupported features.
2602
2603 2008-03-24  Cary Coutant  <ccoutant@google.com>
2604
2605         * i386.cc (Target_i386::Got_type): New enum declaration.
2606         (Target_i386::Scan::local): Updated callers of Output_data_got
2607         member functions.
2608         (Target_i386::Scan::global): Likewise.
2609         (Target_i386::Relocate::relocate): Likewise.
2610         (Target_i386::Relocate::relocate_tls): Likewise.
2611         * object.h (Got_offset_list): New class.
2612         (Sized_relobj::local_has_got_offset): Added got_type parameter.
2613         (Sized_relobj::local_got_offset): Likewise.
2614         (Sized_relobj::set_local_got_offset): Likewise.
2615         (Sized_relobj::local_has_tls_got_offset): Removed.
2616         (Sized_relobj::local_tls_got_offset): Removed.
2617         (Sized_relobj::set_local_tls_got_offset): Removed.
2618         (Sized_relobj::Local_got_offsets): Changed to store a list of offsets.
2619         * output.cc (Output_data_got::add_global): Added got_type parameter.
2620         (Output_data_got::add_global_with_rel): Likewise.
2621         (Output_data_got::add_global_with_rela): Likewise.
2622         (Output_data_got::add_global_pair_with_rel): New function.
2623         (Output_data_got::add_global_pair_with_rela): New function.
2624         (Output_data_got::add_local): Added got_type parameter.
2625         (Output_data_got::add_local_with_rel): Likewise.
2626         (Output_data_got::add_local_with_rela): Likewise.
2627         (Output_data_got::add_local_pair_with_rel): New function.
2628         (Output_data_got::add_local_pair_with_rela): New function.
2629         (Output_data_got::add_global_tls): Removed.
2630         (Output_data_got::add_global_tls_with_rel): Removed.
2631         (Output_data_got::add_global_tls_with_rela): Removed.
2632         (Output_data_got::add_local_tls): Removed.
2633         (Output_data_got::add_local_tls_with_rel): Removed.
2634         (Output_data_got::add_local_tls_with_rela): Removed.
2635         * output.h (Output_data_got::add_global): Added got_type parameter.
2636         (Output_data_got::add_global_with_rel): Likewise.
2637         (Output_data_got::add_global_with_rela): Likewise.
2638         (Output_data_got::add_global_pair_with_rel): New function.
2639         (Output_data_got::add_global_pair_with_rela): New function.
2640         (Output_data_got::add_local): Added got_type parameter.
2641         (Output_data_got::add_local_with_rel): Likewise.
2642         (Output_data_got::add_local_with_rela): Likewise.
2643         (Output_data_got::add_local_pair_with_rel): New function.
2644         (Output_data_got::add_local_pair_with_rela): New function.
2645         (Output_data_got::add_global_tls): Removed.
2646         (Output_data_got::add_global_tls_with_rel): Removed.
2647         (Output_data_got::add_global_tls_with_rela): Removed.
2648         (Output_data_got::add_local_tls): Removed.
2649         (Output_data_got::add_local_tls_with_rel): Removed.
2650         (Output_data_got::add_local_tls_with_rela): Removed.
2651         * resolve.cc (Symbol::override_base_with_special): Removed
2652         reference to has_got_offset_ field.
2653         * symtab.cc (Symbol::init_fields): Replaced initialization
2654         of got_offset_ with got_offsets_.  Removed initialization
2655         of has_got_offset_
2656         * symtab.h (Symbol::has_got_offset): Aded got_type parameter.
2657         (Symbol::got_offset): Likewise.
2658         (Symbol::set_got_offset): Likewise.
2659         (Symbol::has_tls_got_offset): Removed.
2660         (Symbol::tls_got_offset): Removed.
2661         (Symbol::set_tls_got_offset): Removed.
2662         (Symbol::got_offset_): Removed.
2663         (Symbol::tls_mod_got_offset_): Removed.
2664         (Symbol::tls_pair_got_offset_): Removed.
2665         (Symbol::got_offsets_): New field.
2666         (Symbol::has_got_offset): Removed.
2667         (Symbol::has_tls_mod_got_offset): Removed.
2668         (Symbol::has_tls_pair_got_offset): Removed.
2669         * x86_64.cc (Target_x86_64::Got_type): New enum declaration.
2670         (Target_x86_64::Scan::local): Updated callers of Output_data_got
2671         member functions.
2672         (Target_x86_64::Scan::global): Likewise.
2673         (Target_x86_64::Relocate::relocate): Likewise.
2674         (Target_x86_64::Relocate::relocate_tls): Likewise.
2675
2676 2008-03-25  Ben Elliston  <bje@au.ibm.com>
2677
2678         * yyscript.y: Fix spelling error in comment.
2679
2680 2008-03-24  Ian Lance Taylor  <iant@google.com>
2681
2682         * options.h (class General_options): Define build_id option.
2683         * layout.h (class Layout): Declare write_build_id, create_note,
2684         create_build_id.  Add build_id_note_ member.
2685         * layout.cc: Include <cerrno>, <fcntl.h>, <unistd.h>,
2686         "libiberty.h", "md5.h", "sha1.h".
2687         (Layout::Layout): Initialize eh_frame_data_,
2688         eh_frame_hdr_section_, and build_id_note_.
2689         (Layout::finalize): Call create_build_id.
2690         (Layout::create_note): New function, broken out of
2691         Layout::create_gold_note.
2692         (Layout::create_gold_note): Call create_note.
2693         (Layout::create_build_id): New function.
2694         (Layout::write_build_id): New function.
2695         (Close_task_runner::run): Call write_build_id.
2696
2697         * x86_64.cc: Correct license to GPLv3.
2698
2699 2008-03-23  Ian Lance Taylor  <iant@google.com>
2700
2701         * options.cc: Include "demangle.h".
2702         (parse_optional_string): New function.
2703         (parse_long_option): Handle takes_optional_argument.
2704         (parse_short_option): Update dash_z initializer.  Handle
2705         takes_optional_argument.
2706         (General_options::General_options): Initialize do_demangle_.
2707         (General_options::finalize): Set do_demangle_.  Handle demangling
2708         style.
2709         * options.h (parse_optional_string): Declare.
2710         (struct One_option): Add optional_arg field.  Update constructor.
2711         Update call constructor calls.  Add takes_optional_argument
2712         function.
2713         (DEFINE_var): Add optional_arg__ parameter.  Change all callers.
2714         (DEFINE_optional_string): Define.
2715         (General_options::demangle): Change from DEFINE_bool to
2716         DEFINE_optional_string.
2717         (General_options::no_demangle): New function.
2718         (General_options::do_demangle): New function.
2719         (General_options::set_do_demangle): New function.
2720         (General_options::execstack_status_): Move definition to end of
2721         class definition.
2722         (General_options::static_): Likewise.
2723         (General_options::do_demangle_): New field.
2724         * object.cc (big_endian>::get_symbol_location_info): Call
2725         Options::do_demangle, not Options::demangle.
2726         * symtab.cc (demangle): Likewise.
2727
2728 2008-03-22  Ian Lance Taylor  <iant@google.com>
2729
2730         * gold.h: Include <cstddef> and <sys/types.h>
2731         * options.h: Include <cstring>.
2732
2733 2008-03-21  Ian Lance Taylor  <iant@google.com>
2734
2735         * Added source code to GNU binutils.