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