3 * script.cc (Lazy_demangler): New class.
4 (Version_script_info::get_symbol_version_helper): Demangle a
9 * i386.cc (Target_i386::Relocate::relocate): Recognize non-PIC calls
11 * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
15 * version.cc (version_string): Bump to 1.9.
17 * gold.h: Include <cstring> and <stdint.h>.
18 * version.cc: Include <cstdio>.
19 * object.cc (Sized_relobj::do_layout): Initialize gc_sd to avoid a
21 * reduced_debug_output.cc (insert_into_vector): Rename from
22 Insert_into_vector; change all callers. Use Swap_unaligned to
23 avoid aliasing issue; remove union since it is unnecessary.
27 * Makefile.am (CCFILES): Add gc.cc.
29 * Makefile.in: Regenerate.
30 * gold.cc (Gc_runner): New class.
31 (queue_initial_tasks): Call garbage collection related tasks
32 when corresponding options are invoked.
33 (queue_middle_gc_tasks): New function.
34 (queue_middle_tasks): Reorder tasks to allow relocs to be read and
35 processed early before laying out sections during garbage collection.
36 * gold.h (queue_middle_gc_tasks): New function.
37 (is_prefix_of): Move from "layout.cc".
38 * i386.cc (Target_i386::gc_process_relocs): New function.
39 * layout.cc (is_prefix_of): Remove. Move to "gold.h"
40 * main.cc (main): Create object of class "Garbage_collection".
41 * object.cc (Relobj::copy_symbols_data): New function.
42 (Relobj::is_section_name_included): New function.
43 (Sized_relobj::do_layout): Allow this function to be called twice
44 during garbage collection and defer layout of section during the
46 * object.h (Relobj::get_symbols_data): New function.
47 (Relobj::is_section_name_included): New function.
48 (Relobj::copy_symbols_data): New function.
49 (Relobj::set_symbols_data): New function.
50 (Relobj::get_relocs_data): New function.
51 (Relobj::set_relocs_data): New function.
52 (Relobj::is_output_section_offset_invalid): New pure virtual function.
53 (Relobj::gc_process_relocs): New function.
54 (Relobj::do_gc_process_relocs): New pure virtual function.
55 (Relobj::sd_): New data member.
56 (Sized_relobj::is_output_section_offset_invalid): New function.
57 (Sized_relobj::do_gc_process_relocs): New function.
58 * options.h (General_options::gc_sections): Modify to not be a no-op.
59 (General_options::print_gc_sections): New option.
60 * plugin.cc (Plugin_finish::run): Remove function call to
61 Plugin_manager::layout_deferred_objects. Move it to "gold.cc".
62 * powerpc.cc (Target_powerpc::gc_process_relocs): New function.
63 * reloc.cc (Read_relocs::run): Add task to process relocs and
64 determine unreferenced sections when doing garbage collection.
65 (Gc_process_relocs): New class.
66 (Sized_relobj::do_gc_process_relocs): New function.
67 (Sized_relobj::do_scan_relocs): Don't try to scan the relocs for
68 sections that are garbage collected.
69 * reloc.h (Gc_process_relocs): New class.
70 * sparc.cc (Target_sparc::gc_process_relocs): New function.
71 * symtab.cc (Symbol::should_add_dynsym_entry): Do not add entries for
72 symbols whose corresponding sections are garbage collected.
73 (Symbol_table::Symbol_table): Add new parameter for the garbage
75 (Symbol_table::gc_mark_undef_symbols): New function.
76 (Symbol_table::gc_mark_symbol_for_shlib): New function.
77 (Symbol_table::gc_mark_dyn_syms): New function.
78 (Symbol_table::resolve): Do not treat symbols seen in dynamic objects
80 (Symbol_table::add_from_object): Likewise.
81 (Symbol_table::add_from_relobj): When building shared objects, do not
82 treat externally visible symbols as garbage.
83 (Symbol_table::sized_finalize_symbol): Do not check dynamic symbol
84 table information for static and relocatable links.
85 * symtab.h (Symbol_table::set_gc): New function.
86 (Symbol_table::gc): New function.
87 (Symbol_table::gc_mark_undef_symbols): New function.
88 (Symbol_table::gc_mark_symbol_for_shlib): New function.
89 (Symbol_table::gc_mark_dyn_syms): New function.
90 (Symbol_table::gc_): New data member.
91 * target.h (Sized_target::gc_process_relocs): New pure virtual
93 * x86_64.cc (Target_x86_64::gc_process_relocs): New function.
94 * testsuite/testfile.cc (Target_test::gc_process_relocs): New function.
98 * options.h (General_options::gc_sections): Define as a no-op for now.
99 (General_options::no_keep_memory): Ditto.
100 (General_options::Bshareable): Define.
101 * options.cc (General_options::finalize): Honor -Bshareable.
105 * powerpc.cc (Powerpc_relocate_functions::rel16_ha): Don't try to
106 read the value in the contents, since we don't use it. Use the
107 template endianness when writing.
108 (Relocate::relocate): Use it for R_PPC_REL16_HA.
112 * configure.tgt (powerpc64-*): Fix targ_obj.
116 * object.cc (Sized_relobj::write_local_symbols): Don't write out
117 local symbols when stripping all symbols.
121 * output.cc (Output_reloc): Add explicit instantiations.
125 * archive.cc (Archive::get_elf_object_for_member): Remove call
126 to File_read::claim_for_plugin.
127 * descriptors.cc (Descriptors::open): Remove reference to
129 (Descriptors::claim_for_plugin): Remove.
130 * descriptors.h (Descriptors::claim_for_plugin): Remove.
131 (Descriptors::is_claimed): Remove.
132 (claim_descriptor_for_plugin): Remove.
133 * fileread.cc (File_read::claim_for_plugin): Remove.
134 * fileread.h (File_read::claim_for_plugin): Remove.
135 (File_read::descriptor): Reopen descriptor if necessary.
136 * plugin.cc (Plugin::load): Add two new APIs to transfer vector.
137 (Plugin_manager::all_symbols_read): Add task parameter. Change
139 (Plugin_manager::get_input_file): New function.
140 (Plugin_manager::release_input_file): New function.
141 (Pluginobj::Pluginobj): Add filesize parameter and initialize
142 corresponding data member.
143 (Sized_pluginobj::Sized_pluginobj): Add filesize parameter
144 and pass to base constructor. Change all callers.
145 (get_input_file, release_input_file): New functions.
146 (make_sized_plugin_object): Add filesize parameter. Change all callers.
147 * plugin.h (Plugin_manager::Plugin_manager): Initialize task_ member.
148 (Plugin_manager::all_symbols_read): Add task parameter.
149 (Plugin_manager::get_input_file): New function.
150 (Plugin_manager::release_input_file): New function.
151 (Plugin_manager::task_): New data member.
152 (Pluginobj::Pluginobj): Add filesize parameter.
153 (Pluginobj::filename): New function.
154 (Pluginobj::descriptor): New function.
155 (Pluginobj::filesize): New function.
156 (Pluginobj::filesize_): New data member.
157 (Sized_pluginobj::Sized_pluginobj): Add filesize parameter.
158 * readsyms.cc (Read_symbols::do_read_symbols): Remove call to
159 File_read::claim_for_plugin; use Object::unlock to unlock the file.
161 * testsuite/Makefile.am (plugin_test_4): New test case for plugins
162 with archive libraries.
163 * testsuite/Makefile.in: Regenerate.
164 * testsuite/plugin_test.c (struct sym_info): New type.
165 (get_input_file, release_input_file): New static variables.
166 (onload): Capture new transfer vector entries.
167 (claim_file_hook): Stop reading at end of file according to filesize.
168 Factor out parsing of readelf output into separate function.
169 (all_symbols_read_hook): Exercise get_input_file and release_input_file
170 APIs and get the source file name from the symbol table. Convert
171 source file name to corresponding object file name. Print info
172 message when adding new input files.
173 (parse_readelf_line): New function.
174 * testsuite/plugin_test_1.sh: Add checks for new info messages.
175 * testsuite/plugin_test_2.sh: Likewise.
176 * testsuite/plugin_test_3.sh: Likewise.
177 * testsuite/plugin_test_4.sh: New test case.
181 * version.cc (version_string): Bump to 1.8.
185 * gold.cc (gold_exit): Call plugin cleanup handlers on exit.
186 * plugin.cc (Plugin_manager::finish): Rename as
187 layout_deferred_objects. Move cleanup to separate function.
188 (Plugin_manager::cleanup): New function.
189 (Plugin_finish::run): Call layout_deferred_objects and cleanup
191 * plugin.h (Plugin_manager::finish): Rename as
192 layout_deferred_objects.
193 (Plugin_manager::cleanup): New function.
194 (Plugin_manager::cleanup_done): New field.
198 * plugin.cc (is_visible_from_outside): New function.
199 (Pluginobj::get_symbol_resolution_info): Call is_visible_from_outside
200 so we don't return "IR only" status for exported symbols or -r links.
202 * testsuite/Makefile.am (plugin_test_3): New test case.
203 * testsuite/Makefile.in: Regenerate.
204 * testsuite/plugin_test_3.sh: New file.
208 * object.cc (Sized_relobj::layout_section): New function.
209 (Sized_relobj::do_layout): Defer layout of input sections until after
210 plugin has provided replacement files.
211 (Sized_relobj::do_layout_deferred_sections): New function.
212 * object.h (Relobj::set_section_offset): Remove virtual keyword.
213 (Relobj::layout_deferred_sections): New function.
214 (Relobj::do_layout_deferred_sections): New function.
215 (Sized_relobj::do_layout_deferred_sections): New function.
216 (Sized_relobj::layout_section): New function.
217 (Sized_relobj::Deferred_layout): New structure.
218 (Sized_relobj::deferred_layout_): New field.
219 * plugin.cc (Plugin_manager::finish): Renamed, was cleanup.
220 Change all callers. Layout deferred sections.
221 (class Plugin_finish): Renamed, was Plugin_cleanup. Change all
223 (Plugin_hook::run): Move code from do_plugin_hook inline.
224 (Plugin_hook::do_plugin_hook): Remove.
225 * plugin.h (Plugin_manager::Plugin_manager): Add missing initializers.
226 (Plugin_manager::finish): Renamed, was cleanup.
227 (Plugin_manager::should_defer_layout): New function.
228 (Plugin_manager::add_deferred_layout_object): New function.
229 (Plugin_manager::Deferred_layout_list): New type.
230 (Plugin_manager::deferred_layout_objects_): New field.
231 (Plugin_hook::do_plugin_hook): Remove.
235 * options.h (class General_options): Add --no case for
240 * plugin.cc (Plugin::load): Move LDPT_MESSAGE to front of transfer
242 (Plugin_manager::claim_file): Create plugin object even if
243 plugin did not call the add_symbols callback.
244 (Plugin_obj::get_symbol_resolution_info): Guard against plugin
245 asking for more symbols than were added.
246 * testsuite/Makefile.am (plugin_test_1): Add test case with
248 (empty.syms): New target.
249 * testsuite/Makefile.in: Regenerate.
250 * testsuite/plugin_test.c (claim_file_hook): Add new debug
251 message. Don't call add_symbols if no globals.
252 (all_symbols_read_hook): Don't provide replacement for empty
257 * target-reloc.h (Default_scan_relocatable_relocs): Only discard
258 r_type == 0 for a local symbol with r_sym == 0.
259 (scan_relocatable_relocs): Pass r_sym to
260 local_non_section_strategy.
261 * reloc.cc (Emit_relocs_strategy::local_non_section_strategy): Add
264 * configure.ac: Update test for TLS descriptors: they are
265 supported as of glibc 2.9.
266 * configure: Rebuild.
271 * target-reloc.h (Default_scan_relocatable_relocs): For each
272 function, map r_type == 0 to RELOC_DISCARD.
276 * layout.cc (Layout::add_comdat): Allow COMDAT group from a replacement
277 object to override a kept COMDAT group from a plugin object.
282 * yyscript.y (file_cmd): Handle INPUT.
284 * testsuite/initpri1.c: Change all declarations to be full
285 prototypes by adding void, to avoid compiler warnings.
289 * options.cc (General_options::parse_plugin_opt): New.
290 (General_options::add_plugin): The argument now is just the filename.
291 (General_options::add_plugin_option): New.
292 * options.h (plugin_opt): New.
293 (add_plugin): Change argument name.
294 (add_plugin_option): New.
295 * plugin.cc (Plugin::load): Don't parse the plugin option.
296 * plugin.h (Plugin::Plugin): Rename argument. Init filename_.
297 (Plugin::add_option): New.
298 (Plugin::args_): Change type.
299 (Plugin::filename_): New.
300 (Plugin_manager::add_plugin_option): New.
301 * testsuite/Makefile.am (plugin_test_1): Use new syntax.
302 * testsuite/Makefile.in: Regenerate.
306 * layout.cc (Layout::include_section): Check for SHF_EXCLUDE.
307 Handle --strip-lto-sections option.
308 * options.h (strip_lto_sections): New option.
312 * plugin.cc (ld_plugin_message): Change format parameter to const.
313 Fix mismatch between new[] and delete.
317 * reloc.cc (Sized_relobj::do_read_relocs): Use constant invalid_address
322 * options.cc (General_options::parse_dynamic_list): New function.
323 * options.h (General_options): New flags dynamic_list,
324 dynamic_list_data, dynamic_list_cpp_new, and
325 dynamic_list_cpp_typeinfo. New variable dynamic_list_.
326 (General_options::in_dynamic_list): New function.
327 * script.cc (Lex::Mode): New enum DYNAMIC_LIST.
328 (Lex::can_start_name): Add support for DYNAMIC_LIST mode.
329 (Lex::can_continue_name): Likewise.
331 (read_script_file): New parameter script_options.
332 (read_dynamic_list): New function.
333 (Script_options::define_dynamic_list): New function.
334 (dynamic_list_keyword_parsecodes): New variable.
335 (dynamic_list_keywords): New variable.
336 * script.h (Script_options::define_dynamic_list): New function
338 (read_dynamic_list): New function prototype.
339 * symtab.cc (strprefix): New macro.
340 (Symbol::should_add_dynsym_entry): Support dynamic_list,
341 dynamic_list_data, dynamic_list_cpp_new, and
342 dynamic_list_cpp_typeinfo.
343 * yyscript.y (PARSING_DYNAMIC_LIST): New token.
344 (dynamic_list_expr): New rule.
345 (dynamic_list_nodes): Likewise.
346 (dynamic_list_node): Likewise.
347 * testsuite/Makefile.am (dynamic_list): New test.
348 * testsuite/Makefile.in: Regenerated.
349 * testsuite/dynamic_list.t: New file.
350 * testsuite/dynamic_list.sh: New file.
354 * testsuite/tls_test_c.c: Add prototype for t11 and t11_last.
355 * testsuite/tls_test_c.c (t11): Add explicit "void" to prototype.
356 (t11_last): Likewise.
357 * testsuite/ver_test_6.c (main): Likewise.
361 * options.c (General_options::finalize): Add check for -static and
363 * gold.cc (queue_middle_tasks): Assert that list of dynamic objects
368 * plugin.cc (make_sized_plugin_object): Fix conditional
369 compilation to work when not all targets are enabled.
373 * archive.cc (Archive::get_file_and_offset): Use filename instead
374 of name to get library path.
375 (Archive::include_member): Unlock external member of a thin archive.
377 * testsuite/Makefile.am (TEST_AR): New variable.
378 (thin_archive_test_1): New test.
379 (thin_archive_test_2): New test.
380 * testsuite/Makefile.in: Regenerate.
381 * testsuite/thin_archive_main.cc: New file.
382 * testsuite/thin_archive_test_1.cc: New file.
383 * testsuite/thin_archive_test_2.cc: New file.
384 * testsuite/thin_archive_test_3.cc: New file.
385 * testsuite/thin_archive_test_4.cc: New file.
389 * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.
390 * object.cc (Sized_relobj::do_layout): Use constant invalid_address
392 (Sized_relobj::do_finalize_local_symbols): Likewise.
393 (Sized_relobj::map_to_kept_section): Likewise.
394 * object.h (Sized_relobj::invalid_address): New constant.
395 (Sized_relobj::do_output_section_offset): Check for invalid_address
397 * output.cc (Output_reloc::local_section_offset): Use constant
398 invalid_address instead of -1U.
399 (Output_reloc::get_address): Likewise.
400 (Output_section::output_address): Change -1U to -1ULL.
401 * output.h (Output_reloc::invalid_address): New constant.
402 * reloc.cc (Sized_relobj::write_sections): Use constant
403 invalid_address instead of -1U.
404 (Sized_relobj::relocate_sections): Likewise.
405 * symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
406 values for merge sections.
407 * target-reloc.h (relocate_for_relocatable): Use constant
408 invalid_address instead of -1U.
412 Add plugin functionality for link-time optimization (LTO).
413 * configure.ac (plugins): Add --enable-plugins option.
414 * configure: Regenerate.
415 * config.in: Regenerate.
416 * Makefile.am (LIBDL): New variable.
417 (CCFILES): Add plugin.cc.
418 (HFILES): Add plugin.h.
419 (ldadd_var): Add LIBDL.
420 * Makefile.in: Regenerate.
422 * archive.cc: Include "plugin.h".
423 (Archive::setup): Don't preread archive symbols when using a plugin.
424 (Archive::get_file_and_offset): Add memsize parameter. Change callers.
425 (Archive::get_elf_object_for_member): Call plugin hooks for claiming
427 (Archive::include_member): Add symbols from plugin objects.
428 * archive.h (Archive::get_file_and_offset): Add memsize parameter.
429 * descriptors.cc (Descriptors::open): Check for file descriptors
430 abandoned by plugins.
431 (Descriptors::claim_for_plugin): New function.
432 * descriptors.h (Descriptors::claim_for_plugin): New function.
433 (Open_descriptor::is_claimed): New field.
434 (claim_descriptor_for_plugin): New function.
435 * fileread.cc (File_read::claim_for_plugin): New function.
436 * fileread.h (File_read::claim_for_plugin): New function.
437 (File_read::descriptor): New function.
438 * gold.cc: Include "plugin.h".
439 (queue_initial_tasks): Add task to call plugin hooks for generating
441 * main.cc: Include "plugin.h".
442 (main): Load plugin libraries.
443 * object.h (Pluginobj): Declare.
444 (Object::pluginobj): New function.
445 (Object::do_pluginobj): New function.
446 (Object::set_target): New function.
447 * options.cc: Include "plugin.h".
448 (General_options::parse_plugin): New function.
449 (General_options::General_options): Initialize plugins_ field.
450 (General_options::add_plugin): New function.
451 * options.h (Plugin_manager): Declare.
452 (General_options): Add --plugin option.
453 (General_options::has_plugins): New function.
454 (General_options::plugins): New function.
455 (General_options::add_plugin): New function.
456 (General_options::plugins_): New field.
457 * plugin.cc: New file.
458 * plugin.h: New file.
459 * readsyms.cc: Include "plugin.h".
460 (Read_symbols::do_read_symbols): Check for archive before checking
461 for ELF file. Call plugin hooks to claim files.
462 * resolve.cc (Symbol_table::resolve): Record when symbol is referenced
463 from a real object file; force override when processing replacement
465 * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field.
466 (Symbol::init_base_object): Likewise.
467 (Symbol::init_base_output_data): Likewise.
468 (Symbol::init_base_output_segment): Likewise.
469 (Symbol::init_base_constant): Likewise.
470 (Symbol::init_base_undefined): Likewise.
471 (Symbol::output_section): Assert that object is not a plugin.
472 (Symbol_table::add_from_pluginobj): New function.
473 (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as
475 (Symbol_table::sized_write_globals): Likewise.
476 (Symbol_table::add_from_pluginobj): Instantiate template.
477 * symtab.h (Sized_pluginobj): Declare.
478 (Symbol::in_real_elf): New function.
479 (Symbol::set_in_real_elf): New function.
480 (Symbol::in_real_elf_): New field.
481 (Symbol_table::add_from_pluginobj): New function.
483 * testsuite/Makefile.am (AM_CFLAGS): New variable.
484 (LIBDL): New variable.
486 (check_PROGRAMS): Add plugin_test_1 and plugin_test_2.
487 (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh.
488 (check_DATA): Add plugin_test_1.err and plugin_test_2.err.
489 (MOSTLYCLEANFILES): Likewise.
490 * testsuite/Makefile.in: Regenerate.
491 * testsuite/plugin_test.c: New file.
492 * testsuite/plugin_test_1.sh: New file.
493 * testsuite/plugin_test_2.sh: New file.
497 * target-reloc.h (relocate_section): Check whether a symbol is
498 defined by the ABI before reporting an undefined symbol error.
499 * target.h (Target::is_defined_by_abi): Make parameter const.
500 (Target::do_is_defined_by_abi): Likewise.
501 * i386.cc (Target_i386::do_is_defined_by_abi): Likewise.
502 * powerpc.cc (Target_powerpc::do_is_defined_by_abi): Likewise.
503 * sparc.cc (Target_sparc::do_is_defined_by_abi): Likewise.
504 * x86_64.cc (Target_x86_64::do_is_defined_by_abi): Likewise.
505 * testsuite/Makefile.am (tls_test_shared.so): Add -Wl,-z,defs.
506 * testsuite/Makefile.in: Rebuild.
508 * fileread.cc (make_view): Add casts to avoid warning.
512 * i386.cc (Target_i386::define_tls_base_symbol): Update comments.
513 * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
517 * options.h (General_options::output_is_executable): New.
518 (General_options::output_is_pie): New.
519 * i386.cc (Target_i386::define_tls_base_symbol): Use SEGMENT_START
520 for shared libraries.
521 * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
525 * options.h (origin): New -z option.
526 * layout.cc (Layout:finish_dynamic_section): If "-z origin"
527 is specified, set DF_ORIGIN in DT_FLAGS and set DF_1_ORIGIN
532 * fileread.cc (File_read::make_view): Add check for attempt to map
537 * symtab.cc (Symbol_table::add_from_dynobj): Fix typos in
538 explicit instantiations.
543 * options.cc (General_options::finalize): Allow undefined symbols
544 in shlibs if linking -shared.
547 * symtab.cc (Symbol::init_base_undefined): Mark explicitly undefined
548 symbols as not needing a dynsym entry.
552 * fileread.cc (File_read::open): Do not lock the file unless it
553 was successfully opened.
557 * x86_64.cc (Target_x86_64::Relocate::relocat_tls):
558 Use addend for DTPOFF32, DTPOFF64, and TPOFF32 relocs.
559 * testsuite/tls_test.cc (struct int128): 128-bit struct
560 for testing TLS relocs with non-zero addend.
561 (v12): New TLS variable.
563 (t_last): Add check for v12.
564 * testsuite/tls_test.h (t12): New function.
565 * testsuite/tls_test_main.cc (thread_routine): Call new test.
569 * layout.cc (Layout::attach_allocated_section_to_segment): Don't
570 set tls_segment_ or relro_segment_.
571 (Layout::make_output_segment): Set tls_segment_ and relro_segment_
573 * output.h (Output_section::clear_is_relro): New function.
574 * output.cc (Output_segment::add_output_section): Handle SHF_TLS
575 sections specially even when output_data_ is empty.
576 (Output_segment::maximum_alignment): When first section is relro,
577 only force alignment for PT_LOAD segments.
578 * script.cc (script_data_segment_align): New function.
579 (script_data_segment_relro_end): New function.
580 * script-c.h (script_data_segment_align): Declare.
581 (script_data_segment_relro_end): Declare.
582 * script-sections.h (class Script_sections): Declare
583 data_segment_align and data_segment_relro_end. Add fields
584 segment_align_index_ and saw_relro_end_.
585 * script-sections.cc (class Sections_element): Add set_is_relro
586 virtual function. Add new bool* parameter to place_orphan_here.
587 Add get_output_section virtual function.
588 (class Output_section_definition): Add set_is_relro. Add new
589 bool* parameter to place_orphan_here. Add get_output_section.
591 (Output_section_definition::Output_section_definition): Initialize
592 evaluated_address_, evaluated_load_address, evaluated_addralign_,
593 and is_relro_ fields.
594 (Output_section_definition::place_orphan_here): Add is_relro
596 (Output_section_definition::set_section_addresses): Set relro for
598 (Output_section_definition::alternate_constraint): Likewise.
599 (class Orphan_output_section): Add new bool* parameter to
600 place_orphan_here. Add get_output_section.
601 (Orphan_output_section::place_orphan_here): Add is_relro
603 (Script_sections::Script_sections): Initialize
604 data_segment_align_index_ and saw_relro_end_.
605 (Script_sections::data_segment_align): New function.
606 (Script_sections::data_segment_relro_end): New function.
607 (Script_sections::place_orphan): Set or clear is_relro.
608 (Script_sections::set_section_addresses): Force alignment of first
610 * yyscript.y (exp): Call script_data_segment_align and
611 script_data_segment_relro_end.
612 * testsuite/relro_script_test.t: New file.
613 * testsuite/relro_test.cc (using_script): Declare.
614 (t1, t2): Test using_script.
615 * testsuite/Makefile.am (check_PROGRAMS): Add relro_script_test.
616 (relro_script_test_SOURCES): Define.
617 (relro_script_test_DEPENDENCIES): Define.
618 (relro_script_test_LDFLAGS): Define.
619 (relro_script_test_LDADD): Define.
620 (relro_script_test.so): New target.
621 * testsuite/Makefile.in: Rebuild.
625 * archive.cc (Archive::total_archives, Archive::total_members)
626 (Archive::total_members_loaded): New variables.
627 (Archive::setup): Add parameter. Add option to preread
629 (Archive::read_armap): Add counter.
630 (Archive::get_file_and_offset): New function.
631 (Archive::get_elf_object_for_member): New function.
632 (Archive::read_all_symbols): New function.
633 (Archive::read_symbols): New function.
634 (Archive::add_symbols): Add counters.
635 (Archive::include_all_members): Use armap to find members if it's
637 (Archive::include_member): Skip reading symbols if already read.
638 Factored code into Archive::get_file_and_offset and
639 Archive::get_elf_object_for_member. Changed call to
640 Mapfile::report_include_archive_member.
641 (Archive::print_stats): New function.
642 * archive.h: Declare Object and Read_symbols_data classes.
643 (Archive::Archive): Add initializers for new members.
644 (Archive::setup): Add parameter.
645 (Archive::print_stats): New function.
646 (Archive::total_archives, Archive::total_members)
647 (Archive::total_members_loaded): New variables.
648 (Archive::get_file_and_offset): New function.
649 (Archive::get_elf_object_for_member): New function.
650 (Archive::read_all_symbols): New function.
651 (Archive::read_symbols): New function.
652 (Archive::Archive_member): New class.
653 (Archive::members_): New member.
654 (Archive::num_members_): New member.
655 * main.cc: Include archive.h.
656 (main): Call Archive::print_stats.
657 * mapfile.cc (Mapfile::report_include_archive_member): Delete
658 archive parameter; member_name is now the fully-decorated name.
659 * mapfile.h (Mapfile::report_include_archive_member): Likewise.
660 * options.h: (General_options): Add --preread-archive-symbols option.
661 * readsyms.cc (Read_symbols::do_read_symbols): Change call to
666 * symtab.h (Symbol::use_plt_offset): New function.
667 * i386.cc (Relocate::relocate): Call Symbol::use_plt_offset.
668 * powerpc.cc (Relocate::relocate): Likewise.
669 * sparc.cc (Relocate::relocate): Likewise.
670 * x86_64.cc (Relocate::relocate): Likewise.
671 * testsuite/weak_plt.sh: New test.
672 * testsuite/weak_plt_main.cc: New test.
673 * testsuite/weak_plt_shared.cc: New test.
674 * testsuite/Makefile.am (check_SCRIPTS): Add weak_plt.sh.
675 (check_PROGRAMS): Add weak_plt.
676 (check_DATA): Add weak_plt_shared.so.
677 (weak_plt_main_pic.o, weak_plt): New targets.
678 (weak_plt_shared_pic.o, weak_plt_shared.so): New targets.
679 * testsuite/Makefile.in: Rebuild.
681 * testsuite/Makefile.am (weak_alias_test_1.so): Depend upon
683 (weak_alias_test_2.so, weak_alias_test_4.so): Likewise.
684 * testsuite/Makefile.in: Rebuild.
688 * Makefile.am (POTFILES.in): Set LC_ALL=C.
689 * Makefile.in: Regenerate.
690 * po/POTFILES.in: Regenerate.
694 * script.cc (Script_options::finalize_symbols): Finalize SECTIONS
695 symbols before other symbols.
696 * testsuite/script_test_2.cc (test_addr): Declare.
697 (test_addr_alias): Declare.
698 (main): Check that test_addr and test_addr_alias have the right
700 * testsuite/script_test_2.t: Define test_addr_alias and
706 * descriptors.cc: New file.
707 * descriptors.h: New file.
708 * gold-threads.h (class Hold_optional_lock): New class.
709 * fileread.cc: Include "descriptors.h".
710 (File_read::~File_read): Release descriptor rather than closing
712 (File_read::open) [file]: Call open_descriptor rather than open.
713 Set is_descriptor_opened_.
714 (File_read::open) [memory]: Assert that descriptor is not open.
715 (File_read::reopen_descriptor): New function.
716 (File_read::release): Release descriptor.
717 (File_read::do_read): Make non-const. Reopen descriptor.
718 (File_read::read): Make non-const.
719 (File_read::make_view): Reopen descriptor.
720 (File_read::do_readv): Likewise.
721 * fileread.h (class File_read): Add is_descriptor_opened_ field.
723 * layout.cc: Include "descriptors.h".
724 (Layout::create_build_id): Use open_descriptor rather than open.
725 * output.cc: Include "descriptors.h".
726 (Output_file::open): Use open_descriptor rather than open.
727 * archive.cc (Archive::const_iterator): Change Archive to be
729 (Archive::begin, Archive::end): Make non-const.
730 (Archive::count_members): Likewise.
731 * archive.h (class Archive): Update declarations.
732 * object.h (Object::read): Make non-const.
733 * Makefile.am (CCFILES): Add descriptors.cc.
734 (HFILES): Add descriptors.h.
735 * Makefile.in: Rebuild.
738 * gold.h: Always include <clocale>. Add Solaris workarounds
739 following code in binutils/sysdep.h.
742 * ehframe.cc (Eh_frame::add_ehframe_input_section): Check whether
743 this->eh_frame_hdr_ is NULL before using it.
745 * dynobj.cc (Versions::Versions): Update comment.
747 * dynobj.cc (Versions::Versions): If there is an soname, use it as
748 the base version name.
750 * stringpool.cc (Stringpool_template::add_with_length): Set key to
752 (Stringpool_template::set_string_offsets): Subtract one from key
753 before using it as an array index.
754 (Stringpool_template::get_offset_with_length): Likewise.
755 (Stringpool_template::write_to_buffer): Likewise.
756 * stringpool.h (Stringpool_template::get_offset_from_key):
762 * object.h (Merged_symbol_value::value): Do our best to handle a
766 * script.cc (Version_script_info::get_versions): Don't add empty
767 version tag to return value.
768 (Version_script_info::get_symbol_version_helper): Change return
769 type to bool. Add pversion parameter. Change all callers.
770 (script_register_vers_node): Don't require a non-NULL tag.
771 * script.h (class Version_script_info): Update declarations.
772 (Version_script_info::get_symbol_version): Change return type to
773 bool. Add version parameter. Change all callers.
774 * symtab.cc (Sized_symbol::add_from_relobj): Rework version
775 handling. Handle an empty version from a version script.
776 (Symbol_table::define_special_symbol): Likewise.
777 * testsuite/ver_test_10.script: New file.
778 * testsuite/ver_test_10.sh: New file.
779 * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_10.sh.
780 (check_DATA): Add ver_test_10.syms.
781 (ver_test_10.syms, ver_test_10.so): New target.
782 * testsuite/Makefile.in: Rebuild.
786 * symtab.cc (Symbol_table::sized_write_symbol): Only set st_size
787 to zero for undefined symbols from dynamic libraries.
791 * symtab.cc (Symbol_table::resolve): Remove version parameter.
793 * symtab.h (class Symbol_table): Update declaration.
794 * testsuite/ver_test_9.cc: New file.
795 * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_9.
796 (ver_test_9_SOURCES, ver_test_9_DEPENDENCIES): Define.
797 (ver_test_9_LDFLAGS, ver_test_9_LDADD): Define.
798 (ver_test_9.so, ver_test_9.o): New targets.
799 * testsuite/Makefile.in: Rebuild.
803 * options.h (class General_options): Define --check-sections.
804 * layout.cc (Layout::set_segment_offsets): Handle
807 * options.h (class General_options): Define -n/--nmagic and
809 * options.cc (General_options::finalize): For -n/--nmagic or
810 -N/--omagic, set -static.
811 * layout.cc (Layout::attach_allocated_section_to_segment): If
812 -N/--omagic, don't put read-only and read-write sections in
814 (Layout::find_first_load_seg): If -N/--omagic, don't insist on
815 finding a read-only segment.
816 (Layout::set_segment_offsets): If -N/--omagic or -n/--nmagic,
817 don't set the minimum segment alignment to the common page size,
818 and don't set the file offset to the address modulo the page size.
819 * script-sections.cc (Script_sections::create_segments): If
820 -n/--omagic, don't put read-only and read-write sections in
825 * options.h (class General_options): Add --print-symbol-counts.
826 * main.cc (main): Issue defined symbol report if requested.
827 * archive.cc (Archive::interpret_header): Make into a const member
829 (Archive::add_symbols): Call Input_objects::archive_start and
831 (Archive::const_iterator): Define new class.
832 (Archive::begin, Archive::end): New functions.
833 (Archive::include_all_members): Rewrite to use iterator.
834 (Archive::count_members): New function.
835 * archive.h (class Archive): Update declarations.
836 (Archive::filename): New function.
837 * object.cc: Include "cref.h".
838 (Sized_relobj::Sized_relobj): Initialize defined_count_.
839 (Sized_relobj::do_get_global_symbol_counts): New function.
840 (Input_objects::add_object): Add object to cross-referencer.
841 (Input_objects::archive_start): New function.
842 (Input_objects::archive_stop): New function.
843 (Input_objects::print_symbol_counts): New function.
844 * object.h: Declare Cref and Archive.
845 (Object::get_global_symbol_counts): New function.
846 (Object::do_get_global_symbol_counts): New pure virtual function.
847 (class Sized_relobj): Add defined_count_ field. Update
849 (class Input_objects): Add cref_ field. Update constructor.
851 * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and
853 (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing
855 (Sized_dynobj::do_get_global_symbol_counts): New function.
856 * dynobj.h (class Sized_dynobj): Add fields symbols_ and
857 defined_count_. Update declarations. Define Symbols typedef.
858 * symtab.cc (Symbol_table::add_from_relobj): Add defined
859 parameter. Change all callers.
860 (Symbol_table::add_from_dynobj): Add sympointers and defined
861 parameters. Change all callers.
862 * symtab.h (class Symbol_table): Update declarations.
863 * Makefile.am (CCFILES): Add cref.cc.
864 (HFILES): Add cref.h.
865 * Makefile.in: Rebuild.
869 * symtab.cc (Symbol_table::sized_write_symbol): Set symbol size
870 to zero when writing undefined symbols.
874 * output.cc (Output_section::add_input_section): Don't try to
875 merge empty merge sections.
879 * symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
880 Include symbol version in error message.
884 * configure.ac (gold_cv_c_random_seed): New configured variable.
885 (RANDOM_SEED_CFLAGS): New substituted variable.
886 * Makefile.am (AM_CFLAGS, AM_CXXFLAGS): Add $(RANDOM_SEED_CFLAGS).
887 * configure: Rebuild.
888 * Makefile.in: Likewise.
889 * testsuite/Makefile.in: Likewise.
893 * symtab.cc (Symbol_table::add_from_object): Rewrite the case
894 where we see NAME/NULL and NAME/VERSION as separate symbols.
895 * testsuite/ver_test_main.cc (main): Call t4.
897 * testsuite/ver_test_2.cc (t4_2): Define.
898 * testsuite/ver_test_2.script: Put t4_2a in VER2.
899 * testsuite/ver_test_4.cc (t4_2a): Define.
900 * testsuite/ver_test_4.script: Put t4_2a in VER2.
901 * testsuite/ver_test.h (t4, t4_2, t4_2a): Declare.
905 * dynobj.cc (Versions::add_def): If we give an error about a
906 missing version, go ahead and create the version anyhow.
910 Handle output sections with more than 0x7fffffff bytes.
911 * object.h (class Relobj): Change map_to_output_ to
912 output_sections_, and just keep a section pointer. Change all
913 uses. Move comdat group support to Sized_relobj.
914 (Relobj::is_section_specially_mapped): Remove.
915 (Relobj::output_section): Remove poff parameter. Change all
917 (Relobj::output_section_offset): New function.
918 (Relobj::set_section_offset): Rewrite.
919 (Relobj::map_to_output): Remove.
920 (Relobj::output_sections): New function.
921 (Relobj::do_output_section_offset): New pure virtual function.
922 (Relobj::do_set_section_offset): Likewise.
923 (class Sized_relobj): Add section_offsets_ field. Add comdat
924 group support from Relobj. Update declarations.
925 (Sized_relobj::get_output_section_offset): New function.
926 (Sized_relobj::do_output_section_offset): New function.
927 (Sized_relobj::do_set_section_offset): New function.
928 * object.cc (Relobj::output_section_address): Remove.
929 (Sized_relobj::Sized_relobj): Initialize new fields.
930 (Sized_relobj::include_section_group): Cast find_kept_object to
932 (Sized_relobj::include_linkonce_section): Likewise.
933 (Sized_relobj::do_layout): Use separate arrays for output section
935 (Sized_relobj::do_count_local_symbols): Change map_to_output to
937 (Sized_relobj::do_finalize_local_symbols): Change map_to_output to
938 output_sections and section_offsets.
939 (Sized_relobj::write_local_symbols): Likewise.
940 (map_to_kept_section): Compute output address directly.
941 * reloc.cc (Sized_relobj::do_read_relocs): Change map_to_output to
942 output_sections and section_offsets.
943 (Sized_relobj::write_sections): Likewise.
944 (Sized_relobj::relocate_sections): Likewise.
945 * symtab.cc (sized_finalize_symbol): Use output_section_offset.
946 * output.h (class Output_reloc): Update declarations. Change
947 u2_.relobj to Sized_relobj*.
948 (class Output_data_reloc): Change add functions to use
950 * output.cc (Output_reloc::Output_reloc): Change relobj to
952 (Output_reloc::local_section_offset): Change return type to
953 Elf_Addr. Use get_output_section_offset.
954 (Output_reloc::get_address): Likewise.
955 (Output_section::is_input_address_mapped): Don't call
956 is_section_specially_mapped.
957 (Output_section::output_offset): Likewise.
958 (Output_section::output_address): Likewise.
959 (Output_section::starting_output_address): Likewise.
960 * copy-relocs.cc (Copy_relocs::copy_reloc): Change object
961 parameter to Sized_relobj*.
962 (Copy_relocs::need_copy_reloc): Likewise.
963 (Copy_relocs::save): Likewise.
964 * copy-relocs.h (class Copy_relocs): Update declarations.
965 (class Copy_relocs::Copy_reloc_entry): Change constructor to use
966 Sized_relobj*. Change relobj_ field to Sized_relobj*.
967 * target-reloc.h (relocate_for_relocatable): Change
968 offset_in_output_section type to Elf_Addr. Change code that uses
970 * layout.cc (Layout::layout): Always set *off.
971 * mapfile.cc (Mapfile::print_input_section): Use
972 output_section_offset.
973 * i386.cc (Target_i386::copy_reloc): Change object parameter to
975 * powerpc.cc (Target_powerpc::copy_reloc): Likewise.
976 * sparc.cc (Target_sparc::copy_reloc): Likewise.
977 * x86_64.cc (Target_x86_64::copy_reloc): Likewise.
981 * layout.cc (Layout::include_section): Do not discard unrecognized
986 * script.cc (Lex::can_continue_name): Make '?' allowable in
987 version-script names.
988 * testsuite/version_script.map: Change glob pattern to use '?'
993 * symtab.cc (Symbol_table::add_undefined_symbols_from_command_line):
1000 * powerpc.cc (Powerpc_relocate_functions::addr16_ha) [both
1001 versions]: Don't try to read the value in the contents, since we
1002 don't use it. Use the template endianness when writing.
1006 * fileread.cc (File_read::make_view): Assert on zero-length view.
1007 * object.cc (Sized_relobj::do_read_symbols): Don't try to read
1008 symbol table when there are no symbols to read.
1012 * version.cc (version_string): Bump to 1.7
1016 * powerpc.cc (Powerpc_relocate_functions::addr16_ha): cast
1017 constant 0xFFFF to type Valtype.
1018 (Powerpc_relocate_functions::rel16_ha): Likewise.
1022 * output.h (Output_section::Input_section): Initialize p2align_ to
1023 zero for Output_section_data constructors.
1024 (Output_section::Input_section::addralign): If not an input
1025 section, return the alignment of the Output_section_data.
1026 * testsuite/copy_test.cc: New file.
1027 * testsuite/copy_test_1.cc: New file.
1028 * testsuite/copy_test_2.cc: New file.
1029 * testsuite/Makefile.am (check_PROGRAMS): Add copy_test.
1030 (copy_test_SOURCES, copy_test_DEPENDENCIES): New variables.
1031 (copy_test_LDFLAGS, copy_test_LDADD): New variables.
1032 (copy_test_1_pic.o, copy_test_1.so): New targets.
1033 (copy_test_2_pic.o, copy_test_2.so): New targets.
1034 * testsuite/Makefile.in: Rebuild.
1036 * script-sections.cc (Script_sections::place_orphan): Initialize
1037 local variable exact.
1041 * powerpc.cc (Output_data_plt_powerpc::do_write): 8 + 4 = 0xC.
1046 * powerpc.cc: New file.
1047 * Makefile.am (TARGETSOURCES): Add powerpc.cc
1048 (ALL_TARGETOBJS): Add powerpc.$(OBJEXT)
1049 * configure.tgt: Add entries for powerpc-* and powerpc64-*.
1050 * Makefile.in: Rebuild.
1054 * testsuite/relro_test.cc: Include <cstdio>, <cstdlib>, and
1056 (throwing, orig_terminate): New static variables.
1057 (terminate_handler): New static function.
1058 (t2): Set terminate handler.
1063 * binary.cc (Binary_to_elf::sized_convert): Fix .data
1068 * archive.cc (Archive::include_all_members) Correct to step
1069 over symbol table and extended name table in thin archives.
1074 * target-reloc.h (relocate_for_relocatable): Fix new_offset
1079 * reduced_debug_output.cc: New file.
1080 * reduced_debug_output.h: New file.
1081 * options.h (class General_options): Add --strip-debug-non-line.
1082 * options.cc (General_options::finalize): Add strip_debug_non_line
1083 to the strip heirarchy.
1084 * layout.h (class Layout): Add debug_abbrev_ and debug_info_
1086 * layout.cc: Include "reduced_debug_output.h".
1087 (Layout::Layout): Initialize new fields.
1088 (line_only_debug_sections): New static array.
1089 (is_lines_only_debug_sections): New static inline function.
1090 (Layout::include_section): Handle --strip-debug-non-line.
1091 (Layout::make_output_section): If --strip-debug-non-line, build
1092 new output sections for .debug_abbrev and .debug_info.
1093 * dwarf_reader.cc (read_unsigned_LEB_128): Move to namespace
1094 gold. Warn about possible overflow.
1095 (read_signed_LEB_128): Likewise.
1096 * dwarf_reader.h: (read_unsigned_LEB_128): Declare.
1097 (read_signed_LEB_128): Declare.
1098 * Makefile.am (CCFILES): Add reduced_debug_output.cc.
1099 (HFILES): Add reduced_debug_output.h.
1100 * Makefile.in: Rebuild.
1104 * mapfile.cc: New file.
1105 * mapfile.h: New file.
1106 * options.h (class General_options): Add -M/--print-map and -Map.
1107 * options.cc (General_options::finalize): Make -M equivalent to
1109 * main.cc: Include <cstdio> and "mapfile.h".
1110 (main): Open mapfile if requested.
1111 * gold.cc (class Middle_runner): Add mapfile_ field. Update
1112 constructor. Change caller.
1113 (queue_initial_tasks): Add mapfile parameter. Change caller.
1114 (queue_middle_tasks): Likewise.
1115 * gold.h (queue_initial_tasks, queue_middle_tasks): Update
1117 * archive.cc: Include "mapfile.h".
1118 (Archive::add_symbols): Add mapfile parameter. Change all
1119 callers. Pass mapfile, symbol, and reason to include_member.
1120 (Archive::include_all_members): Add mapfile parameter. Change all
1122 (Archive::include_member): Add mapfile, sym, and why parameters.
1123 Change all callers. Report inclusion to map file.
1124 * archive.h: Include "fileread.h".
1125 (class Archive): Update declarations.
1126 (Archive::file): New const method.
1127 (class Add_archive_symbols): Add mapfile_ field. Update
1128 constructor. Change all callers.
1129 * readsyms.h (class Read_symbols): Likewise.
1130 (class Finish_group): Likewise.
1131 (class Read_script): Likewise.
1132 * common.cc: Include "mapfile.h".
1133 (Symbol_table::allocate_commons): Add mapfile parameter. Change
1135 (Symbol_table::do_allocate_commons): Likewise.
1136 (Symbol_table::do_allocate_commons_list): Likewise. Report common
1137 symbol allocation to mapfile.
1138 * common.h (class Allocate_commons_task): Add mapfile_ field.
1139 Update constructor. Change all callers.
1140 * symtab.h (class Symbol_table): Update declarations.
1141 * layout.cc: Include "mapfile.h".
1142 (Layout_task_runner::run): Print information to mapfile.
1143 (Layout::create_gold_note): Change Output_data_fixed_space to
1144 Output_data_zero_fill.
1145 (Layout::create_build_id): Likewise.
1146 (Layout::print_to_mapfile): New function.
1147 * layout.h (class Layout_task_runner): Add mapfile_ field. Update
1148 constructor. Change caller.
1149 (class Layout): Declare print_to_mapfile.
1150 * output.cc (Output_section::Input_section::print_to_mapfile): New
1152 (Output_section::add_input_section): If producing a map, always
1153 add to input_sections_ list.
1154 (Output_section::do_print_to_mapfile): New function.
1155 (Output_segment::print_sections_to_mapfile): New function.
1156 (Output_segment::print_section_list_to_mapfile): New function.
1157 * output.h: Include "mapfile.h".
1158 (Output_data::print_to_mapfile): New function.
1159 (Output_data::do_print_to_mapfile): New virtual function.
1160 (Output_segment_headers::do_print_to_mapfile): New function.
1161 (Output_file_header::do_print_to_mapfile): New function.
1162 (Output_data_const::do_print_to_mapfile): New function.
1163 (class Output_data_const_buffer): Add map_name_ field. Update
1164 constructor. Change all callers. Add do_print_to_mapfile
1166 (class Output_data_fixed_space): Likewise.
1167 (class Output_data_space): Likewise.
1168 (class Output_data_zero_fill): New class.
1169 (Output_data_strtab::do_print_to_mapfile): New function.
1170 (Output_data_reloc_base::do_print_to_mapfile): New function.
1171 (Output_relocatable_relocs::do_print_to_mapfile): New function.
1172 (Output_data_group::do_print_to_mapfile): New function.
1173 (Output_data_got::do_print_to_mapfile): New function.
1174 (Output_data_dynamic::do_print_to_mapfile): New function.
1175 (Output_symtab_xindex::do_print_to_mapfile): New function.
1176 (class Output_section): Declare do_print_to_mapflie. Declare
1177 print_to_mapfile in Input_section.
1178 (class Output_segment): Declare new functions.
1179 * object.h (Sized_relobj::symbol_count): New function.
1180 * script-sections.cc
1181 (Output_section_element_dot_assignment::set_section_addresses):
1182 Change Output_data_fixed_space to Output_data_zero_fill.
1183 (Output_data_expression::do_print_to_mapfile): New function.
1184 * script.cc (read_input_script): Add mapfile parameter. Change
1186 * script.h (read_input_script): Update declaration.
1187 * ehframe.h (Eh_frame_hdr::do_print_to_mapfile): New function.
1188 (Eh_frame::do_print_to_mapfile): New function.
1189 * merge.h (Output_merge_data::do_print_to_mapfile): New function.
1190 (Output_merge_string::do_print_to_mapfile): New function.
1191 * i386.cc (Output_data_plt_i386::do_print_to_mapfile): New
1193 * sparc.cc (Output_data_plt_sparc::do_print_to_mapfile): New
1195 * x86_64.cc (Output_data_plt_x86_64::do_print_to_mapfile): New
1197 * Makefile.am (CCFILES): Add mapfile.cc.
1198 (HFILES): Add mapfile.h.
1199 * Makefile.in: Rebuild.
1203 * options.h (class General_options): Add -z relro.
1204 * layout.cc (Layout::Layout): Initialize relro_segment_.
1205 (Layout::add_output_section_data): Return the output section.
1206 (Layout::make_output_section): Rcognize relro sections and mark
1208 (Layout::attach_allocated_section_to_segment): Put relro sections
1209 in a PT_GNU_RELRO segment.
1210 (Layout::create_initial_dynamic_sections): Mark the .dynamic
1212 (Layout::segment_precedes): Sort PT_GNU_RELRO segments after
1214 (Layout::linkonce_mapping): Map d.rel.ro.local to
1216 (Layout::output_section_name): Us .data.rel.ro.local for any
1217 section which begins with that.
1218 * layout.h (class Layout): Update add_output_section_data
1219 declaration. Add relro_segment_ field.
1220 * output.cc (Output_section::Output_section): Initialize is_relro_
1221 and is_relro_local_ fields.
1222 (Output_segment::add_output_section): Group relro sections.
1223 (Output_segment::is_first_section_relro): New function.
1224 (Output_segment::maximum_alignment): If there is a relro section,
1225 align the segment to the common page size.
1226 (Output_segment::set_section_addresses): Track whether we are
1227 looking at relro sections. If the last section is a relro
1228 section, align to the common page size.
1229 (Output_segment::set_section_list_addresses): Add in_relro
1230 parameter. Change all callers. Align to the page size when
1231 moving from relro to non-relro section.
1232 (Output_segment::set_offset): Align memsz of a PT_GNU_RELRO
1234 * output.h (class Output_section): Add is_relro_ and
1235 is_relro_local_ fields.
1236 (Output_section::is_relro): New function.
1237 (Output_section::set_is_relro): New function.
1238 (Output_section::is_relro_local): New function.
1239 (Output_section::set_is_relro_local): New function.
1240 (class Output_segment): Update declarations.
1241 * i386.cc (Target_i386::got_section): Mark .got section as relro.
1242 * sparc.cc (Target_sparc::got_section): Likewise.
1243 * x86_64.cc (Target_x86_64::got_section): Likewise.
1244 * testsuite/relro_test_main.cc: New file.
1245 * testsuite/relro_test.cc: New file.
1246 * testsuite/Makefile.am (check_PROGRAMS): Add relro_test.
1247 (relro_test_SOURCES, relro_test_DEPENDENCIES): New variables.
1248 (relro_test_LDFLAGS, relro_test_LDADD): New variables.
1249 (relro_test.so, relro_test_pic.o): New targets.
1250 * testsuite/Makefile.in: Rebuild.
1254 * output.cc (Output_segment::add_output_section): Remove front
1256 * output.h (class Output_segment): Remove
1257 add_initial_output_section and overloaded add_output_section.
1258 Update declaration of remaining add_output_section.
1259 * layout.cc (Layout::create_interp): Call add_output_section
1260 rather than add_initial_output_section.
1261 (Layout::finish_dynamic_section): Likewise.
1263 * i386.cc (Target_i386::Relocate::relocate_tls): Set dynamic type
1264 for TLS_GOTDESC and TLS_DESC_CALL. Only optimize TLS_LDO_32 if we
1265 know the dynamic type.
1266 * x86_64.cc (Target_x86_64::Relocate): Add saw_tls_block_reloc_
1267 field. Initialize it in constructor.
1268 (Target_x86_64::Relocate::relocate_tls): Record that we saw a TLS
1269 block reloc for TLSGD, GOTPC32_TLSDESC, TLSDESC_CALL, and TLSLD.
1270 Only optimize DTPOFF32 and DTPOFF64 if we have seen a TLS block
1273 * output.cc (Output_reloc::get_address): Change return type to
1275 * output.h (class Output_reloc): Update get_address declaration.
1276 * x86_64.cc (Output_data_plt_x86_64::do_write): Use 64-bit types
1277 for section addresses.
1282 * gold.cc (gold_nomem): Use return value of write.
1286 * symtab.c (Symbol::init_base_output_data): Add version
1287 parameter. Change all callers.
1288 (Symbol::init_base_output_segment): Likewise.
1289 (Symbol::init_base_constant): Likewise.
1290 (Symbol::init_base_undefined): Likewise.
1291 (Sized_symbol::init_output_data): Likewise.
1292 (Sized_symbol::init_output_segment): Likewise.
1293 (Sized_symbol::init_constant): Likewise.
1294 (Sized_symbol::init_undefined): Likewise.
1295 (Symbol_table::do_define_in_output_data): If the new symbol has a
1296 version, mark it as the default.
1297 (Symbol_table::do_define_in_output_segment): Likewise.
1298 (Symbol_table::do_define_as_constant): Likewise.
1299 * symtab.h (class Symbol): Update declarations.
1300 (class Sized_symbol): Likewise.
1301 * resolve.cc (Symbol::override_version): New function.
1302 (Symbol::override_base): Call override_version.
1303 (Symbol::override_base_with_special): Likewise.
1304 * testsuite/ver_script_8.script: New file.
1305 * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_8.
1306 (ver_test_8_SOURCES, ver_test_8_DEPENDENCIES): Define.
1307 (ver_test_8_LDFLAGS, ver_test_8_LDADD): Define.
1308 (ver_test_8_1.so, ver_test_8_2.so): New targets.
1313 * options.h (DEFINE_set): Add VARNAME_begin and VARNAME_end
1315 (class General_options): Remove existing --undefined, and add
1316 --no-undefined instead. Add new --undefined as synonym for -u.
1317 * archive.cc (Archive::add_symbols): Check whether symbol was
1319 * gold.cc (queue_middle_tasks): Add -u symbols to symbol table.
1320 * symtab.h (class Symbol): Rename CONSTANT to IS_CONSTANT; change
1321 all uses. Add IS_UNDEFINED. Update declarations to split
1322 different versions of init_base. Declare init_base_undefined.
1323 (Symbol::is_defined): Handle IS_UNDEFINED.
1324 (Symbol::is_undefined): Likewise.
1325 (Symbol::is_weak_undefined): Call is_undefined.
1326 (Symbol::is_absolute): Handle IS_CONSTANT.
1327 (class Sized_symbol): Update declarations to split different
1328 versions of init. Declare init_undefined.
1329 (class Symbol_table): Declare new functions.
1330 * symtab.cc (Symbol::init_base_object): Rename from init_base.
1332 (Symbol::init_base_output_data): Likewise.
1333 (Symbol::init_base_output_segment): Likewise.
1334 (Symbol::init_base_constant): Likewise.
1335 (Symbol::init_base_undefined): New function.
1336 (Sized_symbol::init_object): Rename from init. Change all
1338 (Sized_symbol::init_output_data): Likewise.
1339 (Sized_symbol::init_output_segment): Likewise.
1340 (Sized_symbol::init_constant): Likewise.
1341 (Sized_symbol::init_undefined): New function.
1342 (Symbol_table::add_undefined_symbols_from_command_line): New
1344 (Symbol_table::do_add_undefined_symbols_from_command_line): New
1346 (Symbol::final_value_is_known): Handle IS_UNDEFINED.
1347 (Symbol::output_section): Likewise.
1348 (Symbol::set_output_section): Likewise.
1349 (Symbol_table::sized_finalize_symbol): Likewise.
1350 (Symbol_table::sized_write_globals): Likewise.
1351 * resolve.cc (Symbol_table::should_override): Likewise.
1352 (Symbol::override_base_with_special): Likewise.
1354 * symtab.cc (Symbol_table::add_from_dynobj): If we see a protected
1355 symbol, change it to have default visibility.
1356 * testsuite/protected_1.cc: New file.
1357 * testsuite/protected_2.cc: New file.
1358 * testsuite/protected_3.cc: New file.
1359 * testsuite/protected_main_1.cc: New file.
1360 * testsuite/protected_main_2.cc: New file.
1361 * testsuite/protected_main_3.cc: New file.
1362 * testsuite/Makefile.am (check_PROGRAMS): Add protected_1.
1363 (protected_1_SOURCES, protected_1_DEPENDENCIES): Define.
1364 (protected_1_LDFLAGS, protected_1_LDADD): Define.
1365 (protected_1.so): New target.
1366 (protected_1_pic.o, protected_2_pic.o): New targets.
1367 (protected_3_pic.o): New target.
1368 (check_PROGRAMS): Add protected_2.
1369 (protected_2_SOURCES, protected_2_DEPENDENCIES): Define.
1370 (protected_2_LDFLAGS, protected_2_LDADD): Define.
1371 * testsuite/Makefile.in: Rebuild.
1373 * options.h (DEFINE_var): Add set_user_set_##varname__.
1374 (DEFINE_bool_alias): New macro.
1375 (class General_options): Define -Bstatic using DEFINE_bool_alias
1376 rather than DEFINE_special. Add --undefined as an alias for -z
1378 * options.cc (General_options::parse_Bstatic): Remove.
1380 * options.h (class General_options): Add --fatal-warnings.
1381 * main.cc (main): Implement --fatal-warnings.
1382 * errors.h (Errors::warning_count): New function.
1384 * options.h (class General_options): Add -Bsymbolic-functions.
1385 * symtab.h (Symbol::is_preemptible): Check for
1386 -Bsymbolic-functions.
1390 * options.h (DEFINE_bool): For DASH_Z, create the negative option
1391 as noVARNAME rather than no-VARNAME.
1392 (class General_options): Add option -z combreloc.
1393 * output.h (class Output_reloc) [SHT_REL]: Declare compare and
1395 (Output_reloc::sort_before) [SHT_REL]: New function.
1396 (Output_reloc::sort_before) [SHT_RELA]: New function.
1397 (class Output_data_reloc_base): Add sort_relocs_ field. Define
1398 Sort_relocs_comparison.
1399 (Output_data_reloc_base::Output_data_reloc_base): Add sort_relocs
1400 parameter. Change all callers.
1401 (Output_data_reloc::Output_data_reloc) [both versions]: Add
1402 sort_relocs parameter. Change all callers.
1403 * output.cc (Output_reloc::get_address): New function, broken out
1405 (Output_reloc::write_rel): Call it.
1406 (Output_reloc::compare): New function.
1407 (Output_data_reloc_base::do_write): Optionally sort relocs.
1409 * configure.ac: If targ_extra_obj is set, link it in.
1410 * configure.tgt: Initialize all variables.
1411 (x86_64*): Set targ_extra_obj and targ_extra_size.
1412 * configure: Rebuild.
1414 * object.cc (Sized_relobj::include_section_group): Adjust section
1415 indexes read from group data. Build vector to pass to
1417 * layout.cc (Layout::layout_group): Add flags and shndxes
1418 parameters. Remove contents parameter. Change caller. Update
1419 explicit instantiations.
1420 * layout.h (class Layout): Update layout_group declaration.
1421 * output.cc (Output_data_group::Output_data_group): Add flags and
1422 input_shndxes parameters. Remove contents parameter. Change
1424 (Output_data_group::do_write): Change input_sections_ to
1426 * output.h (class Output_data_group): Update constructor
1427 declaration. Rename input_sections_ to input_shndxes_.
1428 * testsuite/many_sections_test.cc: Add template.
1432 * target-reloc.h (relocate_section): Fix dead-pointer bug.
1434 * layout.cc (Layout::include_section): Refactored check for debug
1436 (Layout::add_comdat): Add new parameters. Change type
1437 of signature parameter. Add object and shndx to signatures table.
1438 (Layout::find_kept_object): New function.
1439 * layout.h: Include <cstring>.
1440 (Layout::is_debug_info_section): New function.
1441 (Layout::add_comdat): Add new parameters.
1442 (Layout::find_kept_object): New function.
1443 (Layout::Kept_section): New struct.
1444 (Layout::Signatures): Change type of map range.
1445 * object.cc (Relobj::output_section_address): New function.
1446 (Sized_relobj::include_section_group): Add new parameters. Change
1447 calls to Layout::add_comdat. Change to build table of kept comdat
1448 groups and table mapping discarded sections to kept sections.
1449 (Sized_relobj::include_linkonce_section): Likewise. Add new parameter.
1450 (Sized_relobj::do_layout): Change calls to include_section_group and
1451 include_linkonce_section.
1452 (Sized_relobj::do_finalize_local_symbols): Do not set local symbol
1453 value to zero when section is discarded.
1454 (Sized_relobj::map_to_kept_section): New function.
1455 * object.h (Relobj::output_section_address): New function.
1456 (Relobj::Comdat_group): New type.
1457 (Relobj::find_comdat_group): New function.
1458 (Relobj::Comdat_group_table): New type.
1459 (Relobj::Kept_comdat_section): New type.
1460 (Relobj::Kept_comdat_section_table): New type.
1461 (Relobj::add_comdat_group): New function.
1462 (Relobj::set_kept_comdat_section): New function.
1463 (Relobj::get_kept_comdat_section): New function.
1464 (Relobj::comdat_groups_): New field.
1465 (Relobj::kept_comdat_sections_): New field.
1466 (Symbol_value::input_value): Update comment.
1467 (Sized_relobj::map_to_kept_section) New function.
1468 (Sized_relobj::include_linkonce_section): Add new parameter.
1469 * target-reloc.h (Comdat_behavior): New type.
1470 (get_comdat_behavior): New function.
1471 (relocate_section): Add code to map a discarded section to the
1472 corresponding kept section when applying a relocation.
1476 * dwarf_reader.cc (next_generation_count): New static var.
1477 (Addr2line_cache_entry): New struct.
1478 (addr2line_cache): New static var.
1479 (Dwarf_line_info::one_addr2line): Added caching.
1480 (Dwarf_line_info::clear_addr2line_cache): New function.
1481 * dwarf_reader.h (Dwarf_line_info::one_addr2line): Add
1482 cache-size parameter.
1483 (Dwarf_line_info::one_addr2line_cache): New function.
1484 * symtab.cc (Symbol_table::detect_odr_violations): Pass
1485 new cache-size argument to one_addr2line(), and clear cache.
1489 * i386.cc (Relocate::relocate): Fix typos for R_386_PC16 and
1490 R_386_PC8 relocations.
1494 * object.cc (Sized_relobj::include_section_group): Check for
1495 invalid section group.
1497 * object.cc (make_elf_object): Correct test for 64-bit ELF file
1500 * readsyms.cc (Read_symbols::do_read_symbols): Use get_view rather
1501 than read for file header.
1502 * archive.cc (Archive::include_member): Likewise.
1506 * aclocal.m4: Regenerate.
1507 * configure: Regenerate.
1511 * version.cc (version_string): Bump to 1.6.
1513 * testsuite/Makefile.am (many_sections_r_test): New target.
1514 (many_sections_r_test_SOURCES): Remove.
1515 (many_sections_r_test_DEPENDENCIES): Remove.
1516 (many_sections_r_test_LDFLAGS): Remove.
1517 (many_sections_r_test_LDADD): Remove.
1519 * object.cc (Sized_relobj::do_add_symbols): Always pass
1520 local_symbol_count_ to add_from_relobj.
1522 * testsuite/Makefile.am (many_sections_check.h): Only check one in
1523 every thousand variables.
1524 * testsuite/Makefile.in: Rebuild.
1526 * object.cc (Xindex::initialize_symtab_xindex): New function.
1527 (Xindex::read_symtab_xindex): New function.
1528 (Xindex::sym_xindex_to_shndx): New function.
1529 (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if
1531 (Sized_relobj::do_initialize_xindex): New function.
1532 (Sized_relobj::do_read_symbols): Adjust section links.
1533 (Sized_relobj::symbol_section_and_value): Add is_ordinary
1534 parameter. Change all callers.
1535 (Sized_relobj::include_section_group): Adjust section links and
1536 symbol section indexes.
1537 (Sized_relobj::do_layout): Adjust section links.
1538 (Sized_relobj::do_count_local_symbols): Adjust section links and
1539 symbol section indexes.
1540 (Sized_relobj::do_finalize_local_symbols): Distinguish between
1541 ordinary and special symbols.
1542 (Sized_relobj::write_local_symbols): Add symtab_xindex and
1543 dynsym_xindex parameters. Change all callers. Adjust section
1544 links. Use SHN_XINDEX when needed.
1545 (Sized_relobj::get_symbol_location_info): Adjust section links.
1546 Don't get fooled by special symbols.
1547 * object.h (class Xindex): Define.
1548 (class Object): Add xindex_ parameter. Declare virtual functoin
1549 do_initialize_xindex.
1550 (Object::adjust_sym_shndx): New function.
1551 (Object::set_xindex): New protected function.
1552 (class Symbol_value): Add is_ordinary_shndx_ field.
1553 (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_.
1554 (Symbol_value::value): Assert ordinary section.
1555 (Symbol_value::initialize_input_to_output_map): Likewise.
1556 (Symbol_value::set_input_shndx): Add is_ordinary parameter.
1558 (Symbol_value::input_shndx): Add is_ordinary parameter. Change
1560 (class Sized_relobj): Update declarations.
1561 (Sized_relobj::local_symbol_input_shndx): Add is_ordinary
1562 parameter. Change all callers.
1563 (Sized_relobj::adjust_shndx): New function.
1564 * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_
1566 (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx
1567 parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section
1568 for SHT_DYNSYM section if available. Set dynsym_shndx_ field.
1569 (Sized_dynobj::read_dynsym_section): Adjust section links.
1570 (Sized_dynobj::read_dynamic): Likewise.
1571 (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust
1573 (Sized_dynobj::do_initialize_xindex): New function.
1574 * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare
1575 do_initialize_xindex.
1576 (Sized_dynobj::adjust_shndx): New function.
1577 * layout.cc (Layout::Layout): Initialize symtab_xindex_ and
1578 dynsym_xindex_ fields.
1579 (Layout::finalize): Add a call to set_section_indexes before
1580 creating the symtab sections.
1581 (Layout::set_section_indexes): Don't do anything if the section
1582 already has a section index.
1583 (Layout::create_symtab_sections): Add shnum parameter. Change
1584 caller. Create .symtab_shndx section if needed.
1585 (Layout::create_shdrs): Add shstrtab_section parameter. Change
1587 (Layout::allocated_output_section_count): New function.
1588 (Layout::create_dynamic_symtab): Create .dynsym_shndx section if
1590 * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_
1591 fields. Update declarations.
1592 (Layout::symtab_xindex): New function.
1593 (Layout::dynsym_xindex): New function.
1594 (class Write_symbols_task): Add layout_ field.
1595 (Write_symbols_task::Write_symbols_task): Add layout parameter.
1597 * output.cc (Output_section_headers::Output_section_headers): Add
1598 shstrtab_section parameter. Change all callers.
1599 (Output_section_headers::do_sized_write): Store overflow values
1600 for section count and section string table section index in
1601 section header zero.
1602 (Output_file_header::do_sized_write): Check for overflow of
1603 section count and section string table section index.
1604 (Output_symtab_xindex::do_write): New function.
1605 (Output_symtab_xindex::endian_do_write): New function.
1606 * output.h (class Output_section_headers): Add shstrtab_section_.
1607 Update declarations.
1608 (class Output_symtab_xindex): Define.
1609 (Output_section::has_out_shndx): New function.
1610 * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_
1612 (Symbol::init_base): Add st_shndx and is_ordinary parameters.
1614 (Sized_symbol::init): Likewise.
1615 (Symbol::output_section): Check for ordinary symbol.
1616 (Symbol_table::add_from_object): Remove orig_sym parameter. Add
1617 st_shndx, is_ordinary, and orig_st_shndx parameters. Change all
1619 (Symbol_table::add_from_relobj): Add symndx_offset parameter.
1620 Change all callers. Simplify handling of symbols from sections
1621 not included in the link.
1622 (Symbol_table::add_from_dynobj): Handle ordinary symbol
1624 (Weak_alias_sorter::operator()): Assert that symbols are
1626 (Symbol_table::sized_finalize_symbol): Handle ordinary symbol
1628 (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex
1629 parameters. Change all callers.
1630 (Symbol_table::sized_write_globals): Likewise. Handle ordinary
1631 symbol distinction. Use SHN_XINDEX when needed.
1632 (Symbol_table::write_section_symbol): Add symtab_xindex
1633 parameter. Change all callers.
1634 (Symbol_table::sized_write_section_symbol): Likewise. Use
1635 SHN_XINDEX when needed.
1636 * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update
1638 (Symbol::shndx): Add is_ordinary parameter. Change all callers.
1639 (Symbol::is_defined): Check is_ordinary.
1640 (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise.
1641 (Symbol::is_absolute, Symbol::is_common): Likewise.
1642 (class Sized_symbol): Update declarations.
1643 (class Symbol_table): Update declarations.
1644 * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary
1645 parameters. Change all callers.
1646 (Sized_symbol::override): Likewise.
1647 (Symbol_table::override): Likewise.
1648 (symbol_to_bits): Add is_ordinary parameter. Change all callers.
1649 (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx,
1650 is_ordinary, and orig_st_shndx parameters. Change all callers.
1651 * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol
1652 to be in an ordinary section.
1653 * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add
1654 object and is_ordinary parameters. Change all callers.
1655 (Sized_dwarf_line_info::read_relocs): Add object parameter.
1656 Change all callers. Don't add undefined or non-ordinary symbols
1658 (Sized_dwarf_line_info::read_line_mappings): Add object parameter.
1660 * dwarf_reader.h (class Sized_dwarf_line_info): Update
1662 * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol.
1663 * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links.
1664 (Sized_relobj::relocate_sections): Likewise.
1665 * target-reloc.h (scan_relocs): Adjust section symbol index.
1666 (scan_relocatable_relocs): Likewise.
1667 * i386.cc (Scan::local): Check for ordinary symbols.
1668 * sparc.cc (Scan::local): Likewise.
1669 * x86_64.cc (Scan::local): Likewise.
1670 * testsuite/binary_unittest.cc (Sized_binary_test): Update calls
1671 to symbol_section_and_value.
1672 * testsuite/many_sections_test.cc: New file.
1673 * testsuite/Makefile.am (BUILT_SOURCES): Define.
1674 (check_PROGRAMS): Add many_sections_test.
1675 (many_sections_test_SOURCES): Define.
1676 (many_sections_test_DEPENDENCIES): Define.
1677 (many_sections_test_LDFLAGS): Define.
1678 (BUILT_SOURCES): Add many_sections_define.h.
1679 (many_sections_define.h): New target.
1680 (BUILT_SOURCES): Add many_sections_check.h.
1681 (many_sections_check.h): New target.
1682 (check_PROGRAMS): Add many_sections_r_test.
1683 (many_sections_r_test_SOURCES): Define.
1684 (many_sections_r_test_DEPENDENCIES): Define.
1685 (many_sections_r_test_LDFLAGS): Define.
1686 (many_sections_r_test_LDADD): Define.
1687 (many_sections_r_test.o): New target.
1688 * testsuite/Makefile.in: Rebuild.
1692 * errors.cc (Errors::info): New function.
1693 (gold_info): New function.
1694 * errors.h (Errors::info): New function.
1695 * gold.h (gold_info): New function.
1696 * object.cc (Input_objects::add_object): Print trace output.
1697 * options.cc (options::parse_set): New function.
1698 (General_options::parse_wrap): Deleted.
1699 (General_options::General_options): Deleted initializer.
1700 * options.h (options::String_set): New typedef.
1701 (options::parse_set): New function.
1702 (DEFINE_set): New macro.
1703 (General_options::wrap): Changed to use DEFINE_set. Changed
1704 callers of any_wrap_symbols and is_wrap_symbol.
1705 (General_options::trace, General_options::trace_symbol):
1707 (General_options::any_wrap_symbols, General_options::is_wrap_symbol)
1708 (General_options::wrap_symbols_): Deleted.
1709 * symtab.cc (Symbol_table::add_from_object): Print trace output.
1713 * options.cc (General_options::parse_V): New function.
1714 * options.h: Add entries for -V and -Qy.
1718 * common.cc (Symbol_table::allocate_commons): Remove options
1719 parameter. Change caller.
1720 (Symbol_table::do_allocate_commons): Remove options parameter.
1721 Change caller. Just call do_allocate_commons_list twice.
1722 (Symbol_table::do_allocate_commons_list): New function, broken out
1723 of do_allocate_commons.
1724 * common.h (class Allocate_commons_task): Remove options_ field.
1726 * symtab.cc (Symbol_table::Symbol_table): Initialize
1728 (Symbol_table::add_from_object): Put TLS common symbols on
1730 (Symbol_table::sized_finalize_symbol): Handle STT_TLS symbols
1731 which are IN_OUTPUT_DATA.
1732 * symtab.h (class Symbol_table): Add tls_commons_ field. Update
1733 allocate_commons and do_allocate_commons declarations. Declare
1734 do_allocate_commons_list.
1735 * gold.cc (queue_middle_tasks): Update creation of
1736 Allocate_commons_task to not pass options.
1737 * testsuite/Makefile.am (INCLUDES): Add -I.. .
1738 (TLS_TEST_C_FLAGS): New variable.
1739 (tls_test_c_pic.o): New target.
1740 (tls_test_shared.so): Link in tls_test_c_pic.o.
1741 (tls_test_c_pic_ie.o): New target.
1742 (tls_test_ie_shared.so): Link in tls_test_c_pic_ie.o.
1743 (tls_test_DEPENDENCIES, tls_test_LDADD): Add tls_test_c.o.
1744 (tls_test_c.o): New target.
1745 (tls_pic_test_DEPENDENCIES): Add tls_test_c_pic.o.
1746 (tls_pic_test_LDADD): Likewise.
1747 (tls_shared_gd_to_ie_test_DEPENDENCIES): Add tls_test_c_pic.o.
1748 (tls_shared_gd_to_ie_test_LDADD): Likewise.
1749 (tls_test_c_gnu2.o): New target.
1750 (tls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): Add
1752 (tls_shared_gnu2_gd_to_ie_test_LDADD): Likewise.
1753 (tls_test_gnu2_shared.so): Link in tls_test_c_gnu2.o.
1754 (tls_test_shared_nonpic.so): Link in tls_test_c.o.
1755 * testsuite/tls_test.cc: Include "config.h".
1756 (t_last): Call t11_last.
1757 * testsuite/tls_test.h (t11, t11_last): Declare.
1758 * testsuite/tls_test_c.c: New file.
1759 * testsuite/tls_test_main.cc (thread_routine): Call t11.
1760 * configure.ac: Check for OpenMP support.
1761 * configure, config.in, Makefile.in: Rebuild.
1762 * testsuite/Makefile.in: Rebuild.
1766 * i386.cc (Target_i386::define_tls_base_symbol): New function.
1767 (Target_i386::tls_base_symbol_defined_): New field.
1768 (Target_i386::Scan::local): Define _TLS_MODULE_BASE_ symbol.
1769 (Target_i386::Scan::global): Likewise.
1770 * symtab.cc (sized_finalize_symbol): Add check for TLS symbol.
1771 * x86_64.cc (Target_x86_64::define_tls_base_symbol): New function.
1772 (Target_x86_64::tls_base_symbol_defined_): New field.
1773 (Target_x86_64::Scan::local): Define _TLS_MODULE_BASE_ symbol.
1774 (Target_x86_64::Scan::global): Likewise.
1778 * symtab.h (Symbol::is_strong_undefined): Removed unused function.
1779 (Symbol::needs_plt_entry): Allow weak undefined symbols.
1780 (Symbol::needs_dynamic_reloc): Allow weak undefined symbols when
1781 building shared libraries.
1782 * testsuite/Makefile.am (weak_undef_nonpic_test): New target.
1783 (weak_undef_file1_nonpic.o, weak_undef_file2_nonpic.o)
1784 (weak_undef_lib_nonpic.so, alt/weak_undef_lib_nonpic.so): New targets.
1785 * testsuite/Makefile.in: Rebuild.
1786 * testsuite/weak_undef.h: New file.
1787 * testsuite/weak_undef_file1.cc: Add extra test cases.
1788 * testsuite/weak_undef_file2.cc: Likewise.
1789 * testsuite/weak_undef_test.cc: Likewise.
1793 * sparc.cc (Target_sparc::Scan): Change from struct to class.
1794 Add issued_non_pic_error_ field. Declare check_non_pic.
1795 (Target_sparc::Scan::check_non_pic): New function.
1796 (Target_sparc::Scan::local): Call check_non_pic as appropriate.
1797 (Target_sparc::Scan::global): Likewise.
1799 * configure.ac (FN_PTRS_IN_SO_WITHOUT_PIC): Add sparc64.
1800 * configure: Rebuild.
1802 * options.h (DEFINE_enable): New macro.
1803 (new_dtags): New enable option.
1804 (initfirst, interpose, loadfltr, nodefaultlib,
1805 nodelete, nodlopen, nodump): New -z options.
1806 * layout.cc (Layout:finish_dynamic_section): If new
1807 dtags enabled, emit DT_RUNPATH. Also, emit a
1808 DT_FLAGS_1 containing any specified -z flags.
1812 * copy-relocs.cc: New file.
1813 * copy-relocs.h: New file.
1814 * reloc.cc: Remove Copy_relocs code.
1815 * reloc.h: Likewise.
1816 * reloc-types.h (struct Reloc_types) [both versions]: Add
1817 get_reloc_addend_noerror.
1818 * output.h (class Output_data_reloc<elfcpp::SHT_REL>): Add
1819 variants of add_global which take an addend which must be zero.
1820 * i386.cc: Include "copy-relocs.h".
1821 (class Target_i386): Change type of copy_relocs_ to variable,
1823 (Target_i386::copy_reloc): Rewrite to pass to Copy_relocs class.
1825 (Target_i386::do_finalize_sections): Change handling of
1827 * sparc.cc: Include "copy-relocs.h".
1828 (class Target_sparc): Change type of copy_relocs_ to variable,
1830 (Target_sparc::copy_reloc): Rewrite to pass to Copy_relocs class.
1832 (Target_sparc::do_finalize_sections): Change handling of
1834 * x86_64.cc: Include "copy-relocs.h".
1835 (class Target_x86_64): Change type of copy_relocs_ to variable,
1837 (Target_x86_64::copy_reloc): Rewrite to pass to Copy_relocs
1838 class. Change all callers.
1839 (Target_x86_64::do_finalize_sections): Change handling of
1841 * Makefile.am (CCFILES): Add copy-relocs.cc.
1842 (HFILES): Add copy-relocs.h.
1844 * Makefile.in, aclocal.m4, testsuite/Makefile.in: Rebuild.
1846 * testsuite/script_test_4.sh: Permit leading zeroes.
1850 * script-sections.cc (Script_sections::create_segments): Use
1851 header_size_adjustment even when there is enough room for the
1853 * testsuite/script_test_4.sh: New file.
1854 * testsuite/script_test_4.t: New file.
1855 * testsuite/Makefile.am (check_SCRIPTS): Add script_test_4.sh.
1856 (check_DATA): Add script_test_4.stdout.
1857 (MOSTLYCLEANFILES): Likewise.
1858 (script_test_4): New target.
1859 (script_test_4.stdout): New target.
1860 * testsuite/Makefile.in: Rebuild.
1862 * sparc.cc: Add definitions for Output_data_plt_sparc class
1867 * sparc.cc: New file.
1868 * Makefile.am (TARGETSOURCES): Add sparc.cc
1869 (ALL_TARGETOBJS): Add sparc.$(OBJEXT)
1870 * configure.tgt: Document targ_extra_size and
1871 targ_extra_big_endian. Add entries for sparc-* and
1873 * configure.ac: Handle targ_extra_size and
1874 targ_extra_big_endian.
1875 * Makefile.in: Rebuild.
1876 * configure: Likewise.
1877 * po/POTFILES.in: Likewise.
1878 * po/gold.pot: Likewise.
1882 * layout.cc (Layout::Layout): Initialize sections_are_attached_.
1883 (Layout::get_output_section): Ignore SHF_WRITE and SHF_EXECINSTR
1884 in the name/type/flags to section mapping. Don't call
1885 allocate_output_section.
1886 (Layout::choose_output_section): Change parameter from adjust_name
1887 to is_input_section. Don't permit input sections after sections
1888 are attached to segments. Don't call allocate_output_section.
1889 (Layout::layout_eh_frame): Call update_flags_for_input_section,
1890 not write_enable_output_section.
1891 (Layout::make_output_section): Don't push to
1892 unattached_section_list_ nor call attach_to_segment. Call
1893 attach_section_to_segment if sections are attached.
1894 (Layout::attach_sections_to_segments): New function.
1895 (Layout::attach_section_to_segment): New function.
1896 (Layout::attach_allocated_section_to_segment): Rename from
1897 attach_to_segment. Remove flags parameter.
1898 (Layout::allocate_output_section): Remove function.
1899 (Layout::write_enable_output_section): Remove function.
1900 * layout.h (class Layout): Update for above changes. Add new
1901 field sections_are_attached_.
1902 * output.h (Output_section::update_flags_for_input_section): New
1904 * output.cc (Output_section::add_input_section): Call
1905 update_flags_for_input_section.
1906 * gold.cc (queue_middle_tasks): Call attach_sections_to_segments.
1910 * i386.cc (Target_i386::got_mod_index_entry): Restore code previously
1911 thought unnecessary.
1912 * x86_64.cc (Target_x86_64::got_mod_index_entry): Likewise.
1916 * output.h (class Output_section_data): Remove inline definition
1918 * output.cc (Output_section_data::set_addralign): New function.
1922 Add support for TLS descriptors for i386 and x86_64.
1923 * i386.cc (Target_i386::Relocate::tls_desc_gd_to_ie): New function.
1924 (Target_i386::Relocate::tls_desc_gd_to_le): New function.
1925 (Target_i386::Got_type): Add GOT_TYPE_TLS_NOFFSET and
1927 (Target_i386::got_mod_index_entry): Remove unnecessary code.
1928 (Target_i386::Scan::local): Implement R_386_TLS_GOTDESC and
1929 R_386_TLS_DESC_CALL relocations. Fix problem with initial-exec
1931 (Target_i386::Scan::global): Fix problem with GD-to-IE relaxation.
1932 Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations;
1933 Fix problem with initial-exec relocations.
1934 (Target_i386::Relocate::relocate_tls): Likewise.
1935 (Target_i386::Relocate::tls_gd_to_ie): Fix problem with GD-to-IE
1937 * output.cc (Output_data_dynamic::Dynamic_entry::write): Add
1938 support for section-plus-offset dynamic table entries.
1939 * output.h (Output_data_dynamic::add_section_plus_offset): New function.
1940 (Output_data_dynamic::Dynamic_entry): Add support for
1941 section-plus-offset dynamic table entries.
1942 (Output_data_dynamic::Classification): Likewise.
1943 (Output_data_dynamic::classification_): Renamed offset_.
1944 * x86_64.cc (Target_x86_64::Relocate::tls_desc_gd_to_ie): New function.
1945 (Target_x86_64::Relocate::tls_desc_gd_to_le): New function.
1946 (Target_x86_64::make_plt_section): New function.
1947 (Target_x86_64::reserve_tlsdesc_entries): New function.
1948 (Output_data_plt_x86_64::Output_data_plt_x86_64): Add new parameter.
1949 (Output_data_plt_x86_64::reserve_tlsdesc_entry): New function.
1950 (Output_data_plt_x86_64::has_tlsdesc_entry): New function.
1951 (Output_data_plt_x86_64::get_tlsdesc_got_offset): New function.
1952 (Output_data_plt_x86_64::get_tlsdesc_plt_offset): New function.
1953 (Output_data_plt_x86_64::tlsdesc_plt_entry): New field.
1954 (Output_data_plt_x86_64::set_final_data_size): Move out of line;
1955 add extra PLT entry for TLS descriptors.
1956 (Output_data_plt_x86_64::got_): New field.
1957 (Output_data_plt_x86_64::tlsdesc_got_offset_): New field.
1958 (Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize new
1960 (Output_data_plt_x86_64::do_write): Write extra PLT entry for TLS
1962 (Target_x86_64::make_plt_entry): Factor out make_plt_section.
1963 (Target_x86_64::got_mod_index_entry): Remove unnecessary code.
1964 (Target_x86_64::Scan::local): Implement R_386_TLS_GOTDESC and
1965 R_386_TLS_DESC_CALL relocations.
1966 (Target_x86_64::Scan::global): Likewise.
1967 (Target_x86_64::do_finalize_sections): Add dynamic table entries
1968 for TLS descriptors.
1969 (Relocate::relocate_tls): Fix problem with GD-to-IE relaxation.
1970 Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations.
1971 (Target_x86_64::Relocate::tls_gd_to_ie): Fix problem with
1972 GD-to-IE relaxation.
1973 * configure.ac: Export new conditional variables TLS_GNU2_DIALECT
1974 and TLS_DESCRIPTORS.
1975 * Makefile.in: Rebuild.
1976 * configure: Rebuild.
1977 * testsuite/Makefile.am (tls_shared_gd_to_ie_test): New target.
1978 (tls_test_shared2.so): New target.
1979 (tls_shared_gd_to_ie_test_SOURCES): New variable.
1980 (tls_shared_gd_to_ie_test_DEPENDENCIES): New variable.
1981 (tls_shared_gd_to_ie_test_LDFLAGS): New variable.
1982 (tls_shared_gd_to_ie_test_LDADD): New variable.
1983 (tls_shared_gnu2_gd_to_ie_test): New target.
1984 (tls_test_gnu2.o, tls_test_file2_gnu2.o, tls_test_gnu2_shared2.so):
1986 (tls_shared_gnu2_gd_to_ie_test_SOURCES): New variable.
1987 (ls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): New variable.
1988 (tls_shared_gnu2_gd_to_ie_test_LDFLAGS): New variable.
1989 (tls_shared_gnu2_gd_to_ie_test_LDADD): New variable.
1990 (tls_shared_gnu2_test): New target.
1991 (tls_test_gnu2_shared.so): New target.
1992 (tls_shared_gnu2_test_SOURCES): New variable.
1993 (tls_shared_gnu2_test_DEPENDENCIES): New variable.
1994 (tls_shared_gnu2_test_LDFLAGS): New variable.
1995 (tls_shared_gnu2_test_LDADD): New variable.
1996 * testsuite/Makefile.in: Rebuild.
1997 * testsuite/Makefile.
2001 * testsuite/Makefile.am (justsyms_2r.o): Add dependency on
2003 * testsuite/Makefile.in: Rebuild.
2005 * testsuite/script_test_2a.cc (script_test_string_a): Make 8 bytes
2007 * testsuite/script_test_2.cc (main): Adjust test.
2012 * options.h (General_options): Add entries for '-Y' and
2014 * options.cc (General_options:finalize): If -Y was used, add those
2015 entries to the library path instead of the default "/lib" and
2020 * testsuite/justsyms.t: Start at 0x100.
2021 * testsuite/justsyms_1.cc: Adjust justsyms_string assertion.
2022 * testsuite/script_test_2b.cc (script_test_string_b): Make 8 bytes
2024 * testsuite/script_test_2.cc: Adjust string and section length
2030 * script-sections.cc (Sections_element::allocate_to_segment): Add
2032 (Output_section_definition::allocate_to_segment): Likewise.
2033 (Orphan_output_section::allocate_to_segment): Likewise.
2034 (Script_sections::attach_sections_using_phdrs_clause): Don't
2035 propagate non-PT_LOAD segments to orphan sections.
2036 * testsuite/Makefile.am (script_test_3.stdout): Generate using
2037 readelf rather than objdump.
2038 * testsuite/script_test_3.sh: Adjust accordingly. Test that
2039 .interp section and PT_INTERP segment are the same size.
2040 * testsuite/Makefile.in: Rebuild.
2042 * symtab.cc (Symbol_table::add_from_dynobj): Only look for weak
2043 aliases for symbols defined in the same object.
2044 * testsuite/Makefile.am (check_PROGRAMS): Add weak_alias_test.
2045 (weak_alias_test_SOURCES): New variable.
2046 (weak_alias_test_DEPENDENCIES): New variable.
2047 (weak_alias_test_LDFLAGS): New variable.
2048 (weak_alias_test_LDADD): New variable.
2049 (weak_alias_test_1_pic.o, weak_alias_test_1.so): New targets.
2050 (weak_alias_test_2_pic.o, weak_alias_test_2.so): New targets.
2051 (weak_alias_test_3.o): New target.
2052 (weak_alias_test_4_pic.o, weak_alias_test_4.so): New targets.
2053 * testsuite/weak_alias_test_main.cc: New file.
2054 * testsuite/weak_alias_test_1.cc: New file.
2055 * testsuite/weak_alias_test_2.cc: New file.
2056 * testsuite/weak_alias_test_3.cc: New file.
2060 * options.h (class General_options): Add --noinhibit-exec option.
2061 * main.cc (main): Check --noinhibit-exec.
2063 * options.h (class General_options): Define --wrap as a special
2064 option. Add wrap_symbols_ field.
2065 (General_options::any_wrap_symbols): New function.
2066 (General_options::is_wrap_symbol): New function.
2067 * options.cc (General_options::parse_wrap): New function.
2068 (General_options::General_options): Initialize wrap_symbols_.
2069 * symtab.cc (Symbol_table::wrap_symbol): New function.
2070 (Symbol_table::add_from_object): Handle --wrap.
2071 * symtab.h (class Symbol_table): Declare wrap_symbol.
2072 * target.h (Target::wrap_char): New function.
2073 (Target::Target_info): Add wrap_char field.
2074 * i386.cc (Target_i386::i386_info): Initialize wrap_char.
2075 * x86_64.cc (Target_x86_64::x86_64_info): Likewise.
2076 * testsuite/testfile.cc (Target_test::test_target_info):
2079 * errors.cc (Errors::undefined_symbol): Mention symbol version if
2082 * layout.h (class Layout): Add added_eh_frame_data_ field.
2083 * layout.cc (Layout::Layout): Initialize new field.
2084 (Layout::layout_eh_frame): Don't add eh_frame_data_ to .eh_frame
2085 output section until we find a section we merged successfully.
2086 * object.cc (Sized_relobj::check_eh_frame_flags): Don't require
2087 that the size be non-zero.
2089 * merge.cc (Object_merge_map::get_output_offset): Remove inline
2094 * configure.ac: Export new conditional variable HAVE_ZLIB.
2095 * testsuite/Makefile.am (flagstest_o_specialfile): Condition
2097 (flagstest_o_specialfile_and_compress_debug_sections): Likewise.
2098 * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
2102 * version.cc (version_string): Set to "1.5".
2104 * x86_64.cc (Target_x86_64::Scan): Change from struct to class.
2105 Add issued_non_pic_error_ field. Declare check_non_pic.
2106 (Target_x86_64::Scan::check_non_pic): New function.
2107 (Target_x86_64::Scan::local): Call check_non_pic as appropriate.
2108 (Target_x86_64::Scan::global): Likewise.
2110 * output.cc (Output_reloc<SHT_REL>::local_section_offset): Add
2111 addend parameter. Change caller. Handle merge sections.
2112 (Output_reloc<SHT_REL>::symbol_value): Change parameter type from
2113 Address to Addend. Don't add in the result of
2114 local_section_offset, pass down the addend and use the returned
2116 * output.h (class Output_reloc<SHT_REL>): Add Addend typedef.
2117 Update declarations of local_section_offset and symbol_value.
2118 * testsuite/two_file_test_1.cc (t18): New function.
2119 * testsuite/two_file_test_2.cc (f18): New function.
2120 * testsuite/two_file_test_main.cc (main): Call t18.
2121 * testsuite/two_file_test.h (t18, f18): Declare.
2123 * configure.ac: Don't test for objdump, c++filt, or readelf.
2124 * testsuite/Makefile.am: Remove READELF and OBJDUMP_AND_CPPFILT
2126 (TEST_READELF): New variable.
2127 (TEST_OBJDUMP, TEST_CXXFILT, TEST_STRIP): New variables.
2128 (check_PROGRAMS): Add two_file_strip_test.
2129 (two_file_strip_test): New target.
2130 (check_PROGRAMS): Add two_file_same_shared_strip_test.
2131 (two_file_same_shared_strip_test_SOURCES): New variable.
2132 (two_file_same_shared_strip_test_DEPENDENCIES): New variable.
2133 (two_file_same_shared_strip_test_LDFLAGS): New variable.
2134 (two_file_same_shared_strip_test_LDADD): New variable.
2135 (two_file_shared_strip.so): New target.
2136 (ver_test_2.syms, ver_test_4.syms): Use TEST_READELF.
2137 (ver_test_5.syms, ver_test_7.syms): Likewise.
2138 (ver_matching_test.stdout): Use TEST_OBJDUMP and TEST_CXXFILT.
2139 (strip_test_3.stdout): Use TEST_OBJDUMP.
2140 * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
2144 * symtab.h (Symbol::is_weak_undefined): New function.
2145 (Symbol::is_strong_undefined): New function.
2146 (Symbol::is_absolute): New function.
2147 (Symbol::needs_plt_entry): Exclude weak undefined symbols.
2148 (Symbol::needs_dynamic_reloc): Exclude weak undefined and
2150 * testsuite/Makefile.am (check_PROGRAMS): Add weak_undef_test.
2151 (weak_undef_test): New target.
2152 * testsuite/Makefile.in: Rebuild.
2153 * testsuite/weak_undef_file1.cc: New file.
2154 * testsuite/weak_undef_file2.cc: New file.
2155 * testsuite/weak_undef_test.cc: New file.
2159 * compressed_output.h (class Output_compressed_section): Use
2161 * compressed_output.cc (zlib_compress): Use unsigned buffers,
2163 (zlib_compressed_suffix): Removed.
2164 (Output_compressed_section::set_final_data_size): Use unsigned
2166 * testsuite/Makefile.am (flagstest_compress_debug_sections):
2167 Fix linker invocation.
2168 (flagstest_o_specialfile_and_compress_debug_sections):
2170 * testsuite/Makefile.in: Regenerated.
2174 * dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog,
2175 Sized_dwarf_line_info::process_one_opcode): Use Swap_unaligned.
2183 * fileread.cc (File_read::find_view): Add byteshift and vshifted
2184 parameters. Update for new key type to views_. Change all
2186 (File_read::read): Adjust for byteshift in returned view.
2187 (File_read::add_view): New function, broken out of
2189 (File_read::make_view): New function, broken out of
2191 (File_read::find_or_make_view): Add offset and aligned
2192 parameters. Rewrite accordingly. Change all callers.
2193 (File_read::get_view): Add offset and aligned parameters. Adjust
2194 for byteshift in return value.
2195 (File_read::get_lasting_view): Likewise.
2196 * fileread.h (class File_read): Update declarations.
2197 (class File_read::View): Add byteshift_ field. Add byteshift to
2198 constructor. Add byteshift method.
2199 * archive.h (Archive::clear_uncached_views): New function.
2200 (Archive::get_view): Add aligned parameter. Change all callers.
2201 * object.h (Object::get_view): Add aligned parameter. Change all
2203 (Object::get_lasting_view): Likewise.
2205 * fileread.cc (File_read::release): Don't call clear_views if
2206 there are multiple objects.
2207 * fileread.h (File_read::clear_uncached_views): New function.
2208 * archive.cc (Add_archive_symbols::run): Call clear_uncached_views
2213 Add thin archive support.
2214 * archive.cc (Archive::armagt): New const.
2215 (Archive::setup): Remove task parameter and calls to unlock.
2216 (Archive::unlock_nested_archives): New function.
2217 (Archive::read_header): Add nested_off parameter. Change
2219 (Archive::interpret_header): Likewise.
2220 (Archive::include_all_members): Change to handle thin
2222 (Archive::include_member): Likewise.
2223 * archive.h (Archive::Archive): Add new parameters and
2225 (Archive::armagt): New const.
2226 (Archive::setup): Remove task parameter.
2227 (Archive::unlock_nested_archives): New function.
2228 (Archive::read_header): Add nested_off parameter.
2229 (Archive::interpret_header): Likewise.
2230 (Archive::Nested_archive_table): New typedef.
2231 (Archive::is_thin_archive_): New field.
2232 (Archive::nested_archives_): New field.
2233 (Archive::options_): New field.
2234 (Archive::dirpath_): New field.
2235 (Archive::task_): New field.
2236 * readsyms.cc (Read_symbols::do_read_symbols): Add check
2237 for thin archives. Pass additional parameters to
2238 Archive::Archive. Unlock the archive file after calling
2243 * symtab.cc (Symbol_table::do_define_as_constant): Don't force a
2244 version symbol to be local.
2245 * testsuite/ver_test_4.sh: New file.
2246 * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_4.sh.
2247 (check_DATA): Add ver_test_4.syms.
2248 (ver_test_4.syms): New target.
2249 * testsuite/Makefile.in: Rebuild.
2252 (Output_section::Input_section_sort_entry::has_priority): New
2254 (Output_section::Input_section_sort_entry::match_file_name): New
2256 (Output_section::Input_section_sort_entry::match_section_name):
2258 (Output_section::Input_section_sort_entry::match_section_name_prefix):
2260 (Output_section::Input_section_sort_entry::match_section_file):
2262 (Output_section::Input_section_sort_compare::operator()): Rewrite
2263 using new Input_section_sort_entry functions. Sort crtbegin and
2264 crtend first. Sort sections with no priority before sections with
2266 * testsuite/initpri1.c (d3): Check j != 4.
2267 (cd5): New constructor/destructor function.
2268 (main): Check j != 2.
2270 * symtab.cc (Symbol_table::add_from_object): If we don't use the
2271 new symbol when resolving, don't call set_is_default.
2272 * testsuite/ver_test_7.cc: New file.
2273 * testsuite/ver_test_7.sh: New file.
2274 * testsuite/Makefile.am (ver_test_7.so): New target.
2275 (ver_test_7.o): New target.
2276 (check_SCRIPTS): Add ver_test_7.sh.
2277 (check_DATA): Add ver_test_7.syms.
2278 (ver_test_7.syms): New target.
2282 * layout.cc (Layout::layout): If we see an input section with a
2283 name that needs sorting, set the must_sort flag for the output
2285 (Layout::make_output_section): If the name of the output section
2286 indicates that it might require sorting, set the may_sort flag.
2287 * output.h (Output_section::may_sort_attached_input_sections): New
2289 (Output_section::set_may_sort_attached_input_sections): New
2291 (Output_section::must_sort_attached_input_sections): New
2293 (Output_section::set_must_sort_attached_input_sections): New
2295 (class Output_section): Declare Input_section_sort_entry. Define
2296 Input_section_sort_compare. Declare
2297 sort_attached_input_sections. Add new fields:
2298 may_sort_attached_input_sections_,
2299 must_sort_attached_input_sections_,
2300 attached_input_sections_are_sorted_.
2301 * output.cc (Output_section::Output_section): Initialize new
2303 (Output_section::add_input_section): Add an entry to
2304 input_sections_ if may_sort or must_sort are true.
2305 (Output_section::set_final_data_size): Call
2306 sort_attached_input_sections if necessary.
2307 (Output_section::Input_section_sort_entry): Define new class.
2308 (Output_section::Input_section_sort_compare::operator()): New
2310 (Output_section::sort_attached_input_sections): New function.
2311 * configure.ac: Check whether the compiler supports constructor
2312 priorities. Define a CONSTRUCTOR_PRIORITY automake conditional.
2313 * testsuite/initpri1.c: New file.
2314 * testsuite/Makefile.am (check_PROGRAMS): Add initpri1 if
2315 CONSTRUCTOR_PRIORITY.
2316 (initpri1_SOURCES, initpri1_DEPENDENCIES): New variables.
2317 (initpri1_LDFLAGS): New variable.
2318 * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
2322 * common.cc (Sort_commons::operator): Correct sorting algorithm.
2323 * testsuite/common_test_1.c: New file.
2324 * testsuite/Makefile.am (check_PROGRAMS): Add common_test_1.
2325 (common_test_1_SOURCES): New variable.
2326 (common_test_1_DEPENDENCIES): New variable.
2327 (common_test_1_LDFLAGS): New variable.
2329 * symtab.cc (Symbol_table::add_from_object): Handle saw_undefined_
2330 and commons_ correctly when NAME/VERSION does not override
2332 * testsuite/ver_test_6.c: New file.
2333 * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_6
2334 (ver_test_6_SOURCES, ver_test_6_DEPENDENCIES): New variables.
2335 (ver_test_6_LDFLAGS, ver_test_6_LDADD): New variables.
2339 * symtab.cc (Symbol_table::add_from_relobj): Don't set the version
2340 of an undefined symbol from a version script.
2341 * testsuite/Makefile.am (ver_test_5.so): New target.
2342 (ver_test_5.o): New target.
2343 (check_SCRIPTS): Add ver_test_5.sh.
2344 (check_DATA): Add ver_test_5.syms.
2345 (ver_test_5.syms): New target.
2346 * testsuite/ver_test_5.cc: New file.
2347 * testsuite/ver_test_5.script: New file.
2348 * testsuite/ver_test_5.sh: New file.
2349 * Makefile.in, testsuite/Makefile.in: Rebuild.
2352 Fix problems building gold with gcc 4.3.0.
2353 * gold.h (TEMPLATE_ATTRIBUTE_PRINTF_4): Define.
2354 (gold_error_at_location, gold_warning_at_location): Use it.
2355 * configure.ac: Check whether we can compile and use a template
2356 function with a printf attribute.
2357 * x86_64.cc (Target_x86_64::do_code_fill): Swap out a 32-bit value
2358 when jumping over bytes.
2359 * object.cc: Instantiate Object::read_section_data.
2360 * debug.h: Include <cstring>
2361 * dwarf_reader.cc: Include <algorithm>
2362 * main.cc: Include <cstring>.
2363 * options.cc: Include <cstring>.
2364 * output.cc: Include <cstring>.
2365 * script.cc: Include <cstring>.
2366 * script.h: Include <string>.
2367 * symtab.cc: Include <cstring> and <algorithm>.
2368 * target-select.cc: Include <cstring>.
2369 * version.cc: Include <string>.
2370 * testsuite/testmain.cc: Include <cstdlib>.
2371 * configure, config.in: Rebuild.
2375 * options.cc: Include "../bfd/bfdver.h".
2376 (options::help): Print bug reporting address.
2378 * version.cc (print_version): Adjust output for current value of
2383 * options.cc (options::help): Print list of supported targets.
2384 * target-select.h: Include <vector>.
2385 (class Target_selector): Make machine_, size_, and is_big_endian_
2386 fields const. Add bfd_name_ and instantiated_target_ fields.
2387 (Target_selector::Target_selector): Add bfd_name parameter.
2388 (Target_selector::recognize): Make non-virtual, call
2390 (Target_selector::recognize_by_name): Make non-virtual, call
2391 do_recognize_by_name.
2392 (Target_selector::supported_names): New function.
2393 (Target_selector::bfd_name): New function.
2394 (Target_selector::do_instantiate_target): New pure virtual
2396 (Target_selector::do_recognize): New virtual function.
2397 (Target_selector::do_recognize_by_name): New virtual function.
2398 (Target_selector::instantiate_target): New private function.
2399 (supported_target_names): Declare.
2400 * target-select.cc (Target_selector::Target_selector): Update for
2401 new parameter and fields.
2402 (select_target_by_name): Check that the name matches before
2403 calling recognize_by_name.
2404 (supported_target_names): New function.
2405 * i386.cc (class Target_selector_i386): Update Target_selector
2406 constructor call. Remove recognize and recognize_by_name. Add
2407 do_instantiate_target.
2408 * x86_64.cc (class Target_selector_x86_64): Likewise.
2409 * testsuite/testfile.cc (class Target_selector_test): Update for
2410 changes to Target_selector.
2412 * README: Rewrite, with some notes on unsupported features.
2416 * i386.cc (Target_i386::Got_type): New enum declaration.
2417 (Target_i386::Scan::local): Updated callers of Output_data_got
2419 (Target_i386::Scan::global): Likewise.
2420 (Target_i386::Relocate::relocate): Likewise.
2421 (Target_i386::Relocate::relocate_tls): Likewise.
2422 * object.h (Got_offset_list): New class.
2423 (Sized_relobj::local_has_got_offset): Added got_type parameter.
2424 (Sized_relobj::local_got_offset): Likewise.
2425 (Sized_relobj::set_local_got_offset): Likewise.
2426 (Sized_relobj::local_has_tls_got_offset): Removed.
2427 (Sized_relobj::local_tls_got_offset): Removed.
2428 (Sized_relobj::set_local_tls_got_offset): Removed.
2429 (Sized_relobj::Local_got_offsets): Changed to store a list of offsets.
2430 * output.cc (Output_data_got::add_global): Added got_type parameter.
2431 (Output_data_got::add_global_with_rel): Likewise.
2432 (Output_data_got::add_global_with_rela): Likewise.
2433 (Output_data_got::add_global_pair_with_rel): New function.
2434 (Output_data_got::add_global_pair_with_rela): New function.
2435 (Output_data_got::add_local): Added got_type parameter.
2436 (Output_data_got::add_local_with_rel): Likewise.
2437 (Output_data_got::add_local_with_rela): Likewise.
2438 (Output_data_got::add_local_pair_with_rel): New function.
2439 (Output_data_got::add_local_pair_with_rela): New function.
2440 (Output_data_got::add_global_tls): Removed.
2441 (Output_data_got::add_global_tls_with_rel): Removed.
2442 (Output_data_got::add_global_tls_with_rela): Removed.
2443 (Output_data_got::add_local_tls): Removed.
2444 (Output_data_got::add_local_tls_with_rel): Removed.
2445 (Output_data_got::add_local_tls_with_rela): Removed.
2446 * output.h (Output_data_got::add_global): Added got_type parameter.
2447 (Output_data_got::add_global_with_rel): Likewise.
2448 (Output_data_got::add_global_with_rela): Likewise.
2449 (Output_data_got::add_global_pair_with_rel): New function.
2450 (Output_data_got::add_global_pair_with_rela): New function.
2451 (Output_data_got::add_local): Added got_type parameter.
2452 (Output_data_got::add_local_with_rel): Likewise.
2453 (Output_data_got::add_local_with_rela): Likewise.
2454 (Output_data_got::add_local_pair_with_rel): New function.
2455 (Output_data_got::add_local_pair_with_rela): New function.
2456 (Output_data_got::add_global_tls): Removed.
2457 (Output_data_got::add_global_tls_with_rel): Removed.
2458 (Output_data_got::add_global_tls_with_rela): Removed.
2459 (Output_data_got::add_local_tls): Removed.
2460 (Output_data_got::add_local_tls_with_rel): Removed.
2461 (Output_data_got::add_local_tls_with_rela): Removed.
2462 * resolve.cc (Symbol::override_base_with_special): Removed
2463 reference to has_got_offset_ field.
2464 * symtab.cc (Symbol::init_fields): Replaced initialization
2465 of got_offset_ with got_offsets_. Removed initialization
2467 * symtab.h (Symbol::has_got_offset): Aded got_type parameter.
2468 (Symbol::got_offset): Likewise.
2469 (Symbol::set_got_offset): Likewise.
2470 (Symbol::has_tls_got_offset): Removed.
2471 (Symbol::tls_got_offset): Removed.
2472 (Symbol::set_tls_got_offset): Removed.
2473 (Symbol::got_offset_): Removed.
2474 (Symbol::tls_mod_got_offset_): Removed.
2475 (Symbol::tls_pair_got_offset_): Removed.
2476 (Symbol::got_offsets_): New field.
2477 (Symbol::has_got_offset): Removed.
2478 (Symbol::has_tls_mod_got_offset): Removed.
2479 (Symbol::has_tls_pair_got_offset): Removed.
2480 * x86_64.cc (Target_x86_64::Got_type): New enum declaration.
2481 (Target_x86_64::Scan::local): Updated callers of Output_data_got
2483 (Target_x86_64::Scan::global): Likewise.
2484 (Target_x86_64::Relocate::relocate): Likewise.
2485 (Target_x86_64::Relocate::relocate_tls): Likewise.
2489 * yyscript.y: Fix spelling error in comment.
2493 * options.h (class General_options): Define build_id option.
2494 * layout.h (class Layout): Declare write_build_id, create_note,
2495 create_build_id. Add build_id_note_ member.
2496 * layout.cc: Include <cerrno>, <fcntl.h>, <unistd.h>,
2497 "libiberty.h", "md5.h", "sha1.h".
2498 (Layout::Layout): Initialize eh_frame_data_,
2499 eh_frame_hdr_section_, and build_id_note_.
2500 (Layout::finalize): Call create_build_id.
2501 (Layout::create_note): New function, broken out of
2502 Layout::create_gold_note.
2503 (Layout::create_gold_note): Call create_note.
2504 (Layout::create_build_id): New function.
2505 (Layout::write_build_id): New function.
2506 (Close_task_runner::run): Call write_build_id.
2508 * x86_64.cc: Correct license to GPLv3.
2512 * options.cc: Include "demangle.h".
2513 (parse_optional_string): New function.
2514 (parse_long_option): Handle takes_optional_argument.
2515 (parse_short_option): Update dash_z initializer. Handle
2516 takes_optional_argument.
2517 (General_options::General_options): Initialize do_demangle_.
2518 (General_options::finalize): Set do_demangle_. Handle demangling
2520 * options.h (parse_optional_string): Declare.
2521 (struct One_option): Add optional_arg field. Update constructor.
2522 Update call constructor calls. Add takes_optional_argument
2524 (DEFINE_var): Add optional_arg__ parameter. Change all callers.
2525 (DEFINE_optional_string): Define.
2526 (General_options::demangle): Change from DEFINE_bool to
2527 DEFINE_optional_string.
2528 (General_options::no_demangle): New function.
2529 (General_options::do_demangle): New function.
2530 (General_options::set_do_demangle): New function.
2531 (General_options::execstack_status_): Move definition to end of
2533 (General_options::static_): Likewise.
2534 (General_options::do_demangle_): New field.
2535 * object.cc (big_endian>::get_symbol_location_info): Call
2536 Options::do_demangle, not Options::demangle.
2537 * symtab.cc (demangle): Likewise.
2541 * gold.h: Include <cstddef> and <sys/types.h>
2542 * options.h: Include <cstring>.
2546 * Added source code to GNU binutils.