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