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