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