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