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