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