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