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