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