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