OSDN Git Service

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