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