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