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