4 * layout.cc (Layout::symtab_section_shndx): New function.
5 * layout.h (class Layout): Declare symtab_section_shndx.
6 * output.cc (Output_section::write_header): Call it.
11 * symtab.cc (Symbol::should_add_dynsym_entry): Don't add undefined
12 symbols which are not used in a relocation.
17 * layout.cc (Layout::segment_precedes): Don't crash if a linker
18 script create indistinguishable segments.
19 (Layout::set_segment_offsets): Use stable_sort when sorting
20 segments. Pass this to Compare_segments constructor.
21 * layout.h (class Layout): Make segment_precedes non-static.
22 (class Compare_segments): Change from struct to class. Add
23 layout_ field. Add constructor.
25 (Script_sections::attach_sections_using_phdrs_clause): Rename
26 local orphan to is_orphan. Don't report failure to put empty
27 section in segment. On attachment failure, report name of
28 section, and attach to first PT_LOAD segment.
33 * target-select.cc (Target_selector::Target_selector): Add
34 emulation parameter. Change all callers.
35 (select_target_by_bfd_name): Rename from select_target_by_name.
37 (select_target_by_emulation): New function.
38 (supported_emulation_names): New function.
39 * target-select.h (class Target_selector): Add emulation_ field.
41 (Target_selector::recognize_by_bfd_name): Rename from
42 recognize_by_name. Change all callers.
43 (Target_selector::supported_bfd_names): Rename from
44 supported_names. Change all callers.
45 (Target_selector::recognize_by_emulation): New function.
46 (Target_selector::supported_emulations): New function.
47 (Target_selector::emulation): New function.
48 (Target_selector::do_recognize_by_bfd_name): Rename from
49 do_recognize_by_name. Change all callers.
50 (Target_selector::do_supported_bfd_names): Rename from
51 do_supported_names. Change all callers.
52 (Target_selector::do_recognize_by_emulation): New function.
53 (Target_selector::do_supported_emulations): New function.
54 (select_target_by_bfd_name): Change name in declaration.
55 (select_target_by_emulation): Declare.
56 (supported_emulation_names): Declare.
57 * parameters.cc (parameters_force_valid_target): Try to find
58 target based on emulation from -m option.
59 * options.h (class General_options): Change doc string for -m.
60 * options.cc (help): Print emulations.
61 (General_options::parse_V): Likewise.
62 * freebsd.h (Target_selector_freebsd::Target_selector_freebsd):
63 Add emulation parameter. Change all callers.
67 * target.h (class Target): Add osabi_ field.
68 (Target::osabi): New function.
69 (Target::set_osabi): New function.
70 (Target::Target): Initialize osabi_.
71 (Target::do_adjust_elf_header): Make pure virtual.
72 (Sized_target::do_adjust_elf_header): Declare.
73 * target.cc (Sized_target::do_adjust_elf_header): New function.
74 (class Sized_target): Instantiate all versions.
75 * freebsd.h (class Target_freebsd): Remove.
76 (Target_selector_freebsd::do_recognize): Call set_osabi on
78 (Target_selector_freebsd::do_recognize_by_name): Likewise.
79 (Target_selector_freebsd::set_osabi): Remove.
80 * i386.cc (class Target_i386): Inherit from Sized_target rather
82 * x86_64.cc (class Target_x86_64): Likewise.
86 * target.h (Target::can_check_for_function_pointers): Rewrite.
88 (Target::can_icf_inline_merge_sections): Likewise.
89 (Target::section_may_have_icf_unsafe_poineters): Likewise.
90 (Target::Target_info): Add can_icf_inline_merge_sections field.
91 (Target::do_can_check_for_function_pointers): New virtual
93 (Target::do_section_may_have_icf_unsafe_pointers): Likewise.
94 * arm.cc (Target_arm::do_can_check_for_function_pointers): Rename
95 from can_check_for_function_pointers, move in file.
96 (Target_arm::do_section_may_have_icf_unsafe_pointers): Rename from
97 section_may_have_icf_unsafe_poineters, move in file.
98 (Target_arm::arm_info): Initialize can_icf_inline_merge_sections.
99 * i386.cc (Target_i386::do_can_check_for_function_pointers):
100 Rename from can_check_for_function_pointers, move in file.
101 (Target_i386::can_icf_inline_merge_sections): Remove.
102 (Target_i386::i386_info): Initialize
103 can_icf_inline_merge_sections.
104 * powerpc.cc (Target_powerpc::powerpc_info) [all versions]:
105 Initialize can_icf_inline_merge_sections.
106 * sparc.cc (Target_sparc::sparc_info) [both version]: Likewise.
107 * x86_64.cc (Target_x86_64::do_can_check_for_function_pointers):
108 Rename from can_check_for_function_pointers, move in file.
109 (Target_x86_64::can_icf_inline_merge_sections): Remove.
110 (Target_x86_64::x86_64_info): Initialize
111 can_icf_inline_merge_sections.
112 * testsuite/testfile.cc (Target_test::test_target_info):
114 * icf.cc (get_section_contents): Correct formatting.
118 * symtab.cc (Symbol::versioned_name): New function.
119 (Symbol_table::add_to_final_symtab): Use versioned_name when
121 (Symbol_table::sized_write_symbol): Likewise.
122 * symtab.h (class Symbol): Declare versioned_name.
123 * stringpool.h (class Stringpool_template): Add variant of add
124 which takes a std::basic_string.
125 * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_12.
126 (ver_test_12_SOURCES, ver_test_12_DEPENDENCIES): New variables.
127 (ver_test_12_LDFLAGS, ver_test_12_LDADD): New variables.
128 (ver_test_12.o): New target.
129 * testsuite/Makefile.in: Rebuild.
133 * arm.cc (Arm_relocate_functions::thm_jump8,
134 Arm_relocate_functions::thm_jump11): Use a wider signed
135 type to compute offset.
136 * testsuite/Makefile.am: Add new tests arm_thm_jump11 and
138 * testsuite/Makefile.in: Regenerate.
139 * testsuite/arm_branch_in_range.sh: Check test results of
140 arm_thm_jump11 and arm_thm_jump8.
141 * testsuite/arm_thm_jump11.s: New test source file.
142 * testsuite/arm_thm_jump11.t: New linker script.
143 * testsuite/arm_thm_jump8.s: New test source file.
144 * testsuite/arm_thm_jump8.t: New linker script.
148 * layout.cc: Include "object.h".
149 (ctors_sections_in_init_array): New static variable.
150 (Layout::is_ctors_in_init_array): New function.
151 (Layout::layout): Add entry to ctors_sections_in_init_array if
153 * layout.h (class Layout): Declare is_ctors_in_init_array.
154 * reloc.cc (Sized_relobj_file::do_relocate): Call reverse_words if
155 is_ctors_reverse_view is set.
156 (Sized_relobj_file::write_sections): Add layout parameter. Change
157 all callers. Set is_ctors_reverse_view field of View_size.
158 (Sized_relobj_file::reverse_words): New function.
159 * object.h (Sized_relobj_file::View_size): Add
160 is_ctors_reverse_view field.
161 (class Sized_relobj_file): Update declarations.
162 * testsuite/initpri3.c: New test.
163 * testsuite/Makefile.am: (check_PROGRAMS): Add initpri3a and
165 (initpri3a_SOURCES, initpri3a_DEPENDENCIES): New variables.
166 (initpri3a_LDFLAGS, initpri3a_LDADD): New variables.
167 (initpri3b_SOURCES, initpri3b_DEPENDENCIES): New variables.
168 (initpri3b_LDFLAGS, initpri3b_LDADD): New variables.
169 * testsuite/Makefile.in: Rebuild.
173 * testsuite/Makefile.am: Add in-tree assembler to gcctestdir.
174 (debug_msg_cdebug.o, odr_violation1_cdebug.o, odr_violation2_cdebug.o)
175 (debug_msg_cdebug.err): New targets.
176 * testsuite/Makefile.in: Regenerate.
177 * testsuite/debug_msg.sh: Check output of link with compressed debug.
178 Fix checks for link with shared library.
182 * arm.cc (Arm_output_section::append_text_sections_to_list): Do not
183 skip empty text sections.
184 * testsuite/arm_exidx_test.s: Test handling of an empty text section.
189 * options.h (class General_options): Add --ctors-in-init-array.
190 * layout.cc (Layout::get_output_section): Treat SHT_INIT_ARRAY and
191 friends as SHT_PROGBITS for merging sections.
192 (Layout::layout): Remove special handling of .init_array and
193 friends. Don't sort if doing relocatable link. Sort for .ctors
194 and .dtors if ctors_in_init_array.
195 (Layout::make_output_section): Force correct section types for
196 .init_array and friends. Don't sort if doing relocatable link,
197 Don't sort .ctors and .dtors if ctors_in_init_array.
198 (Layout::section_name_mapping): Remove .ctors. and .dtorso.
199 (Layout::output_section_name): Add relobj parameter. Change all
200 callers. Handle .ctors. and .dtors. in code rather than table.
201 Handle .ctors and .dtors if ctors_in_init_array.
202 (Layout::match_file_name): New function, moved from output.cc.
203 * layout.h (class Layout): Update declarations.
204 * output.cc: Include "layout.h".
205 (Input_section_sort_entry::get_priority): New function.
206 (Input_section_sort_entry::match_file_name): Just call
207 Layout::match_file_name.
208 (Output_section::Input_section_sort_init_fini_compare::operator()):
209 Handle .ctors and .dtors. Sort by explicit priority rather than
211 * configure.ac: Remove CONSTRUCTOR_PRIORITY test and conditional.
212 * testsuite/initpri2.c: New test.
213 * testsuite/Makefile.am: Don't test CONSTRUCTOR_PRIORITY.
214 (check_PROGRAMS): Add initpri2.
215 (initpri2_SOURCES, initpri2_DEPENDENCIES): New variables.
216 (initpri2_LDFLAGS, initpri2_LDADD): New variables.
217 * configure, testsuite/Makefile.in: Rebuild.
222 * layout.cc (Layout::attach_allocated_section_to_segment): Add a
223 .interp section to a PT_INTERP segment even if we have seen a
224 --dynamic-linker option. Don't do it if we have seen a PHDRS
225 clause in a linker script.
226 (Layout::finalize): Don't create a .interp section if we've
227 already create a PT_INTERP segment.
228 (Layout::create_interp): Always call choose_output_section (revert
229 patch of 2011-06-17). Don't create PT_INTERP segment.
231 (Script_sections::create_note_and_tls_segments): Add a .interp
232 section to a PT_INTERP segment even if we have seen a
233 --dynamic-linker option.
237 * layout.cc (Layout::finish_dynamic_section): Don't set DT_TEXTREL
238 merely because a non-PT_LOAD segment has a dynamic reloc.
242 * layout.cc (Layout::finish_dynamic_section): Don't create
243 DT_FLAGS entry if not needed.
248 * layout.cc (Layout::layout_eh_frame): Correct handling of
249 writable .eh_frame section.
254 * resolve.cc (Symbol_table::resolve): Don't give an error if a
255 symbol is redefined with the exact same object and value.
260 * layout.h (class Layout): Add interp_segment_ field.
261 * layout.cc (Layout::Layout): Initialize interp_segment_ field.
262 (Layout::attach_allocated_section_to_segment): If making shared
263 library, put .interp section in PT_INTERP segment.
264 (Layout::finalize): Also call create_interp if -dynamic-linker
266 (Layout::create_interp): Assert that there is no PT_INTERP
267 segment. If not using a SECTIONS clause, use make_output_section.
268 (Layout::make_output_segment): Set interp_segment_ if PT_INTERP.
270 (Script_sections::create_note_and_tls_segments): If making shared
271 library, put .interp section in PT_INTERP segment.
275 * object.cc (Sized_relobj_file::do_layout): Keep warning sections
276 when making a shared library.
280 * x86_64.cc (Target_x86_64::Scan::check_non_pic): Add gsym
281 parameter. Change all callers. Don't issue warning about PC32
282 against locally defined symbol.
286 * symtab.cc (Warnings::issue_warning): Don't warn if relocation
287 occurs in same object.
291 * po/POTFILES.in: Regenerate.
296 (Orphan_output_section::set_section_addresses): For a relocatable
297 link set address to 0.
302 * gold/gold.cc (queue_initial_tasks): Warn if --incremental is
303 used with --compress-debug-sections.
304 * gold/object.cc (Sized_relobj_file::do_layout): Report
305 uncompressed size of compressed input sections.
310 * testsuite/two_file_test_2_v1.cc: Change initialization of
311 v2 to keep it in .data.
315 * common.cc (Symbol_table::do_allocate_commons_list): Call
317 * errors.cc (Errors::fatal): Adjust call to gold_exit.
318 (Errors::fallback): New function.
319 (gold_fallback): New function.
320 * errors.h (Errors::fallback): New function.
321 * gold.cc (gold_exit): Change status parameter to enum; adjust
323 (queue_initial_tasks): Call gold_fallback.
324 * gold.h: Include cstdlib.
325 (Exit_status): New enum type.
326 (gold_exit): Change status parameter to enum.
327 (gold_fallback): New function.
328 * layout.cc (Layout::set_section_offsets): Call gold_fallback.
329 (Layout::create_symtab_sections): Likewise.
330 (Layout::create_shdrs): Likewise.
331 * main.cc (main): Adjust call to gold_exit.
332 * output.cc (Output_data_got::add_got_entry): Call gold_fallback.
333 (Output_data_got::add_got_entry_pair): Likewise.
334 (Output_section::add_input_section): Likewise.
335 (Output_section::add_output_section_data): Likewise.
336 (Output_segment::set_section_list_addresses): Likewise.
337 * x86_64.cc (Output_data_plt_x86_64::add_entry): Likewise.
341 * layout.cc (Layout::set_segment_offsets): Don't adjust layout
342 for incremental links.
343 * output.cc (Output_segment::set_section_list_addresses): Remove
344 FIXME and test for TLS or BSS.
348 * testsuite/Makefile.am: Add incremental_copy_test,
349 incremental_common_test_1.
350 * testsuite/Makefile.in: Regenerate.
351 * testsuite/common_test_1_v1.c: New source file.
352 * testsuite/common_test_1_v2.c: New source file.
353 * testsuite/copy_test_v1.cc: New source file.
357 * common.cc (Symbol_table::do_allocate_commons_list): For incremental
358 update, allocate common from bss section's free list.
359 * incremental-dump.cc (dump_incremental_inputs): Print flag for
360 linker-defined symbols.
361 * incremental.cc (Sized_incremental_binary::do_process_got_plt):
362 Skip GOT and PLT entries that are no longer referenced.
363 (Output_section_incremental_inputs::write_info_blocks): Mark
364 linker-defined symbols.
365 (Sized_incr_relobj::do_add_symbols): Process linker-defined symbols.
366 * output.cc (Output_section::allocate): New function.
367 * output.h (Output_section::allocate): New function.
368 * resolve.cc (Symbol_table::report_resolve_problem): Add case for
369 linker-defined symbols.
370 (Symbol::override_base_with_special): Copy is_predefined_ flag.
371 * symtab.cc (Symbol::init_fields): Initialize is_predefined_ flag.
372 (Symbol::init_base_output_data): Likewise.
373 (Symbol::init_base_output_segment): Likewise.
374 (Symbol::init_base_constant): Likewise.
375 (Sized_symbol::init_output_data): Likewise.
376 (Sized_symbol::init_output_segment): Likewise.
377 (Sized_symbol::init_constant): Likewise.
378 (Symbol_table::do_define_in_output_data): Likewise.
379 (Symbol_table::do_define_in_output_segment): Likewise.
380 (Symbol_table::do_define_as_constant): Likewise.
381 * symtab.h (Symbol::is_predefined): New function.
382 (Symbol::init_base_output_data): Add is_predefined parameter.
383 (Symbol::init_base_output_segment): Likewise.
384 (Symbol::init_base_constant): Likewise.
385 (Symbol::is_predefined_): New data member.
386 (Sized_symbol::init_output_data): Add is_predefined parameter.
387 (Sized_symbol::init_output_segment): Likewise.
388 (Sized_symbol::init_constant): Likewise.
389 (enum Symbol_table::Defined): Add INCREMENTAL_BASE.
393 * copy-relocs.cc (Copy_relocs::copy_reloc): Call make_copy_reloc
394 instead of emit_copy_reloc.
395 (Copy_relocs::emit_copy_reloc): Refactor.
396 (Copy_relocs::make_copy_reloc): New function.
397 (Copy_relocs::add_copy_reloc): Remove.
398 * copy-relocs.h (Copy_relocs::emit_copy_reloc): Move to public
400 (Copy_relocs::make_copy_reloc): New function.
401 (Copy_relocs::add_copy_reloc): Remove.
402 * gold.cc (queue_middle_tasks): Emit old COPY relocations from
403 unchanged input files.
404 * incremental-dump.cc (dump_incremental_inputs): Print "COPY" flag.
405 * incremental.cc (Sized_incremental_binary::do_reserve_layout):
406 Reserve BSS space for COPY relocations.
407 (Sized_incremental_binary::do_emit_copy_relocs): New function.
408 (Output_section_incremental_inputs::write_info_blocks): Record
409 whether a symbol is copied from a shared object.
410 (Sized_incr_dynobj::do_add_symbols): Record COPY relocations.
411 * incremental.h (enum Incremental_shlib_symbol_flags): New type.
412 (INCREMENTAL_SHLIB_SYM_FLAGS_SHIFT): New constant.
413 (Incremental_input_entry_reader::get_output_symbol_index): Add
415 (Incremental_binary::emit_copy_relocs): New function.
416 (Incremental_binary::do_emit_copy_relocs): New function.
417 (Sized_incremental_binary::Sized_incremental_binary): Initialize
419 (Sized_incremental_binary::add_copy_reloc): New function.
420 (Sized_incremental_binary::do_emit_copy_relocs): New function.
421 (Sized_incremental_binary::Copy_reloc): New struct.
422 (Sized_incremental_binary::Copy_relocs): New typedef.
423 (Sized_incremental_binary::copy_relocs_): New data member.
424 * symtab.cc (Symbol_table::add_from_incrobj): Change return type.
425 * symtab.h (Symbol_table::add_from_incrobj): Change return type.
426 * target.h (Sized_target::emit_copy_reloc): New function.
427 * x86_64.cc (Target_x86_64::emit_copy_reloc): New function.
432 * gold/archive.cc (Archive::Archive): Initialize new data member.
433 (Archive::include_all_members): Return if archive has already been
435 * gold/archive.h (Archive::include_all_members_): New data member.
439 * dynobj.h: Fix spelling mistake in comment.
440 * output.cc: Likewise.
446 * arm.cc (Target_arm::tag_cpu_arch_combine): Fix handling of
447 arch value that equals to elfcpp::MAX_TAG_CPU_ARCH.
448 * testsuite/Makefile.am: (MOSTLYCLEANFILES): Clean up. Remove
449 redundant arm_exidx_test.so.
450 * testsuite/Makefile.in: Regenerate.
451 (check_SCRIPTS): Add pr12826.sh
452 (check_DATA): Add pr12826.stdout
453 (pr12826.stdout, pr12826.so, pr12826_1.o, pr12826_2.o): New rules.
454 * testsuite/pr12826.sh: New file.
455 * testsuite/pr12826_1.s: Ditto.
456 * testsuite/pr12826_1.s: Ditto.
460 * reloc.cc (Sized_relobj_file::do_read_relocs): Ignore empty reloc
466 * testsuite/Makefile.am: Use different file name for two_file_test
467 temporary file for each incremental test.
468 * testsuite/Makefile.in: Rebuild.
472 * binary.cc (Binary_to_elf::sized_convert): Don't crash if the
473 binary input file is empty.
477 * testsuite/Makefile.am (ver_test_2.so): Use -Wl,-R,.
478 (ver_test_9.so): Likewise.
479 * testsuite/Makefile.in: Rebuild.
483 * incremental-dump.cc (dump_incremental_inputs): Print COMDAT groups.
484 * incremental.cc (Incremental_inputs::report_input_section): Fix
485 comment, indentation.
486 (Incremental_inputs::report_comdat_group): New function.
487 (Output_section_incremental_inputs::set_final_data_size): Adjust size
488 of data for incremental input file entry.
489 (Output_section_incremental_inputs::write_info_blocks): Write COMDAT
490 group count, COMDAT group signatures.
491 (Sized_incr_relobj::do_layout): Record kept COMDAT group info from
492 an unchanged input file.
493 * incremental.h (Incremental_object_entry::Incremental_object_entry):
494 Initialize new data member.
495 (Incremental_object_entry::add_comdat_group): New function.
496 (Incremental_object_entry::get_comdat_group_count): New function.
497 (Incremental_object_entry::get_comdat_signature_key): New function.
498 (Incremental_object_entry::groups_): New data member.
499 (Incremental_inputs::report_comdat_group): New function.
500 (Incremental_input_entry_reader::get_symbol_offset): Adjust size of
501 data for incremental input file entry.
502 (Incremental_input_entry_reader::get_comdat_group_count): New function.
503 (Incremental_input_entry_reader::get_input_section): Adjust size of
504 data for incremental input file entry.
505 (Incremental_input_entry_reader::get_global_symbol_reader): Likewise.
506 (Incremental_input_entry_reader::get_comdat_group_signature): New
508 * object.cc (Sized_relobj::include_section_group): Report kept
509 COMDAT groups for incremental links.
513 * dirsearch.cc (Dirsearch::find): Replace n1 and n2 parameters
514 with name parameter. Add found_name parameter.
515 * fileread.cc (Input_file::find_file): Adjust code accordingly.
516 * dirsearch.h (class Dirsearch): Update declaration.
520 * archive.cc (Library_base::should_include_member): Pull in object
521 from archive if it defines the entry symbol.
522 * parameters.cc (Parameters::entry): New function.
523 * parameters.h (class Parameters): Declare entry.
524 * output.h (class Output_file_header): Remove entry_ field.
525 * output.cc (Output_file_header::Output_file_header): Remove entry
526 parameter. Change all callers.
527 (Output_file_header::entry): Use parameters->entry.
528 * gold.cc (queue_middle_tasks): Likewise.
529 * plugin.cc (Plugin_hook::run): Likewise.
533 * gold.cc (queue_initial_tasks): Pass incremental base filename
534 to Output_file::open_base_file; don't print error message.
535 * incremental-dump.cc (main): Adjust call to
536 Output_file::open_for_modification.
537 * incremental-dump.cc (main): Likewise.
538 * incremental.cc (Incremental_inputs::report_command_line):
539 Ignore --incremental-base option when comparing command lines.
540 Ignore parameter when given as separate argument.
541 * options.h (class General_options): Add --incremental-base.
542 * output.cc (Output_file::Output_file):
543 (Output_file::open_base_file): Add base_name and writable parameters;
544 read base file into new file; print error message here.
545 (Output_file::map_no_anonymous): Add writable parameter; adjust all
547 * output.h (Output_file::open_for_modification): Rename to...
548 (Output_file::open_base_file): ...this; add base_name and
549 writable parameters; adjust all callers.
550 (Output_file::map_no_anonymous): Add writable parameter; adjust all
552 * testsuite/Makefile.am (incremental_test_4): Test
554 * testsuite/Makefile.in: Regenerate.
558 * testsuite/Makefile.am: Add incremental_test_2, incremental_test_3,
560 * testsuite/Makefile.in: Regenerate.
561 * testsuite/two_file_test_1_v1.cc: New test source file.
562 * testsuite/two_file_test_1b_v1.cc: New test source file.
563 * testsuite/two_file_test_2_v1.cc: New test source file.
567 * dynobj.h (Dynobj::do_dynobj): New function.
568 * incremental-dump.cc (dump_incremental_inputs): Print as_needed
569 flag and soname for shared objects.
570 * incremental.cc (Incremental_inputs::report_object): Make
571 either Incremental_object_entry or Incremental_dynobj_entry; add
572 soname to string table.
573 (Incremental_inputs::report_input_section): Add assertion.
574 (Output_section_incremental_inputs::set_final_data_size): Adjust
575 type of input file entry for shared libraries; adjust size of
576 shared library info entry.
577 (Output_section_incremental_inputs::write_input_files): Write
578 as_needed flag for shared libraries.
579 (Output_section_incremental_inputs::write_info_blocks): Adjust type
580 of input file entry for shared libraries; write soname.
581 (Sized_incr_dynobj::Sized_incr_dynobj): Read as_needed flag and
582 soname from incremental info.
583 * incremental.h (enum Incremental_input_flags): Add
584 INCREMENTAL_INPUT_AS_NEEDED.
585 (Incremental_input_entry::Incremental_input_entry): Initialize new
587 (Incremental_input_entry::set_as_needed): New function.
588 (Incremental_input_entry::as_needed): New function.
589 (Incremental_input_entry::do_dynobj_entry): New function.
590 (Incremental_input_entry::as_needed_): New data member.
591 (Incremental_object_entry::Incremental_object_entry): Don't check
593 (Incremental_object_entry::do_type): Likewise.
594 (class Incremental_dynobj_entry): New class.
595 (Incremental_input_entry_reader::as_needed): New function.
596 (Incremental_input_entry_reader::get_soname): New function.
597 (Incremental_input_entry_reader::get_global_symbol_count): Rewrite.
598 (Incremental_input_entry_reader::get_output_symbol_index): Adjust
599 size of shared library info entry.
600 * layout.cc (Layout::finish_dynamic_section): Don't test for
601 incremental link when adding DT_NEEDED entries.
602 * object.h (Object::Object): Initialize new data member.
603 (Object::dynobj): New function.
604 (Object::set_as_needed): New function.
605 (Object::as_needed): New function.
606 (Object::do_dynobj): New function.
607 (Object::as_needed_): New data member.
611 * incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc
612 info; adjust display of GOT entries.
613 * incremental.cc (Sized_incremental_binary::setup_readers): Allocate
614 vector of input objects; remove file_status_.
615 (Sized_incremental_binary::do_reserve_layout): Remove file_status_.
616 (Sized_incremental_binary::do_process_got_plt): Adjust calls to
617 got_plt reader; call target hooks to reserve GOT entries.
618 (Output_section_incremental_inputs::set_final_data_size): Adjust size
619 of input file info header and GOT info entry.
620 (Output_section_incremental_inputs::write_info_blocks): Write dynamic
622 (Got_plt_view_info::got_descriptor): Remove.
623 (Got_plt_view_info::sym_index): New data member.
624 (Got_plt_view_info::input_index): New data member.
625 (Local_got_offset_visitor::visit): Write input file index.
626 (Global_got_offset_visitor::visit): Write 0 for input file index.
627 (Global_symbol_visitor_got_plt::operator()): Replace got_descriptor
628 with sym_index and input_index.
629 (Output_section_incremental_inputs::write_got_plt): Adjust size of
630 incremental info GOT entry; replace got_descriptor with input_index.
631 (Sized_relobj_incr::Sized_relobj_incr): Adjust initializers; record
632 map from input file index to object.
633 (Sized_relobj_incr::do_layout): Replace direct data member reference
634 with accessor function.
635 (Sized_relobj_incr::do_for_all_local_got_entries): Move to base class.
636 * incremental.h (Incremental_input_entry_reader::get_symbol_offset):
637 Adjust size of input file info header.
638 (Incremental_input_entry_reader::get_first_dyn_reloc): New function.
639 (Incremental_input_entry_reader::get_dyn_reloc_count): New function.
640 (Incremental_input_entry_reader::get_input_section): Adjust size of
641 input file info header.
642 (Incremental_got_plt_reader::Incremental_got_plt_reader): Adjust size
643 of incremental info GOT entry.
644 (Incremental_got_plt_reader::get_got_desc): Remove.
645 (Incremental_got_plt_reader::get_got_symndx): New function.
646 (Incremental_got_plt_reader::get_got_input_index): New function.
647 (Sized_incremental_binary::Sized_incremental_binary): Remove
648 file_status_; add input_objects_.
649 (Sized_incremental_binary::~Sized_incremental_binary): Remove.
650 (Sized_incremental_binary::set_file_is_unchanged): Remove.
651 (Sized_incremental_binary::file_is_unchanged): Remove.
652 (Sized_incremental_binary::set_input_object): New function.
653 (Sized_incremental_binary::input_object): New function.
654 (Sized_incremental_binary::file_status_): Remove.
655 (Sized_incremental_binary::input_objects_): New data member.
656 (Sized_relobj_incr): Rename Sized_incr_relobj to this; adjust all
658 (Sized_relobj_incr::invalid_address): Move to base class.
659 (Sized_relobj_incr::is_output_section_offset_invalid): Move to base
661 (Sized_relobj_incr::do_output_section_offset): Likewise.
662 (Sized_relobj_incr::do_for_all_local_got_entries): Likewise.
663 (Sized_relobj_incr::section_offsets_): Likewise.
664 * object.cc (Sized_relobj::do_for_all_local_got_entries): New
666 (Sized_relobj_file::Sized_relobj_file): Remove local_got_offsets_.
667 (Sized_relobj_file::layout_section): Replace refs to section_offsets_
668 with accessor function.
669 (Sized_relobj_file::do_layout): Likewise.
670 (Sized_relobj_file::do_layout_deferred_sections): Likewise.
671 (Sized_relobj_file::do_for_all_local_got_entries): Move to base class.
672 (Sized_relobj_file::compute_final_local_value): Replace refs to
673 section_offsets_ with accessor function.
674 (Sized_relobj_file::do_finalize_local_symbols): Likewise.
675 * object.h (Relobj::Relobj): Initialize new data members.
676 (Relobj::add_dyn_reloc): New function.
677 (Relobj::first_dyn_reloc): New function.
678 (Relobj::dyn_reloc_count): New function.
679 (Relobj::first_dyn_reloc_): New data member.
680 (Relobj::dyn_reloc_count_): New data member.
681 (Sized_relobj): Rename Sized_relobj_base to this; adjust all
683 (Sized_relobj::Address): New typedef.
684 (Sized_relobj::invalid_address): Move here from child class.
685 (Sized_relobj::Sized_relobj): Initialize new data members.
686 (Sized_relobj::sized_relobj): New function.
687 (Sized_relobj::is_output_section_offset_invalid): Move here from
689 (Sized_relobj::get_output_section_offset): Likewise.
690 (Sized_relobj::local_has_got_offset): Likewise.
691 (Sized_relobj::local_got_offset): Likewise.
692 (Sized_relobj::set_local_got_offset): Likewise.
693 (Sized_relobj::do_for_all_local_got_entries): Likewise.
694 (Sized_relobj::clear_got_offsets): New function.
695 (Sized_relobj::section_offsets): Move here from child class.
696 (Sized_relobj::do_output_section_offset): Likewise.
697 (Sized_relobj::do_set_section_offset): Likewise.
698 (Sized_relobj::Local_got_offsets): Likewise.
699 (Sized_relobj::local_got_offsets_): Likewise.
700 (Sized_relobj::section_offsets_): Likewise.
701 (Sized_relobj_file): Rename Sized_relobj to this; adjust all
703 (Sized_relobj_file::is_output_section_offset_invalid): Move to base
705 (Sized_relobj_file::sized_relobj): New function
706 (Sized_relobj_file::local_has_got_offset): Move to base class.
707 (Sized_relobj_file::local_got_offset): Likewise.
708 (Sized_relobj_file::set_local_got_offset): Likewise.
709 (Sized_relobj_file::get_output_section_offset): Likewise.
710 (Sized_relobj_file::do_for_all_local_got_entries): Likewise.
711 (Sized_relobj_file::do_output_section_offset): Likewise.
712 (Sized_relobj_file::do_set_section_offset): Likewise.
713 (Sized_relobj_file::Local_got_offsets): Likewise.
714 (Sized_relobj_file::local_got_offsets_): Likewise.
715 (Sized_relobj_file::section_offsets_): Likewise.
716 * output.cc (Output_reloc::Output_reloc): Adjust type of relobj
718 (set_needs_dynsym_index): Convert relobj to derived class pointer.
719 (Output_reloc::get_symbol_index): Likewise.
720 (Output_reloc::local_section_offset): Likewise.
721 (Output_reloc::get_address): Likewise.
722 (Output_reloc::symbol_value): Likewise.
723 (Output_data_got::reserve_slot): Move to class definition.
724 (Output_data_got::reserve_local): New function.
725 (Output_data_got::reserve_slot_for_global): Remove.
726 (Output_data_got::reserve_global): New function.
727 * output.h (Output_reloc::Output_reloc): Adjust type of relobj
728 (all constructors, two instantiations).
729 (Output_reloc::get_relobj): New function (two instantiations).
730 (Output_reloc::u1_.relobj, Output_reloc::u2_.relobj): Adjust type.
731 (Output_data_reloc_base::add): Convert relobj to derived class pointer.
732 (Output_data_reloc::add_global): Adjust type of relobj.
733 (Output_data_reloc::add_global_relative): Likewise.
734 (Output_data_reloc::add_symbolless_global_addend): Likewise.
735 (Output_data_reloc::add_local): Likewise.
736 (Output_data_reloc::add_local_relative): Likewise.
737 (Output_data_reloc::add_symbolless_local_addend): Likewise.
738 (Output_data_reloc::add_local_section): Likewise.
739 (Output_data_reloc::add_output_section): Likewise.
740 (Output_data_reloc::add_absolute): Likewise.
741 (Output_data_reloc::add_target_specific): Likewise.
742 (Output_data_got::reserve_slot): Move definition here.
743 (Output_data_got::reserve_local): New function.
744 (Output_data_got::reserve_global): New function.
745 * reloc.cc (Sized_relobj_file::do_read_relocs): Replace refs to
746 section_offsets_ with accessor function.
747 (Sized_relobj_file::write_sections): Likewise.
748 (Sized_relobj_file::do_relocate_sections): Likewise.
749 * target.h (Sized_target::reserve_local_got_entry): New function.
750 (Sized_target::reserve_global_got_entry): New function.
751 * x86_64.cc (Target_x86_64::reserve_local_got_entry): New function.
752 (Target_x86_64::reserve_global_got_entry): New function.
753 (Target_x86_64::init_got_plt_for_update): Create rela_dyn section.
757 * gold.cc (queue_middle_tasks): Process existing GOT/PLT entries.
758 * incremental-dump.cc (dump_incremental_inputs): Mask high-order
759 bit when checking got_type.
760 * incremental.cc (Sized_incremental_binary::setup_readers):
761 Store symbol table and string table locations; initialize bit vector
762 of file status flags.
763 (Sized_incremental_binary::do_reserve_layout): Set bit flag for
765 (Sized_incremental_binary::do_process_got_plt): New function.
766 (Sized_incremental_binary::get_symtab_view): Use stored locations.
767 (Output_section_incremental_inputs::set_final_data_size): Record
768 file index for each input file.
769 (Output_section_incremental_inputs::write_got_plt): Store file index
770 instead of input entry offset for each GOT entry.
772 (Incremental_input_entry::Incremental_input_entry): Initialize new
774 (Incremental_input_entry::set_offset): Store file index.
775 (Incremental_input_entry::get_file_index): New function.
776 (Incremental_input_entry::file_index_): New data member.
777 (Incremental_binary::process_got_plt): New function.
778 (Incremental_binary::do_process_got_plt): New function.
779 (Sized_incremental_binary::Sized_incremental_binary): Initialize new
781 (Sized_incremental_binary::~Sized_incremental_binary): New destructor.
782 (Sized_incremental_binary::set_file_is_unchanged): New function.
783 (Sized_incremental_binary::file_is_unchanged): New function.
784 (Sized_incremental_binary::do_process_got_plt): New function.
785 (Sized_incremental_binary::file_status_): New data member.
786 (Sized_incremental_binary::main_symtab_loc_): New data member.
787 (Sized_incremental_binary::main_strtab_loc_): New data member.
788 * output.cc (Output_data_got::Got_entry::write): Add case
790 (Output_data_got::add_global): Call add_got_entry.
791 (Output_data_got::add_global_plt): Likewise.
792 (Output_data_got::add_global_with_rel): Likewise.
793 (Output_data_got::add_global_with_rela): Likewise.
794 (Output_data_got::add_global_pair_with_rel): Call add_got_entry_pair.
795 (Output_data_got::add_global_pair_with_rela): Likewise.
796 (Output_data_got::add_local): Call add_got_entry.
797 (Output_data_got::add_local_plt): Likewise.
798 (Output_data_got::add_local_with_rel): Likewise.
799 (Output_data_got::add_local_with_rela): Likewise.
800 (Output_data_got::add_local_pair_with_rel): Call add_got_entry_pair.
801 (Output_data_got::add_local_pair_with_rela): Likewise.
802 (Output_data_got::reserve_slot): New function.
803 (Output_data_got::reserve_slot_for_global): New function.
804 (Output_data_got::add_got_entry): New function.
805 (Output_data_got::add_got_entry_pair): New function.
806 (Output_section::add_output_section_data): Edit FIXME.
808 (Output_section_data_build::Output_section_data_build): New
809 constructor with size parameter.
810 (Output_data_space::Output_data_space): Likewise.
811 (Output_data_got::Output_data_got): Initialize new data member; new
812 constructor with size parameter.
813 (Output_data_got::add_constant): Call add_got_entry.
814 (Output_data_got::reserve_slot): New function.
815 (Output_data_got::reserve_slot_for_global): New function.
816 (class Output_data_got::Got_entry): Add RESERVED_CODE.
817 (Output_data_got::add_got_entry): New function.
818 (Output_data_got::add_got_entry_pair): New function.
819 (Output_data_got::free_list_): New data member.
820 * target.h (Sized_target::init_got_plt_for_update): New function.
821 (Sized_target::register_global_plt_entry): New function.
822 * x86_64.cc (Output_data_plt_x86_64::Output_data_plt_x86_64):
823 Initialize new data member; call init; add constructor with PLT count.
824 (Output_data_plt_x86_64::init): New function.
825 (Output_data_plt_x86_64::add_relocation): New function.
826 (Output_data_plt_x86_64::reserve_slot): New function.
827 (Output_data_plt_x86_64::free_list_): New data member.
828 (Target_x86_64::init_got_plt_for_update): New function.
829 (Target_x86_64::register_global_plt_entry): New function.
830 (Output_data_plt_x86_64::add_entry): Allocate from free list for
832 (Output_data_plt_x86_64::add_relocation): New function.
833 * testsuite/object_unittest.cc (Object_test): Set default options.
837 * options.h (class General_options): Make -i a synonym for -r.
841 * testsuite/tls_test_main.cc: Use semaphores instead of mutexes.
845 * object.cc (Sized_relobj::do_count_local_symbols): Check for
850 * layout.cc (Layout::layout): If the output section flags change,
855 * incremental-dump.cc (dump_incremental_inputs): Print local
856 symbol info for each input file.
858 (Output_section_incremental_inputs::set_final_data_size): Add local
859 symbol info to input file entries in incremental info.
860 (Output_section_incremental_inputs::write_info_blocks): Likewise.
861 (Sized_incr_relobj::Sized_incr_relobj): Initialize new data members.
862 (Sized_incr_relobj::do_add_symbols): Cosmetic change.
863 (Sized_incr_relobj::do_count_local_symbols): Replace stub with
865 (Sized_incr_relobj::do_finalize_local_symbols): Likewise.
866 (Sized_incr_relobj::do_relocate): Write the local symbols.
867 (Sized_incr_dynobj::do_add_symbols): Cosmetic change.
868 * incremental.h (Incremental_inputs_reader::get_symbol_offset):
869 Adjust size of input file header.
870 (Incremental_inputs_reader::get_local_symbol_offset): New function.
871 (Incremental_inputs_reader::get_local_symbol_count): New function.
872 (Incremental_inputs_reader::get_input_section): Adjust size of input
874 (Incremental_inputs_reader::get_global_symbol_reader): Likewise.
875 (Sized_incr_relobj::This): New typedef.
876 (Sized_incr_relobj::sym_size): New const data member.
877 (Sized_incr_relobj::Local_symbol): New struct.
878 (Sized_incr_relobj::do_output_local_symbol_count): New function.
879 (Sized_incr_relobj::do_local_symbol_offset): New function.
880 (Sized_incr_relobj::local_symbol_count_): New data member.
881 (Sized_incr_relobj::output_local_dynsym_count_): New data member.
882 (Sized_incr_relobj::local_symbol_index_): New data member.
883 (Sized_incr_relobj::local_symbol_offset_): New data member.
884 (Sized_incr_relobj::local_dynsym_offset_): New data member.
885 (Sized_incr_relobj::local_symbols_): New data member.
886 * object.h (Relobj::output_local_symbol_count): New function.
887 (Relobj::local_symbol_offset): New function.
888 (Relobj::do_output_local_symbol_count): New function.
889 (Relobj::do_local_symbol_offset): New function.
890 (Sized_relobj::do_output_local_symbol_count): New function.
891 (Sized_relobj::do_local_symbol_offset): New function.
895 * descriptors.cc (set_close_on_exec): New function.
896 (Descriptors::open): Use set_close_on_exec.
897 * output.cc (S_ISLNK): Define if not defined.
901 * incremental.cc (Sized_incremental_binary::setup_readers): Allocate
903 (Sized_incremental_binary::do_apply_incremental_relocs): New function.
904 (Sized_incr_relobj::do_add_symbols): Add symbols to global symbol map.
905 (Sized_incr_relobj::do_relocate): Remap section indices in incremental
907 (Sized_incr_dynobj::do_add_symbols): Add symbols to global symbol map.
908 (Sized_incr_dynobj::do_for_all_global_symbols): Remove FIXME.
909 (Sized_incr_dynobj::do_for_all_local_got_entries): Likewise.
911 (Incremental_inputs_reader::global_symbol_reader_at_offset): New
913 (Incremental_binary::apply_incremental_relocs): New function.
914 (Incremental_binary::do_apply_incremental_relocs): New function.
915 (Sized_incremental_binary::Sized_incremental_binary): Initialize new
917 (Sized_incremental_binary::add_global_symbol): New function.
918 (Sized_incremental_binary::global_symbol): New function.
919 (Sized_incremental_binary::do_apply_incremental_relocs): New function.
920 (Sized_incremental_binary::symbol_map_): New data member.
921 * layout.cc (Layout_task_runner::run): Apply incremental relocations.
922 * target.h (Sized_target::apply_relocation): New function.
923 * target-reloc.h (apply_relocation): New function.
924 * x86_64.cc (Target_x86_64::apply_relocation): New function.
928 * arm.cc (Arm_output_section::Arm_output_section): Set SHF_LINK_ORDER
929 flag of a SHT_ARM_EXIDX section.
930 * testsuite/Makefile.am (arm_exidx_test): New test rules.
931 * testsuite/Makefile.in: Regenerate.
932 * testsuite/arm_exidx_test.s: New file.
933 * testsuite/arm_exidx_test.sh: Same.
938 * archive.h (Incremental_archive_entry::Archive_member):
939 Initialize arg_serial_ (second constructor).
943 * object.cc (Relocate_info::location): Simplify location string.
944 * errors.cc (Errors::error_at_location): Don't print program
946 (Errors::warning_at_location): Likewise.
947 (Errors::undefined_symbol): Likewise.
948 * testsuite/debug_msg.sh: Update accordingly.
952 * gold/layout.cc (Layout::symtab_section_offset): New function.
953 * gold/layout.h (Layout::symtab_section_offset): New function.
954 * gold/reloc.cc (Sized_relobj::do_relocate): Call it.
958 * configure.ac: Check for sys/mman.h and mmap. Check for mremap
960 * output.h (class Output_file): Add map_is_allocated_ field.
961 * output.cc: Only #include <sys/mman.h> if it exists. If mmap is
962 not available, provide stubs. If mremap is not available, #define
964 (MREMAP_MAYMOVE): Define if not defined.
965 (Output_file::Output_file): Initialize map_is_allocated_.
966 (Output_file::resize): Check map_is_allocated_.
967 (Output_file::map_anonymous): If mmap fails, use malloc.
968 (Output_file::unmap): Don't do anything for an anonymous map.
969 * fileread.cc: Only #include <sys/mman.h> if it exists. If mmap
970 is not available, provide stubs.
971 (File_read::View::~View): Use free rather than delete[].
972 (File_read::make_view): Use malloc rather than new[]. If mmap
974 (File_read::find_or_make_view): Use malloc rather than new[].
975 * gold.h: Remove HAVE_REMAP code.
976 * mremap.c: #include <errno.h>. Only #include <sys/mman.h> if it
977 exists. Rename mremap to gold_mremap. If mmap is not available
979 * configure, config.in: Rebuild.
983 * incremental.cc (Sized_incr_relobj::do_add_symbols): Always
984 initialize local variable v.
988 * archive.cc (Archive::include_member): Adjust call to
990 (Add_archive_symbols::run): Track argument serial numbers.
991 (Lib_group::include_member): Likewise.
992 (Add_lib_group_symbols::run): Adjust call to report_archive_begin.
993 * archive.h (Incremental_archive_entry::Archive_member):
994 Initialize arg_serial_.
995 (Archive_member::arg_serial_): New data member.
996 * dynobj.cc (Dynobj::Dynobj): Allow input_file_ to be NULL.
997 (Sized_dynobj::do_add_symbols): Track symbols when doing an
999 (Sized_dynobj::do_for_all_local_got_entries): New function.
1000 * dynobj.h: (Sized_dynobj::do_for_all_local_got_entries): New
1002 * fileread.cc (get_mtime): New function.
1003 * fileread.h (get_mtime): New function.
1004 * gold.cc (queue_initial_tasks): Check for incremental update.
1005 (process_incremental_input): New function.
1006 (queue_middle_tasks): Don't force valid target for incremental
1008 * incremental-dump.cc (find_input_containing_global): Adjust
1009 size of symbol info entry.
1010 (dump_incremental_inputs): Dump argument serial number and
1011 in_system_directory flag; bias shndx by 1; print symbol names
1012 when dumping per-file symbol lists; use new symbol info readers.
1014 (Output_section_incremental_inputs:update_data_size): New function.
1015 (Sized_incremental_binary::setup_readers): Setup input readers
1016 for each input file; build maps for files added from libraries
1018 (Sized_incremental_binary::check_input_args): New function.
1019 (Sized_incremental_binary::do_check_inputs): Build map of argument
1020 serial numbers to input arguments.
1021 (Sized_incremental_binary::do_file_has_changed): Rename
1022 do_file_is_unchanged to this; compare file modification times.
1023 (Sized_incremental_binary::do_init_layout): New function.
1024 (Sized_incremental_binary::do_reserve_layout): New function.
1025 (Sized_incremental_binary::do_get_input_reader): Remove.
1026 (Sized_incremental_binary::get_symtab_view): New function.
1027 (Incremental_checker::can_incrementally_link_output_file): Remove.
1028 (Incremental_inputs::report_command_line): Exclude --debug options.
1029 (Incremental_inputs::report_archive_begin): Add parameter; track
1030 argument serial numbers; don't put input file entry for archive
1031 before archive members.
1032 (Incremental_inputs::report_archive_end): Put input file entry
1033 for archive after archive members.
1034 (Incremental_inputs::report_object): Add parameter; track argument
1035 serial numbers and in_system_directory flag.
1036 (Incremental_inputs::report_script): Add parameter; track argument
1038 (Output_section_incremental_inputs::set_final_data_size): Adjust
1039 size of symbol info entry; check for forwarding symbols.
1040 (Output_section_incremental_inputs::write_input_files): Write
1041 in_system_directory flag and argument serial number.
1042 (Output_section_incremental_inputs::write_info_blocks): Map section
1043 indices between incremental info and original input file; store
1044 input section index for each symbol.
1045 (class Local_got_offset_visitor): Derive from Got_offset_list::Visitor;
1046 change operator() to visit().
1047 (class Global_got_offset_visitor): Likewise.
1048 (class Global_symbol_visitor_got_plt):
1049 (Output_section_incremental_inputs::write_got_plt): Use new visitor
1051 (Sized_incr_relobj::Sized_incr_relobj): New constructor.
1052 (Sized_incr_relobj::do_read_symbols): New function.
1053 (Sized_incr_relobj::do_layout): New function.
1054 (Sized_incr_relobj::do_layout_deferred_sections): New function.
1055 (Sized_incr_relobj::do_add_symbols): New function.
1056 (Sized_incr_relobj::do_should_include_member): New function.
1057 (Sized_incr_relobj::do_for_all_global_symbols): New function.
1058 (Sized_incr_relobj::do_for_all_local_got_entries): New function.
1059 (Sized_incr_relobj::do_section_size): New function.
1060 (Sized_incr_relobj::do_section_name): New function.
1061 (Sized_incr_relobj::do_section_contents): New function.
1062 (Sized_incr_relobj::do_section_flags): New function.
1063 (Sized_incr_relobj::do_section_entsize): New function.
1064 (Sized_incr_relobj::do_section_address): New function.
1065 (Sized_incr_relobj::do_section_type): New function.
1066 (Sized_incr_relobj::do_section_link): New function.
1067 (Sized_incr_relobj::do_section_info): New function.
1068 (Sized_incr_relobj::do_section_addralign): New function.
1069 (Sized_incr_relobj::do_initialize_xindex): New function.
1070 (Sized_incr_relobj::do_get_global_symbol_counts): New function.
1071 (Sized_incr_relobj::do_read_relocs): New function.
1072 (Sized_incr_relobj::do_gc_process_relocs): New function.
1073 (Sized_incr_relobj::do_scan_relocs): New function.
1074 (Sized_incr_relobj::do_count_local_symbols): New function.
1075 (Sized_incr_relobj::do_finalize_local_symbols): New function.
1076 (Sized_incr_relobj::do_set_local_dynsym_indexes): New function.
1077 (Sized_incr_relobj::do_set_local_dynsym_offset): New function.
1078 (Sized_incr_relobj::do_relocate): New function.
1079 (Sized_incr_relobj::do_set_section_offset): New function.
1080 (Sized_incr_dynobj::Sized_incr_dynobj): New function.
1081 (Sized_incr_dynobj::do_read_symbols): New function.
1082 (Sized_incr_dynobj::do_layout): New function.
1083 (Sized_incr_dynobj::do_add_symbols): New function.
1084 (Sized_incr_dynobj::do_should_include_member): New function.
1085 (Sized_incr_dynobj::do_for_all_global_symbols): New function.
1086 (Sized_incr_dynobj::do_for_all_local_got_entries): New function.
1087 (Sized_incr_dynobj::do_section_size): New function.
1088 (Sized_incr_dynobj::do_section_name): New function.
1089 (Sized_incr_dynobj::do_section_contents): New function.
1090 (Sized_incr_dynobj::do_section_flags): New function.
1091 (Sized_incr_dynobj::do_section_entsize): New function.
1092 (Sized_incr_dynobj::do_section_address): New function.
1093 (Sized_incr_dynobj::do_section_type): New function.
1094 (Sized_incr_dynobj::do_section_link): New function.
1095 (Sized_incr_dynobj::do_section_info): New function.
1096 (Sized_incr_dynobj::do_section_addralign): New function.
1097 (Sized_incr_dynobj::do_initialize_xindex): New function.
1098 (Sized_incr_dynobj::do_get_global_symbol_counts): New function.
1099 (make_sized_incremental_object): New function.
1100 (Incremental_library::copy_unused_symbols): New function.
1101 (Incremental_library::do_for_all_unused_symbols): New function.
1102 * incremental.h (enum Incremental_input_flags): New type.
1103 (class Incremental_checker): Remove.
1104 (Incremental_input_entry::Incremental_input_entry): Add argument
1106 (Incremental_input_entry::arg_serial): New function.
1107 (Incremental_input_entry::set_is_in_system_directory): New function.
1108 (Incremental_input_entry::is_in_system_directory): New function.
1109 (Incremental_input_entry::arg_serial_): New data member.
1110 (Incremental_input_entry::is_in_system_directory_): New data member.
1111 (class Script_info): Move here from script.h.
1112 (Script_info::Script_info): Add filename parameter.
1113 (Script_info::filename): New function.
1114 (Script_info::filename_): New data member.
1115 (Incremental_script_entry::Incremental_script_entry): Add argument
1117 (Incremental_object_entry::Incremental_object_entry): Likewise.
1118 (Incremental_object_entry::add_input_section): Build list of input
1119 sections with map to original shndx.
1120 (Incremental_object_entry::get_input_section_index): New function.
1121 (Incremental_object_entry::shndx_): New data member.
1122 (Incremental_object_entry::name_key_): Rename; adjust all refs.
1123 (Incremental_object_entry::sh_size_): Rename; adjust all refs.
1124 (Incremental_archive_entry::Incremental_archive_entry): Add argument
1126 (Incremental_inputs::report_archive_begin): Likewise.
1127 (Incremental_inputs::report_object): Likewise.
1128 (Incremental_inputs::report_script): Likewise.
1129 (class Incremental_global_symbol_reader): New class.
1130 (Incremental_input_entry_reader::Incremental_input_entry_reader): Read
1131 and store flags and input file type.
1132 (Incremental_input_entry_reader::arg_serial): New function.
1133 (Incremental_input_entry_reader::type): Extract type from flags.
1134 (Incremental_input_entry_reader::is_in_system_directory): New function.
1135 (Incremental_input_entry_reader::get_input_section_count): Call
1136 accessor function for type.
1137 (Incremental_input_entry_reader::get_symbol_offset): Call accessor
1138 function for type; adjust size of global symbol entry.
1139 (Incremental_input_entry_reader::get_global_symbol_count): Call
1140 accessor function for type.
1141 (Incremental_input_entry_reader::get_object_count): Likewise.
1142 (Incremental_input_entry_reader::get_object_offset): Likewise.
1143 (Incremental_input_entry_reader::get_member_count): Likewise.
1144 (Incremental_input_entry_reader::get_unused_symbol_count): Likewise.
1145 (Incremental_input_entry_reader::get_member_offset): Likewise.
1146 (Incremental_input_entry_reader::get_unused_symbol): Likewise.
1147 (Incremental_input_entry_reader::Global_symbol_info): Remove.
1148 (Incremental_input_entry_reader::get_global_symbol_info): Remove.
1149 (Incremental_input_entry_reader::get_global_symbol_reader): New
1151 (Incremental_input_entry_reader::get_output_symbol_index): New
1153 (Incremental_input_entry_reader::type_): Remove.
1154 (Incremental_input_entry_reader::flags_): New data member.
1155 (Incremental_inputs_reader::input_file_offset): New function.
1156 (Incremental_inputs_reader::input_file_index): New function.
1157 (Incremental_inputs_reader::input_file): Call input_file_offset.
1158 (Incremental_inputs_reader::input_file_at_offset): New function.
1159 (Incremental_relocs_reader::get_r_type): Reformat.
1160 (Incremental_relocs_reader::get_r_shndx): Reformat.
1161 (Incremental_relocs_reader::get_r_offset): Reformat.
1162 (Incremental_relocs_reader::data): New function.
1163 (Incremental_binary::Incremental_binary): Initialize new data members.
1164 (Incremental_binary::check_inputs): Add cmdline parameter.
1165 (Incremental_binary::file_is_unchanged): Remove.
1166 (Input_reader::arg_serial): New function.
1167 (Input_reader::get_unused_symbol_count): New function.
1168 (Input_reader::get_unused_symbol): New function.
1169 (Input_reader::do_arg_serial): New function.
1170 (Input_reader::do_get_unused_symbol_count): New function.
1171 (Input_reader::do_get_unused_symbol): New function.
1172 (Incremental_binary::input_file_count): New function.
1173 (Incremental_binary::get_input_reader): Change signature to use
1174 index instead of filename.
1175 (Incremental_binary::file_has_changed): New function.
1176 (Incremental_binary::get_input_argument): New function.
1177 (Incremental_binary::get_library): New function.
1178 (Incremental_binary::get_script_info): New function.
1179 (Incremental_binary::init_layout): New function.
1180 (Incremental_binary::reserve_layout): New function.
1181 (Incremental_binary::output_file): New function.
1182 (Incremental_binary::do_check_inputs): New function.
1183 (Incremental_binary::do_file_is_unchanged): Remove.
1184 (Incremental_binary::do_file_has_changed): New function.
1185 (Incremental_binary::do_init_layout): New function.
1186 (Incremental_binary::do_reserve_layout): New function.
1187 (Incremental_binary::do_input_file_count): New function.
1188 (Incremental_binary::do_get_input_reader): Change signature.
1189 (Incremental_binary::input_args_map_): New data member.
1190 (Incremental_binary::library_map_): New data member.
1191 (Incremental_binary::script_map_): New data member.
1192 (Sized_incremental_binary::Sized_incremental_binary): Initialize
1194 (Sized_incremental_binary::output_section): New function.
1195 (Sized_incremental_binary::inputs_reader): Add const.
1196 (Sized_incremental_binary::symtab_reader): Add const.
1197 (Sized_incremental_binary::relocs_reader): Add const.
1198 (Sized_incremental_binary::got_plt_reader): Add const.
1199 (Sized_incremental_binary::get_symtab_view): New function.
1200 (Sized_incremental_binary::Inputs_reader): New typedef.
1201 (Sized_incremental_binary::Input_entry_reader): New typedef.
1202 (Sized_incremental_binary::do_check_inputs): Add cmdline parameter.
1203 (Sized_incremental_binary::do_file_is_unchanged): Remove.
1204 (Sized_incremental_binary::do_file_has_changed): New function.
1205 (Sized_incremental_binary::do_init_layout): New function.
1206 (Sized_incremental_binary::do_reserve_layout): New function.
1207 (Sized_input_reader::Inputs_reader): Remove.
1208 (Sized_input_reader::Input_entry_reader): Remove.
1209 (Sized_input_reader::do_arg_serial): New function.
1210 (Sized_input_reader::do_get_unused_symbol_count): New function.
1211 (Sized_input_reader::do_get_unused_symbol): New function.
1212 (Sized_incremental_binary::do_input_file_count): New function.
1213 (Sized_incremental_binary::do_get_input_reader): Change signature;
1214 use index instead of filename.
1215 (Sized_incremental_binary::section_map_): New data member.
1216 (Sized_incremental_binary::input_entry_readers_): New data member.
1217 (class Sized_incr_relobj): New class.
1218 (class Sized_incr_dynobj): New class.
1219 (make_sized_incremental_object): New function.
1220 (class Incremental_library): New class.
1221 * layout.cc (Free_list::num_lists): New static data member.
1222 (Free_list::num_nodes): New static data member.
1223 (Free_list::num_removes): New static data member.
1224 (Free_list::num_remove_visits): New static data member.
1225 (Free_list::num_allocates): New static data member.
1226 (Free_list::num_allocate_visits): New static data member.
1227 (Free_list::init): New function.
1228 (Free_list::remove): New function.
1229 (Free_list::allocate): New function.
1230 (Free_list::dump): New function.
1231 (Free_list::print_stats): New function.
1232 (Layout_task_runner::run): Resize output file for incremental updates.
1233 (Layout::Layout): Initialize new data members.
1234 (Layout::set_incremental_base): New function.
1235 (Layout::init_fixed_output_section): New function.
1236 (Layout::layout_eh_frame): Do not build .eh_frame_hdr section for
1237 incremental updates.
1238 (Layout::create_gold_note): Do not create gold note section for
1239 incremental updates.
1240 (Layout::set_segment_offsets): Do not recalculate RELRO alignment
1241 for incremental updates.
1242 (Layout::set_section_offsets): For incremental updates, allocate space
1244 (Layout::create_symtab_sections): Layout with offsets relative to
1245 start of section; for incremental updates, allocate space from free
1247 (Layout::create_shdrs): For incremental updates, allocate space from
1249 (Layout::finish_dynamic_section): For incremental updates, do not
1250 check --as-needed (fixed in subsequent patch).
1251 * layout.h (class Free_list): New class.
1252 (Layout::set_incremental_base): New function.
1253 (Layout::incremental_base): New function.
1254 (Layout::init_fixed_output_section): New function.
1255 (Layout::allocate): New function.
1256 (Layout::incremental_base_): New data member.
1257 (Layout::free_list_): New data member.
1258 * main.cc (main): Print Free_list statistics.
1259 * object.cc (Relobj::finalize_incremental_relocs): Add
1260 clear_counts parameter; clear counts only when clear_counts is set.
1261 (Sized_relobj::Sized_relobj): Initialize new base class.
1262 (Sized_relobj::do_layout): Don't report special sections.
1263 (Sized_relobj::do_for_all_local_got_entries): New function.
1264 (Sized_relobj::write_local_symbols): Add symtab_off parameter; add
1265 symtab_off to all symbol table offsets.
1266 (Sized_relobj::do_get_global_symbol_counts): Add typename keyword.
1267 * object.h (class Got_offset_list): Move to top of file.
1268 (Object::Object): Allow case where input_file == NULL.
1269 (Object::~Object): Likewise.
1270 (Object::input_file): Assert that input_file != NULL.
1271 (Object::lock): Allow case where input_file == NULL.
1272 (Object::unlock): Likewise.
1273 (Object::is_locked): Likewise.
1274 (Object::token): Likewise.
1275 (Object::release): Likewise.
1276 (Object::is_incremental): New function.
1277 (Object::get_mtime): New function.
1278 (Object::for_all_local_got_entries): New function.
1279 (Object::clear_view_cache_marks): Allow case where input_file == NULL.
1280 (Object::set_is_in_system_directory): New function.
1281 (Object::is_in_system_directory): New function.
1282 (Object::do_is_incremental): New function.
1283 (Object::do_get_mtime): New function.
1284 (Object::do_for_all_local_got_entries): New function.
1285 (Object::is_in_system_directory_): New data member.
1286 (Relobj::finalize_incremental_relocs): Add clear_counts parameter.
1287 (class Sized_relobj_base): New class.
1288 (class Sized_relobj): Derive from Sized_relobj_base.
1289 (class Sized_relobj::Symbols): Redeclare from base class.
1290 (class Sized_relobj::local_got_offset_list): Remove.
1291 (class Sized_relobj::Output_sections): Redeclare from base class.
1292 (class Sized_relobj::do_for_all_local_got_entries): New function.
1293 (class Sized_relobj::write_local_symbols): Add offset parameter.
1294 (class Sized_relobj::local_symbol_offset_): Update comment.
1295 (class Sized_relobj::local_dynsym_offset_): Update comment.
1296 * options.cc (Input_arguments::add_file): Remove const.
1297 * options.h (Input_file_argument::Input_file_argument):
1298 Initialize arg_serial_ (all constructors).
1299 (Input_file_argument::set_arg_serial): New function.
1300 (Input_file_argument::arg_serial): New function.
1301 (Input_file_argument::arg_serial_): New data member.
1302 (Input_arguments::Input_arguments): Initialize file_count_.
1303 (Input_arguments::add_file): Remove const.
1304 (Input_arguments::number_of_input_files): New function.
1305 (Input_arguments::file_count_): New data member.
1306 (Command_line::number_of_input_files): Call
1307 Input_arguments::number_of_input_files.
1308 * output.cc (Output_segment_headers::Output_segment_headers):
1310 (Output_section::Input_section::current_data_size): New function.
1311 (Output_section::Output_section): Initialize new data members.
1312 (Output_section::add_input_section): Don't do merge sections for
1313 an incremental link; allocate space from free list for an
1315 (Output_section::add_output_section_data): Allocate space from
1316 free list for an incremental update.
1317 (Output_section::update_data_size): New function.
1318 (Output_section::set_fixed_layout): New function.
1319 (Output_section::reserve): New function.
1320 (Output_segment::set_section_addresses): Remove const.
1321 (Output_segment::set_section_list_addresses): Remove const; allocate
1322 space from free list for an incremental update.
1323 (Output_segment::set_offset): Adjust size of RELRO segment for an
1325 * output.h (Output_data::current_data_size): Move here from
1327 (Output_data::pre_finalize_data_size): New function.
1328 (Output_data::update_data_size): New function.
1329 (Output_section_headers::update_data_size): new function.
1330 (Output_section_data_build::current_data_size): Move to Output_data.
1331 (Output_data_strtab::update_data_size): New function.
1332 (Output_section::current_data_size): Move to Output_data.
1333 (Output_section::set_fixed_layout): New function.
1334 (Output_section::has_fixed_layout): New function.
1335 (Output_section::reserve): New function.
1336 (Output_section::update_data_size): New function.
1337 (Output_section::has_fixed_layout_): New data member.
1338 (Output_section::free_list_): New data member.
1339 (Output_segment::set_section_addresses): Remove const.
1340 (Output_segment::set_section_list_addresses): Remove const.
1341 * plugin.cc (Sized_pluginobj::do_for_all_local_got_entries):
1343 * plugin.h (Sized_pluginobj::do_for_all_local_got_entries):
1345 * readsyms.cc (Read_symbols::do_read_symbols): Add library
1346 parameter when calling Add_symbols constructor; store argument
1347 serial number for members of a lib group.
1348 (Add_symbols::locks): Allow case where token == NULL.
1349 (Add_symbols::run): Report libraries denoted by --start-lib/--end-lib.
1350 (Read_member::~Read_member): New function.
1351 (Read_member::is_runnable): New function.
1352 (Read_member::locks): New function.
1353 (Read_member::run): New function.
1354 (Check_script::~Check_script): New function.
1355 (Check_script::is_runnable): New function.
1356 (Check_script::locks): New function.
1357 (Check_script::run): New function.
1358 (Check_library::~Check_library): New function.
1359 (Check_library::is_runnable): New function.
1360 (Check_library::locks): New function.
1361 (Check_library::run): New function.
1362 * readsyms.h (Add_symbols::Add_symbols): Add library parameter.
1363 (Add_symbols::library_): New data member.
1364 (class Read_member): New class.
1365 (class Check_script): New class.
1366 (class Check_library): New class.
1367 * reloc.cc (Read_relocs::is_runnable): Allow case where
1369 (Read_relocs::locks): Likewise.
1370 (Scan_relocs::locks): Likewise.
1371 (Relocate_task::locks): Likewise.
1372 (Sized_relobj::do_scan_relocs): Tell finalize_incremental_relocs
1374 (Sized_relobj::incremental_relocs_scan): Fix comment.
1375 (Sized_relobj::do_relocate): Pass output file offset to
1376 write_local_symbols.
1377 (Sized_relobj::incremental_relocs_write_reltype): Use reloc_size
1378 from class declaration.
1379 * script.cc (read_input_script): Allocate Script_info; pass
1380 argument serial number to report_script.
1381 * script.h (class Script_info): Move to incremental.h.
1382 * symtab.cc (Symbol_table::add_from_incrobj): New function.
1383 * symtab.h (Symbol_table::add_from_incrobj): New function.
1384 (Symbol_table::set_file_offset): New function.
1388 * incremental-dump.cc (dump_incremental_inputs): Change signature
1389 to take a Sized_incremental_binary; change caller. Use readers
1390 in Sized_incremental_binary.
1392 (Sized_incremental_binary::find_incremental_inputs_sections):
1393 Rename do_find_incremental_inputs_sections to this.
1394 (Sized_incremental_binary::setup_readers): New function.
1395 (Sized_incremental_binary::do_check_inputs): Check
1396 has_incremental_info_ flag; move setup code to setup_readers;
1398 (Sized_incremental_binary::do_file_is_unchanged): New function.
1399 (Sized_incremental_binary::do_get_input_reader): New function.
1400 * incremental.h (class Incremental_binary): Move to end of file.
1401 (Incremental_binary::file_is_unchanged): New function.
1402 (Incremental_binary::do_file_is_unchanged): New function.
1403 (Incremental_binary::Input_reader): New class.
1404 (Incremental_binary::get_input_reader): New function.
1405 (class Sized_incremental_binary): Move to end of file.
1406 (Sized_incremental_binary::Sized_incremental_binary): Setup the
1407 input section reader classes.
1408 (Sized_incremental_binary::has_incremental_info): New function.
1409 (Sized_incremental_binary::inputs_reader): New function.
1410 (Sized_incremental_binary::symtab_reader): New function.
1411 (Sized_incremental_binary::relocs_reader): New function.
1412 (Sized_incremental_binary::got_plt_reader): New function.
1413 (Sized_incremental_binary::do_file_is_unchanged): New function.
1414 (Sized_incremental_binary::Sized_input_reader): New class.
1415 (Sized_incremental_binary::get_input_reader): New function.
1416 (Sized_incremental_binary::find_incremental_inputs_sections):
1417 Rename do_find_incremental_inputs_sections to this.
1418 (Sized_incremental_binary::setup_readers): New function.
1419 (Sized_incremental_binary::has_incremental_info_): New data member.
1420 (Sized_incremental_binary::inputs_reader_): New data member.
1421 (Sized_incremental_binary::symtab_reader_): New data member.
1422 (Sized_incremental_binary::relocs_reader_): New data member.
1423 (Sized_incremental_binary::got_plt_reader_): New data member.
1424 (Sized_incremental_binary::current_input_file_): New data member.
1429 * dwarf_reader.cc (Sized_dwarf_line_info): Fix vector bounds
1434 * archive.cc (Archive::include_member): Adjust call to report_object.
1435 (Add_archive_symbols::run): Add script_info to call to
1436 report_archive_begin.
1437 (Lib_group::include_member): Adjust call to report_object.
1438 (Add_lib_group_symbols::run): Adjust call to report_object.
1439 * incremental-dump.cc (dump_incremental_inputs): Remove unnecessary
1440 blocks. Add object count for script input files.
1441 * incremental.cc (Incremental_inputs::report_archive_begin): Add
1442 script_info parameter; change all callers.
1443 (Incremental_inputs::report_object): Add script_info parameter;
1445 (Incremental_inputs::report_script): Store backpointer to
1446 incremental info entry.
1447 (Output_section_incremental_inputs::set_final_data_size): Record
1448 additional information for scripts.
1449 (Output_section_incremental_inputs::write_info_blocks): Likewise.
1450 * incremental.h (Incremental_script_entry::add_object): New function.
1451 (Incremental_script_entry::get_object_count): New function.
1452 (Incremental_script_entry::get_object): New function.
1453 (Incremental_script_entry::objects_): New data member; adjust
1455 (Incremental_inputs::report_archive_begin): Add script_info parameter.
1456 (Incremental_inputs::report_object): Add script_info parameter.
1457 (Incremental_inputs_reader::get_object_count): New function.
1458 (Incremental_inputs_reader::get_object_offset): New function.
1459 * options.cc (Input_arguments::add_file): Return reference to
1461 * options.h (Input_argument::set_script_info): New function.
1462 (Input_argument::script_info): New function.
1463 (Input_argument::script_info_): New data member; adjust all
1465 (Input_file_group::add_file): Return reference to new input argument.
1466 (Input_file_lib::add_file): Likewise.
1467 (Input_arguments::add_file): Likewise.
1468 * readsyms.cc (Add_symbols::run): Adjust call to report_object.
1469 * script.cc (Parser_closure::Parser_closure): Add script_info
1470 parameter; adjust all callers.
1471 (Parser_closure::script_info): New function.
1472 (Parser_closure::script_info_): New data member.
1473 (read_input_script): Report scripts earlier to incremental info.
1474 (script_add_file): Set script_info in Input_argument.
1475 (script_add_library): Likewise.
1476 * script.h (Script_options::Script_info): Rewrite class.
1480 * archive.cc (Library_base::should_include_member): Move
1481 method here from class Archive.
1482 (Archive::Archive): Initialize base class.
1483 (Archive::should_include_member): Move to base class.
1484 (Archive::do_for_all_unused_symbols): New function.
1485 (Add_archive_symbols::run): Remove redundant access to
1487 (Lib_group::Lib_group): Initialize base class.
1488 (Lib_group::do_filename): New function.
1489 (Lib_group::include_member): Pass pointer to Lib_group to
1491 (Lib_group::do_for_all_unused_symbols): New function.
1492 (Add_lib_group_symbols::run): Report archive information for
1494 * archive.h (class Library_base): New base class.
1495 (class Archive): Derive from Library_base.
1496 (Archive::filename): Move to base class.
1497 (Archive::set_incremental_info): Likewise.
1498 (Archive::incremental_info): Likewise.
1499 (Archive::Should_include): Likewise.
1500 (Archive::should_include_member): Likewise.
1501 (Archive::Armap_entry): Remove.
1502 (Archive::Unused_symbol_iterator): Remove.
1503 (Archive::unused_symbols_begin): Remove.
1504 (Archive::unused_symbols_end): Remove.
1505 (Archive::do_filename): New function.
1506 (Archive::do_get_mtime): New function.
1507 (Archive::do_for_all_unused_symbols): New function.
1508 (Archive::task_): Move to base class.
1509 (Archive::incremental_info_): Likewise.
1510 (class Lib_group): Derive from Library_base.
1511 (Lib_group::do_filename): New function.
1512 (Lib_group::do_get_mtime): New function.
1513 (Lib_group::do_for_all_unused_symbols): New function.
1514 (Lib_group::task_): Move to base class.
1515 * dynobj.cc (Sized_dynobj::do_for_all_global_symbols): New
1517 * dynobj.h (Sized_dynobj::do_for_all_global_symbols): New
1519 * incremental.cc (Incremental_inputs::report_archive_begin):
1520 Use Library_base; call library's get_mtime; add incremental inputs
1521 entry before members.
1522 (class Unused_symbol_visitor): New class.
1523 (Incremental_inputs::report_archive_end): Use Library_base; use
1524 visitor class to record unused symbols; don't add incremental inputs
1525 entry after members.
1526 (Incremental_inputs::report_object): Use Library_base.
1528 (Incremental_archive_entry::Incremental_archive_entry): Remove
1529 unused Archive parameter.
1530 (Incremental_inputs::report_archive_begin): Use Library_base.
1531 (Incremental_inputs::report_archive_end): Likewise.
1532 (Incremental_inputs::report_object): Likewise.
1533 * object.cc (Sized_relobj::do_for_all_global_symbols): New
1535 * object.h (Object::for_all_global_symbols): New function.
1536 (Object::do_for_all_global_symbols): New function.
1537 (Sized_relobj::do_for_all_global_symbols): New function.
1538 * plugin.cc (Sized_pluginobj::do_for_all_global_symbols): New
1540 * plugin.h (Sized_pluginobj::do_for_all_global_symbols): New
1545 * archive.cc (Archive::interpret_header): Return -1 if something
1546 goes wrong. Change callers accordingly.
1550 * testsuite/Makefile.am (final_layout.stdout): Use -n option with nm.
1551 * testsuite/Makefile.in: Regenerate.
1555 * plugin.cc (get_view): New.
1556 (Plugin::load): Pass get_view to the plugin.
1557 (Plugin_manager::get_view): New.
1561 * testsuite/final_layout.sh: Rewrite to not use dc.
1562 * testsuite/relro_test.sh: Fail if dc is not present.
1566 * testsuite/icf_safe_so_test.sh: Add #!/bin/sh to start.
1568 * testsuite/icf_string_merge_test.sh: Add #!/bin/sh to start.
1569 * testsuite/icf_safe_test.sh: Add #!/bin/sh to start.
1571 * testsuite/icf_sht_rel_addend_test.sh: Add #!/bin/sh to start.
1572 * testsuite/icf_preemptible_functions_test.sh: Add #!/bin/sh to start.
1576 * script-sections.cc (Sort_output_sections::script_compare):
1577 Rename from is_before, change return type.
1578 (Sort_output_sections::operator()): Adjust accordingly.
1583 * testsuite/odr_violation2.cc: Add comment to make all error line
1584 numbers double digits.
1585 * testsuite/debug_msg.sh: Adjust expected errors.
1589 * dwarf_reader.cc (Sized_dwarf_line_info): Include all lines,
1590 but mark earlier ones as non-canonical
1591 (offset_to_iterator): Update search target and example
1592 (do_addr2line): Return extra lines in a vector*
1593 (format_file_lineno): Extract from do_addr2line
1594 (one_addr2line): Add vector* out-param
1595 * dwarf_reader.h (Offset_to_lineno_entry): New field recording
1596 when a lineno entry appeared last for its instruction
1597 (Dwarf_line_info): Add vector* out-param
1598 * object.cc (Relocate_info): Pass NULL for the vector* out-param
1599 * symtab.cc (Odr_violation_compare): Include the lineno in the
1601 (linenos_from_loc): New. Combine the canonical line for an
1602 address with its other lines.
1603 (True_if_intersect): New. Helper functor to make
1604 std::set_intersection a query.
1605 (detect_odr_violations): Compare sets of lines instead of just
1606 one line for each function. This became less deterministic, but
1607 has fewer false positives.
1608 * symtab.h: Declarations.
1609 * testsuite/Makefile.am (odr_violation2.o): Compile with -O2 to
1610 mix an optimized and non-optimized object in the same binary
1611 (odr_violation2.so): Same.
1612 * testsuite/Makefile.in: Regenerate from Makefile.am.
1613 * testsuite/debug_msg.cc (main): Make OdrDerived classes.
1614 * testsuite/debug_msg.sh: Update line numbers and add
1616 * testsuite/odr_violation1.cc: Use OdrDerived, in a
1617 non-optimized context.
1618 * testsuite/odr_violation2.cc: Make sure Ordering::operator()
1619 isn't inlined, and use OdrDerived in an optimized context.
1620 * testsuite/odr_header1.h: Defines OdrDerived, where
1621 optimization will change the
1622 first-instruction-in-the-destructor's file and line number.
1623 * testsuite/odr_header2.h: Defines OdrBase.
1627 * fileread.cc (File_read::clear_views): Don't delete the whole
1633 * fileread.cc: #include <climits>.
1634 (GOLD_IOV_MAX): Define.
1635 (File_read::read_multiple): Limit number of entries by iov_max.
1636 * fileread.h (class File_read): Always set max_readv_entries to
1642 * options.h (class General_options): Add -dy and -dn.
1646 * testsuite/script_test_9.t: Add TLS segment.
1650 * configure.ac: Add check for gnu_indirect_function support in
1651 the toolchain building binutils.
1652 * configure: Rebuild.
1656 * symtab.cc (Symbol::should_add_dynsym_entry) Return false for
1657 plugin only symbols.
1658 (Symbol_table::sized_finalize_symbol) Mark symbol only present
1659 in plugin files as not needed in the symbol table.
1663 * output.cc (Output_section::add_input_section): Delay fill
1664 generation for section ordering.
1669 * object.h (class Sized_relobj): Remove clear_local_symbols.
1670 * reloc.cc (Sized_relobj::do_relocate): Don't call
1671 clear_local_symbols.
1675 * plugin.cc (is_visible_from_outside): Return true for symbols
1680 * symtab.cc (Odr_violation_compare::operator()): Sort by just the
1685 * icf.h (is_section_foldable_candidate): Change type of parameter
1687 * icf.cc (Icf::find_identical_sections): Change type of local variable
1688 section_name to be std::string.
1689 (is_function_ctor_or_dtor): Change type of parameter to std::string.
1693 * script.cc (script_add_extern): Rewrite to use
1694 add_symbol_reference.
1698 * icf.cc (get_section_contents): Always lock section's object.
1702 * options.h (class General_options): Accept
1703 --no-detect-odr-violations.
1707 * version.cc (version_string): Bump to 1.11.
1711 * plugin.cc (class Plugin_rescan): Define new class.
1712 (Plugin_manager::claim_file): Set any_claimed_.
1713 (Plugin_manager::save_archive): New function.
1714 (Plugin_manager::save_input_group): New function.
1715 (Plugin_manager::all_symbols_read): Create Plugin_rescan task if
1717 (Plugin_manager::new_undefined_symbol): New function.
1718 (Plugin_manager::rescan): New function.
1719 (Plugin_manager::rescannable_defines): New function.
1720 (Plugin_manager::add_input_file): Set any_added_.
1721 * plugin.h (class Plugin_manager): define new fields rescannable_,
1722 undefined_symbols_, any_claimed_, and any_added_. Declare
1723 Plugin_rescan as friend. Declare new functions.
1724 (Plugin_manager::Rescannable): Define type.
1725 (Plugin_manager::Rescannable_list): Define type.
1726 (Plugin_manager::Undefined_symbol_list): Define type.
1727 (Plugin_manager::Plugin_manager): Initialize new fields.
1728 * archive.cc (Archive::defines_symbol): New function.
1729 (Add_archive_symbols::run): Pass archive to plugins if any.
1730 * archive.h (class Archive): Declare defines_symbol.
1731 * readsyms.cc (Input_group::~Input_group): New function.
1732 (Finish_group::run): Pass input_group to plugins if any.
1733 * readsyms.h (class Input_group): Declare destructor.
1734 * symtab.cc (add_from_object): Pass undefined symbol to plugins if
1739 * layout.cc (Layout::layout_eh_frame): Mark a writable .eh_frame
1741 (Layout::set_segment_offsets): Reset increase_relro before calling
1742 set_section_addresses a second time.
1746 * script-sections.cc (Sort_output_sections::operator()): Sort TLS
1747 sections before NOBITS sections.
1751 * version.cc (print_version): Update copyright to 2011.
1755 * output.h (Output_data_reloc::add_output_section): Pass OD instead
1756 of OS to this->add. Add OD parameter to second form of the function.
1760 * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Only keep
1761 second of two consecutive entries with same offset.
1765 * testsuite/Makefile.am (ifuncmain2static_LDADD)
1766 (ifuncmain2_LDADD, ifuncmain4static_LDADD, ifuncmain4_LDADD)
1767 (ifuncmain7static_LDADD, ifuncmain7_LDADD): New empty variables,
1768 to avoid unneeded links against $(LDADD).
1769 * testsuite/Makefile.in: Regenerate.
1774 * x86_64.cc (Target_x86_64::Scan::check_non_pic): Give an error
1775 for R_X86_64_32 and R_X86_64_PC32.
1776 * testsuite/Makefile.am (ver_matching_def.so): Depend on and use
1777 ver_matching_def_pic.o.
1778 (ver_matching_def_pic.o): New target.
1782 * fileread.cc (file_counts_lock, file_counts_initialize_lock)
1783 (total_mapped_bytes, current_mapped_bytes, maximum_mapped_bytes):
1784 Move definition before File_read::View member definitions.
1785 (File_read::View::~View): Initialize and hold lock before
1786 updating current_mapped_bytes.
1790 * dwarf_reader.cc: Remove outdated comment.
1791 * gold-threads.cc: Fix typo in error message.
1792 * archive.cc: Fix typos in comments.
1793 * archive.h: Likewise.
1794 * arm-reloc-property.cc: Likewise.
1795 * arm-reloc-property.h: Likewise.
1796 * arm-reloc.def: Likewise.
1798 * attributes.h: Likewise.
1799 * cref.cc: Likewise.
1800 * ehframe.cc: Likewise.
1801 * fileread.h: Likewise.
1803 * i386.cc: Likewise.
1805 * incremental.h: Likewise.
1806 * int_encoding.cc: Likewise.
1807 * layout.h: Likewise.
1808 * main.cc: Likewise.
1809 * merge.h: Likewise.
1810 * object.cc: Likewise.
1811 * object.h: Likewise.
1812 * options.cc: Likewise.
1813 * readsyms.cc: Likewise.
1814 * reduced_debug_output.cc: Likewise.
1815 * reloc.cc: Likewise.
1816 * script-sections.cc: Likewise.
1817 * sparc.cc: Likewise.
1818 * symtab.h: Likewise.
1819 * target-reloc.h: Likewise.
1820 * target.cc: Likewise.
1821 * target.h: Likewise.
1822 * timer.cc: Likewise.
1823 * timer.h: Likewise.
1824 * x86_64.cc: Likewise.
1828 * layout.cc (Layout::layout_gnu_stack): Add warnings for executable
1830 * layout.h (Layout::layout_gnu_stack): Add pointer to Object
1831 parameter; change all callers.
1832 * object.cc (Sized_relobj::do_layout): Adjust call to layout_gnu_stack.
1833 * options.h (warn_execstack): New option.
1837 * arm.cc (Target_arm::Scan::get_reference_flags): Treat R_ARM_PREL31
1838 like function call relocations.
1842 * archive.cc (Archive::get_elf_object_for_member): Permit
1843 punconfigured to be NULL.
1844 (Archive::read_symbols): Pass NULL to get_elf_object_for_member.
1845 (Archive::include_member): Pass NULL to get_elf_object_for_member
1846 if we searched for the archive and this is the first included
1851 * dwarf_reader.h (class Sized_dwarf_line_info): Add
1852 track_relocs_type_ field.
1853 * dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info):
1854 Set track_relocs_type_.
1855 (Sized_dwarf_line_info::process_one_opcode): Ignore the section
1856 contents when using RELA relocs.
1857 (Sized_dwarf_line_info::read_relocs): Add the reloc addend to
1859 * reloc.cc (Track_relocs::next_addend): New function.
1860 * reloc.h (class Track_relocs): Declare next_addend.
1864 * testsuite/icf_virtual_function_folding_test.cc (class Bar): Add
1869 * README: Update compilers known to work and fail.
1873 * configure.in: For --enable-gold, handle value `default' instead of
1874 `both*'. Always install ld as ld.bfd, install as ld if gold is
1876 * configure: Regenerate.
1880 * expression.cc (BINARY_EXPRESSION): Initialize left_alignment
1881 and right_alignment to be zero. Store result alignment only if it is
1882 greater than existing alignment.
1887 * dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info):
1888 Check for ".zdebug_line".
1893 * output.h (Output_segment::set_section_addresses): Pass increase_relro
1894 by reference; adjust all callers.
1895 * output.cc (Output_segment::set_section_addresses): Adjust references
1896 to increase_relro. Add padding to *increase_relro when ORDER_RELRO_LAST
1898 (Output_segment::set_offset): Assert if PT_GNU_RELRO segment does not
1899 end at page boundary.
1904 * layout.cc (Layout::choose_output_section): Transform names of
1905 compressed sections even when using a script with a SECTIONS clause.
1906 (Layout::output_section_name): Remove code to transform
1907 compressed debug section names.
1908 * output.cc (Output_section::add_input_section): Use uncompressed
1909 section size when tracking input sections.
1913 * symtab.h (Symbol::NON_PIC_REF): Remove.
1914 (Symbol::RELATIVE_REF, Symbol::TLS_REF): New Reference_flags.
1915 (Symbol::FUNCTION_CALL): Renumber. Reword comment.
1916 (Symbol::needs_dynamic_reloc): Don't check NON_PIC_REF.
1917 (Symbol::use_plt_offset): Take a flags argument and pass it
1918 directly to needs_dynamic_reloc. Restrict check for undefined
1919 weak symbols to function calls.
1920 * arm.cc (Target_arm::Scan::get_reference_flags): New function.
1921 (Target_arm::Scan::global): Use it.
1922 (Target_arm::Scan::scan_reloc_for_stub): Likewise.
1923 (Target_arm::Relocate::relocate): Likewise.
1924 (Target_arm::Relocate::should_apply_static_reloc): Replace flags
1925 parameter with an r_type parameter. Use get_reference_flags
1927 (Target_arm::Relocate::relocate): Update accordingly.
1928 * i386.cc (Target_i386::Scan::get_reference_flags): New function.
1929 (Target_i386::Scan::reloc_needs_plt_for_ifunc): Use it.
1930 (Target_i386::Scan::global): Likewise.
1931 (Target_i386::Relocate::relocate): Likewise.
1932 (Target_i386::Relocate::should_apply_static_reloc): Replace flags
1933 parameter with an r_type parameter. Use get_reference_flags
1935 (Target_i386::Relocate::relocate): Update accordingly.
1936 * powerpc.cc (Target_powerpc::Scan::get_reference_flags): New function.
1937 (Target_powerpc::Scan::global): Use it.
1938 (Target_powerpc::Scan::scan_reloc_for_stub): Likewise.
1939 (Target_powerpc::Relocate::relocate): Likewise.
1940 * sparc.cc (Target_sparc::Scan::get_reference_flags): New function.
1941 (Target_sparc::Scan::global): Use it.
1942 (Target_sparc::Scan::scan_reloc_for_stub): Likewise.
1943 (Target_sparc::Relocate::relocate): Likewise.
1944 * x86_64.cc (Target_x86_64::Scan::get_reference_flags): New function.
1945 (Target_x86_64::Scan::reloc_needs_plt_for_ifunc): Use it.
1946 (Target_x86_64::Scan::global): Likewise.
1947 (Target_x86_64::Relocate::relocate): Likewise.
1952 * arm.cc (Arm_exidx_merge_section::build_contents): New method.
1953 (Arm_exidx_merge_section::section_contents_): New data member.
1954 (Arm_input_section::Arm_input_section): Initialize original_contents_.
1955 (Arm_input_section::~Arm_input_section): De-allocate memory.
1956 (Arm_input_section::original_contents_): New data member.
1957 (Arm_exidx_fixup::process_exidx_section): Pass EXIDX section contents
1958 in parameters instead of calling Object::section_contents without
1960 (Arm_output_section::group_section): New parameter TASK. Pass it
1961 to callees that need locking objects.
1962 (Arm_output_section::fix_exidx_coverage): New parameter TASK. Use it
1963 to lock EXIDX input sections. Fix a formatting issue. Call
1964 Arm_exidx_merged_section::build_contents to create merged section
1966 (Arm_output_section::create_stub_group): New parameter TASK. Use it
1967 to lock object of stub table owner.
1968 (Arm_exidx_input_section::Arm_exidx_input_section): Add new parameter
1969 TEXT_SIZE to initialize data member TEXT_SIZE_.
1970 (Arm_exidx_input_section::addralign): Fix typo in comment.
1971 (Arm_exidx_input_section::text_size): New method.
1972 (Target_arm::do_relax): New parameter TASK. Pass it to callees
1973 that require locking objects. Lock objects before scanning for stubs
1974 and updating local symbols.
1975 (Arm_input_section<big_endian>::init): Copy contents of original
1977 (Arm_input_section<big_endian>::do_write): Use saved contents of
1978 original input section instead of calling Object::section_contents
1980 (Arm_exidx_cantunwind::do_fixed_endian_write): Find out text section
1981 size without calling Object::section_size().
1982 (Arm_exidx_merged_section::Arm_exidx_merged_section): Add sanity check
1983 for size. Allocate a buffer for merged EXIDX entries.
1984 (Arm_exidx_merged_section::build_contents): New method.
1985 (Arm_exidx_merged_section::do_write): Move merge section contents
1986 building code to Arm_exidx_merged_section::build_contetns. Write
1987 out contetns in buffer instead of building it on the fly.
1988 (Arm_relobj::make_exidx_input_section): Also pass text section size
1989 to Arm_exidx_input_section constructor.
1990 (Arm_relobj::do_read_symbols): Fix memory leak. Fix a formatting issue.
1991 (Arm_dynobj::do_read_symbols): Fix memory leak.
1992 * layout.cc (Layout::finalize): Pass TASK to Target::relax().
1993 * target.h: (class Task): Add forward declaration.
1994 (Target::relax): Add new parameter TASK and pass it to
1996 (Target::do_relax):: New parameter TASK. Fix a formatting issue.
2001 * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Hold a lock on the
2002 object when reading from the file.
2003 * gold.cc (queue_middle_tasks): Hold a lock on the object when doing
2005 * icf.cc (preprocess_for_unique_sections): Hold a lock on the object
2006 when reading section contents.
2007 (get_section_contents): Likewise.
2008 (icf::find_identical_sections): Likewise.
2009 * mapfile.cc (Mapfile::print_discarded_sections): Hold a lock on the
2010 object when reading from the file.
2011 * plugin.cc (Plugin_manager::layout_deferred_objects): Hold a lock on
2012 the object when doing deferred section layout.
2017 * script.h (class Symbol_assignment: name): New member. Returns
2018 the name of the symbol.
2019 * scrfipt.cc (Script_options::is_pending_assignment): New member.
2020 Returns true if the given symbol name is on the list of
2021 assignments wating to be processed.
2022 * archive.cc (should_incldue_member): If the symbol is undefined,
2023 check to see if it is on the list of symbols pending assignment.
2027 * script-sections.cc (Script_sections::find_memory_region): Check
2028 for a NULL output section pointer.
2032 * arm.cc (Arm_outout_section::fix_exidx_coverage): Adjust call to
2033 Output_section::add_relaxed_input_section.
2034 * output.cc (Output_section::add_relaxed_input_section): Add new
2035 arguments LAYOUT and NAME. Set section order index.
2036 (Output_section::convert_input_sections_in_list_to_relaxed_sections):
2037 Copy section order index.
2038 * output.h (Output_section::add_relaxed_input_section): Add new
2039 arguments LAYOUT and NAME.
2043 * testsuite/Makefile.am: Move gcctestdir/ld rule to
2044 NATIVE_OR_CROSS_LINKER.
2045 * testsuite/Makefile.in: Regenerate.
2049 * arm.cc (Arm_relobj::do_read_symbols): Warn about ARM EXIDX sections
2050 without SHF_LINK_ORDER flags.
2051 * layout.cc (Layout::choose_output_section): Do not filter
2052 SHF_LINK_ORDER flag in a relocatable link.
2056 * output.h (Output_segment::set_section_addresses): Change function
2057 signature. Update all callers.
2058 * output.cc (Output_segment::is_first_section_relro): Ignore TLS
2060 (Output_segment::set_section_addresses): Align after last TLS
2061 section. Add padding before last relro section instead of after.
2065 * gold/arm.cc (Target_arm::got_section): Use correct order and set
2066 GOT output section to be writable.
2070 * debug.h (DEBUG_INCREMENTAL): New flag.
2071 (debug_string_to_enum): Add DEBUG_INCREMENTAL).
2072 * gold.cc (queue_initial_tasks): Check parameters for incremental link
2074 * incremental.cc (report_command_line): Ignore all forms of
2076 * layout.cc (Layout::Layout): Check parameters for incremental link
2078 * options.cc (General_options::parse_incremental): New function.
2079 (General_options::parse_no_incremental): New function.
2080 (General_options::parse_incremental_full): New function.
2081 (General_options::parse_incremental_update): New function.
2082 (General_options::incremental_mode_): New data member.
2083 (General_options::finalize): Check incremental_mode_.
2084 * options.h (General_options): Update help text for --incremental.
2085 Add --no-incremental, --incremental-full, --incremental-update.
2086 (General_options::Incremental_mode): New enum type.
2087 (General_options::incremental_mode): New function.
2088 (General_options::incremental_mode_): New data member.
2089 * parameters.cc (Parameters::incremental_mode_): New data member.
2090 (Parameters::set_options): Set incremental_mode_.
2091 (Parameters::set_incremental_full): New function.
2092 (Parameters::incremental): New function.
2093 (Parameters::incremental_update): New function.
2094 (set_parameters_incremental_full): New function.
2095 * parameters.h (Parameters::set_incremental_full): New function.
2096 (Parameters::incremental): New function.
2097 (Parameters::incremental_update): New function.
2098 (Parameters::incremental_mode_): New data member.
2099 (set_parameters_incremental_full): New function.
2100 * plugin.cc (Plugin_manager::add_input_file): Check parameters for
2101 incremental link mode.
2102 * reloc.cc (Sized_relobj::do_read_relocs): Likewise.
2103 (Sized_relobj::do_relocate_sections): Likewise.
2104 * testsuite/Makefile.am (incremental_test): Use --incremental-full
2106 * testsuite/Makefile.in: Regenerate.
2107 * testsuite/incremental_test.sh: Filter all forms of --incremental.
2111 * script-sections.h (class Script_sections): Make
2112 Sections_elements typedef public.
2113 * script-sections.cc (class Sort_output_sections): Add elements_
2114 field. Add constructor which sets it; change all callers.
2115 (Sort_output_sections::is_before): New function.
2116 (Sort_output_sections::operator()): Call is_before.
2117 * configure.ac (NATIVE_OR_CROSS_LINKER): New automake
2119 * testsuite/script_test_10.sh: New test. Test script section
2121 * testsuite/script_test_10.t: Likewise.
2122 * testsuite/script_test_10.s: Likewise.
2123 * testsuite/Makefile.am: Wrap the cross linker tests and the
2124 common tests into NATIVE_OR_CROSS_LINKER.
2125 (check_SCRIPTS): Add script_test_10.sh.
2126 (check_DATA): Add script_test_10.stdout.
2127 (script_test_10.o, script_test_10): New targets.
2128 (script_test_10.stdout): New target.
2129 * configure, testsuite/Makefile.in: Regenerate.
2133 * arm.cc (Target_arm::Scan::local): Report the unsupported reloc
2134 error for the deprecated relocations.
2135 (Target_arm::Scan::global): Likewise.
2136 (Target_arm::Relocate::relocate): Likewise.
2140 * fileread.cc (Input_file::find_file): Initialize *found_name
2141 and *namep when using the fallback search for case 4.
2145 * options.h (class General_options): Redefine -z lazy as an alias for
2146 the negation of -z now.
2150 * resolve.cc (symbol_to_bits): Report the value of the unsupported
2155 * script-sections.cc(class Memory_region): Remove
2156 current_lma_offset_ field. Rename current_vma_offset_ to
2157 current_offset_. Add last_section_ field.
2158 (Memory_region::get_current_vma_address): Rename to
2159 get_current_address.
2160 (Memory_region::get_current_lma_address): Delete.
2161 (Memory_region::increment_vma_offset): Rename to
2163 (Memory_region::increment_lma_offset): Delete.
2164 (Memory_region::attributes_compatible): New method. Returns
2165 true if the provided section is compatible with the region.
2166 (Memory_region::get_last_section): New method. Returns the last
2167 section to use the region.
2168 (Memory_region::set_last_section): New method. Stores the last
2169 section to use the region.
2170 (Script_sections::block_in_region): New method. Returns true if
2171 a block of memory is contained within a region.
2172 (Script_sections::find_memory_region): New method. Locates a
2173 memory region to be used to set a VMA or LMA address.
2174 (Output_section_definition::set_section_addresses): Add code to
2175 check for addresses set by memory regions.
2176 (Output_segment::set_section_addresses): Remove memory region
2178 (Script_sections::create_segment): Add a warning if a header
2179 segment is created outside of any region.
2180 * script-sections.h (class Script_sections): Add prototypes for
2181 find_memory_region and block_in_region methods.
2182 * testsuite/memory_test.s: Use .long instead of .word.
2183 * testsuite/memory_test.t: Add some more output sections.
2184 * testsuite/memory_test.sh: Update expected output.
2188 * symtab.cc (Symbol_table::Symbol_table_hash::operator()): Move
2189 defintion to symtab.h
2190 * symtab.h (Symbol_table::Symbol_table_hash::operator()): Change
2191 declaration to defintion.
2195 * expression.cc (eval): Replace dummy argument with NULL.
2196 (eval_maybe_dot): Check for a NULL result section pointer.
2197 (Symbol_expression::value): Likewise.
2198 (Dot_expression::value): Likewise.
2199 (BINARY_EXPRESSION): Likewise.
2200 (Max_expression::value): Likewise.
2201 (Min_expression::value): Likewise.
2202 (Absolute_expression::value): Likewise.
2203 (Addr_expression::value_from_output_section): Likewise.
2204 (Loaddddr_expression::value_from_output_section): Likewise.
2205 (Segment_start_expression::value): Likewise.
2206 * script-sections.cc
2207 (Sections_elememt_dot_assignment::finalize_symbols): Replace dummy
2209 (Sections_elememt_dot_assignment::set_section_addresses):
2211 (Output_data_expression::do_write_to_buffer): Likewise.
2212 (Output_section_definition::finalize_symbols): Likewise.
2213 (Output_section_definition::set_section_addresses): Likewise.
2217 * gold/testsuite/arm_branch_out_of_range.sh: Fix broken tests.
2221 * target.h (Target::can_icf_inline_merge_sections): New virtual
2223 * x86_64.cc (Target__x86_64::can_icf_inline_merge_sections): New
2225 * i386.cc (Target_i386::can_icf_inline_merge_sections): New
2227 * icf.cc (get_section_contents): Inline merge sections only when
2232 * configure: Regenerate.
2236 * testsuite/memory_test.sh: Adjust for change of 2010-09-10.
2237 * testsuite/Makefile.am (memory_test.o): New target.
2238 (memory_test): Depend on memory_test.o, gcctestdir/ld, and
2240 * testsuite/Makefile.in: Rebuild.
2244 * arm.cc (Target_arm::Relocate::relocate): Ignore symbol type and
2245 defintion if relocation uses GOT entries of the symbol.
2246 * testsuite/icf_safe_test.sh: Fix test.
2247 * testsuite/icf_safe_so_test.sh: Fix test.
2251 * script_sections.cc (class Memory_region): Remove "NULL" from
2252 vector initializations.
2256 * incremental.cc (Output_section_incremental_inputs::write_info_blocks):
2257 Resolve forwarding symbols.
2261 * gold/testsuite/script_test_3.t: Add ARM special sections.
2262 * gold/testsuite/script_test_4.t: Same.
2263 * gold/testsuite/script_test_5.t: Same.
2264 * gold/testsuite/script_test_6.t: Same.
2265 * gold/testsuite/script_test_7.t: Same.
2266 * gold/testsuite/script_test_7.t: Same.
2267 * gold/testsuite/thumb_blx_out_of_range.s: Fix instruction alignment.
2271 * x86_64.cc (Target_x86_64::saw_tls_block_reloc_): Remove member.
2272 (Target_x86_64::Relocate::relocate_tls): Replace check for
2273 saw_tls_block_reloc_ with test for executable section.
2277 * symtab.h (Symbol::needs_dynamic_reloc): Non-PIC calls from
2278 position-independent executables to shared libraries need dynamic
2280 (Symbol::may_need_copy_reloc): Do not generate COPY relocs in
2281 position-independent executables.
2282 * testsuite/Makefile.am (two_file_mixed_pie_test): New test.
2283 * testsuite/Makefile.in: Regenerate.
2288 * testsuite/memory_test.t: Discard any sections that are not
2294 * object.cc (Sized_relobj::do_finalize_local_symbols): Remove
2295 "This::" to work around a bug in gcc 4.2.
2297 * testsuite/ifuncmain7.c (foo_ifunc): Add __attribute__ ((used)).
2301 * layout.cc (Layout::attach_allocated_section_to_segment): Don't put
2302 sections with different PF_X flags in the same segment.
2303 (Layout::find_first_load_seg): Search all segments to find the first
2305 * options.h (rosegment): New.
2309 * layout.cc (Layout::set_segment_offsets): Always advance to a new page.
2313 * arm.cc (Arm_exidx_cantunwind::do_print_to_mapfile): New method.
2314 (Arm_relobj::do_relocate_sections): Add new parameter for output
2315 file to match the parent.
2316 (Target_arm::scan_reloc_section_for_stubs): Use would-be final values
2317 of local symbols instead of input values. Update code to track
2318 changes in gold::relocate_section.
2319 * object.cc (Sized_relobj::compute_final_local_value): New methods.
2320 (Sized_relobj::compute_final_local_value_internal): New methods.
2321 (Sized_relobj::do_finalize_local_symbols): Move code from loop
2322 body into private version of Sized_relobj::compute_final_local_value.
2323 Call the inline method.
2324 * object.h (Symbol_value::Symbol_value): Define destructor. Free
2325 merged symbol value if there is one.
2326 (Symbol_value::has_output_value): New method defintiion.
2327 (Sized_relobj::Compute_final_local_value_status): New enum type.
2328 (Sized_relobj::compute_final_local_value): New methods.
2329 (Sized_relobj::compute_final_local_value_internal): New methods.
2330 * Makefile.am (check_SCRIPTS): Add arm_branch_out_of_range.sh
2331 and arm_cortex_a8.sh.
2332 (thumb_bl_out_of_range_local, arm_cortex_a8_b_cond, arm_cortex_a8_bl,
2333 arm_cortex_a8_blx, arm_cortex_a8_local, arm_corte_a8_local_reloc):
2335 * Makefile.in: Regenerate.
2336 * testsuite/arm_bl_out_of_range.s: Update test.
2337 * testsuite/thumb_bl_out_of_range.s: Ditto.
2338 * testsuite/thumb_blx_out_of_range.s: Ditto.
2339 * testsuite/arm_branch_out_of_range.sh: New file.
2340 * testsuite/arm_cortex_a8.sh: Ditto.
2341 * testsuite/arm_cortex_a8_b.s: Ditto.
2342 * testsuite/arm_cortex_a8_b_cond.s: Ditto.
2343 * testsuite/arm_cortex_a8_b_local.s: Ditto.
2344 * testsuite/arm_cortex_a8_bl.s: Ditto.
2345 * testsuite/arm_cortex_a8_blx.s: Ditto.
2346 * testsuite/arm_cortex_a8_local.s: Ditto.
2347 * testsuite/arm_cortex_a8_local_reloc.s: Ditto.
2348 * testsuite/thumb_bl_out_of_range_local.s: Ditto.
2352 * Makefile.am (memory_test.stdout): Run readelf with -W.
2353 * Makefile.in: Regenerate.
2354 * testsuite/memory_test.sh: Make the regexps accept both 32 and
2359 * script-sections.cc (Script_sections::add_memory_region): Convert
2360 field precision to int.
2361 * script.cc (script_set_section_region, script_set_section_region):
2362 Convert field precision to int.
2366 * arm.cc (do_finalize_sections): Create the __exidx_start and
2367 __exdix_end symbols even when the section is missing.
2371 * README: Remove claim that MEMORY is not supported.
2372 * expression.cc (script_exp_function_origin)
2373 (script_exp_function_length): Move from here to ...
2374 * script.cc: ... here.
2375 (script_set_section_region, script_add_memory)
2376 (script_parse_memory_attr, script_include_directive): New
2378 * script-sections.cc
2379 (class Memory_region): New class.
2380 (class Output_section_definition): Add set_memory_region,
2381 set_section_vma, set_section_lma and get_section_name methods.
2382 (class Script_Sections): Add add_memory_region,
2383 find_memory_region, find_memory_region_origin,
2384 find_memory_region_length and set_memory_region methods.
2385 Have set_section_addresses method walk the list of set memory
2387 Extend the print methos to display memory regions.
2388 * script-sections.h: Add prototypes for new methods.
2389 Add enum for MEMORY region attributes.
2390 * yyscript.y: Add support for parsing MEMORY regions.
2391 * script-c.h: Add prototypes for new functions.
2392 * testsuite/Makefile.am: Add test of MEMORY region functionality.
2393 * testsuite/Makefile.in: Regenerate.
2394 * testsuite/memory_test.sh: New script.
2395 * testsuite/memory_test.s: New assembler source file.
2396 * testsuite/memory_test.t: New linker script.
2400 * gold/resolve.cc (Symbol_table::should_override): Let a weak
2401 reference override an existing dynamic weak reference.
2402 * testsuite/Makefile.am: Add new test dyn_weak_ref.
2403 * testsuite/Makefile.in: Regenerate.
2404 * testsuite/dyn_weak_ref.sh: New file.
2405 * testsuite/dyn_weak_ref_1.c: Ditto.
2406 * testsuite/dyn_weak_ref_2.c: Ditto.
2410 * incremental.h (class Incremental_input_entry): Add virtual
2415 * testsuite/start_lib_test_3.c: Mark t3 as used.
2419 * options.cc (version_script): Fix small typo in previous
2424 * archive.cc: Formatting fixes: Remove whitespace between
2425 typename and following asterisk. Remove whitespace between
2426 function name and opening parenthesis.
2427 * archive.h: Likewise.
2429 * attributes.cc: Likewise.
2430 * attributes.h: Likewise.
2431 * common.cc: Likewise.
2432 * copy-relocs.cc: Likewise.
2433 * dirsearch.h: Likewise.
2434 * dynobj.cc: Likewise.
2435 * ehframe.cc: Likewise.
2436 * ehframe.h: Likewise.
2437 * expression.cc: Likewise.
2438 * fileread.cc: Likewise.
2439 * fileread.h: Likewise.
2441 * gold-threads.cc: Likewise.
2442 * gold.cc: Likewise.
2443 * i386.cc: Likewise.
2445 * incremental-dump.cc: Likewise.
2446 * incremental.cc: Likewise.
2447 * layout.cc: Likewise.
2448 * layout.h: Likewise.
2449 * main.cc: Likewise.
2450 * merge.cc: Likewise.
2451 * merge.h: Likewise.
2452 * object.cc: Likewise.
2453 * object.h: Likewise.
2454 * options.cc: Likewise.
2455 * options.h: Likewise.
2456 * output.cc: Likewise.
2457 * output.h: Likewise.
2458 * plugin.cc: Likewise.
2459 * plugin.h: Likewise.
2460 * powerpc.cc: Likewise.
2461 * reloc.cc: Likewise.
2462 * script-c.h: Likewise.
2463 * script-sections.cc: Likewise.
2464 * script.cc: Likewise.
2465 * stringpool.cc: Likewise.
2466 * symtab.cc: Likewise.
2467 * symtab.h: Likewise.
2468 * target.cc: Likewise.
2469 * timer.cc: Likewise.
2470 * timer.h: Likewise.
2471 * version.cc: Likewise.
2472 * x86_64.cc: Likewise.
2477 * layout.cc (segment_precedes): Sort segments by their physical
2478 addresses, if they have been set.
2482 * archive.cc (Lib_group::add_symbols): Lock object before deleting its
2484 (Lib_group::include_member): Unlock object after deleting its
2486 * testsuite/start_lib_test_3.c: Remove all global symbols to trigger
2492 * gold/archive.h (Add_lib_group_symbols): Add readsyms_blocker_, adjust
2493 constructor, and set_blocker.
2494 * gold/archive.cc (Add_lib_group_symbols::is_runnable): Also check
2496 * gold/readsyms.cc (Read_symbols::do_lib_group): Also pass
2497 this->this_blocker_ to Add_lib_group_symbols::set_blocker.
2498 * testsuite/Makefile.am (start_lib_test): New test case.
2499 * testsuite/Makefile.in: Regenerate.
2500 * testsuite/start_lib_test_main.c: New file.
2501 * testsuite/start_lib_test_1.c: New file.
2502 * testsuite/start_lib_test_2.c: New file.
2503 * testsuite/start_lib_test_3.c: New file.
2507 * Makefile.in: Rebuild with automake 1.11.1.
2508 * aclocal.m4: Likewise.
2509 * testsuite/Makefile.in: Likewise.
2514 * i386.cc (class Output_data_plt_i386): Update declarations.
2515 Define Global_ifunc and Local_ifunc types. Add global_ifuncs_ and
2516 local_ifuncs_ fields.
2517 (Target_i386::do_plt_section_for_global): New function.
2518 (Target_i386::do_plt_section_for_local): New function.
2519 (Output_data_plt_i386::Output_data_plt_i386): Add symtab
2520 parameter; change all callers. Initialize global_ifuncs_ and
2521 local_ifuncs_. If doing a static link define __rel_iplt_start and
2523 (Output_data_plt_i386::add_entry): Handle IFUNC symbols.
2524 (Output_data_plt_i386::add_local_ifunc_entry): New function.
2525 (Output_data_plt_i386::do_write): Fix GOT entries for IFUNC
2527 (Target_i386::make_plt_section): New function, broken out of
2528 make_plt_entry. Set sh_info field of .rel.plt to point to .plt.
2529 (Target_i386::make_plt_entry): Call make_plt_section.
2530 (Target_i386::make_local_ifunc_plt_entry): New function.
2531 (Target_i386::Scan::reloc_needs_iplt_for_ifunc): New function.
2532 (Target_i386::Scan::local): Handle IFUNC symbols. Add
2533 R_386_IRELATIVE to switch.
2534 (Target_i386::Scan::global): Likewise.
2535 (Target_i386::Relocate::relocate): Likewise.
2536 (Target_i386::Relocatable_size_for_reloc): Add R_386_IRELATIVE to
2538 * x86_64.cc (class Output_data_plt_x86_64): Update declarations.
2539 (Target_x86_64::do_plt_section_for_global): New function.
2540 (Target_x86_64::do_plt_section_for_local): New function.
2541 (Output_data_plt_x86_64::Output_data_plt_x86_64): Add symtab
2542 parameter; change all callers. If doing a static link define
2543 __rela_iplt_start and __rela_iplt_end.
2544 (Output_data_plt_x86_64::add_entry): Handle IFUNC symbols.
2545 (Output_data_plt_x86_64::add_local_ifunc_entry): New function.
2546 (Target_x86_64::make_plt_section): Set sh_info field of .rel.plt
2548 (Target_x86_64::make_local_ifunc_plt_entry): New function.
2549 (Target_x86_64::Scan::check_non_pic): Add R_X86_64_IRELATIVE to
2551 (Target_x86_64::Scan::reloc_needs_iplt_for_ifunc): New function.
2552 (Target_x86_64::Scan::local): Handle IFUNC symbols. Add
2553 R_X86_64_IRELATIVE to switch.
2554 (Target_x86_64::Scan::global): Likewise.
2555 (Target_x86_64::Relocate::relocate): Likewise.
2556 (Target_x86_64::Relocatable_size_for_reloc): Add R_X86_64_IRELATIVE to
2558 * target.h (class Target): Add plt_section_for_global and
2559 plt_section_for_local functions. Add do_plt_section_for_global
2560 and do_plt_section_for_local virtual functions.
2561 * symtab.h (Symbol::needs_plt_entry): Handle IFUNC symbol. Add
2562 clarifying comments.
2563 (Symbol::use_plt_offset): Handle IFUNC symbol.
2564 * object.cc (Sized_relobj::Sized_relobj): Initialize
2566 (Sized_relobj::local_has_plt_offset): New function.
2567 (Sized_relobj::local_plt_offset): New function.
2568 (Sized_relobj::set_local_plt_offset): New function.
2569 (Sized_relobj::do_count): Handle IFUNC symbol.
2570 * object.h (class Symbol_value): Add is_ifunc_symbol_ field. Take
2571 a bit away from input_shndx_ field. Add set_is_func_symbol and
2572 is_ifunc_symbol functions.
2573 (class Sized_relobj): Update declarations. Remove Tls_got_entry
2574 and Local_tls_got_offsets. Define Local_plt_offsets. Add
2575 local_plt_offsets_ field.
2576 (Sized_relobj::clear_local_symbols): Clear local_plt_offsets_.
2577 * output.h (class Output_section_data): Add non-const
2578 output_section function.
2579 (class Output_data_got): Update declarations.
2580 (class Output_data_got::Got_entry): Add use_plt_offset_ field.
2581 Add use_plt_offset parameter to global and local constructors.
2582 Change all callers. Change local_sym_index_ field to 31 bits.
2583 Change GSYM_CODE and CONSTANT_CODE accordingly.
2584 * output.cc (Output_data_reloc_base::do_adjust_output_section): If
2585 doing a static link don't set sh_link field.
2586 (Output_data_got::Got_entry::write): Use PLT offset if
2588 (Output_data_got::add_global_plt): New function.
2589 (Output_data_got::add_local_plt): New function.
2590 * target-reloc.h (relocate_section): Handle IFUNC symbol.
2591 * defstd.cc (in_section): Remove entries for __rel_iplt_start,
2592 __rel_iplt_end, __rela_iplt_start, and __rela_iplt_end.
2593 * configure.ac: Set IFUNC automake conditional for glibc >= 2.11.
2594 * testsuite/Makefile.am: Add a bunch of IFUNC tests, all within
2596 * testsuite/ifunc-sel.h: New file.
2597 * testsuite/ifuncmain1.c: New file.
2598 * testsuite/ifuncmain1vis.c: New file.
2599 * testsuite/ifuncmod1.c: New file.
2600 * testsuite/ifuncdep2.c: New file.
2601 * testsuite/ifuncmain2.c: New file.
2602 * testsuite/ifuncmain3.c: New file.
2603 * testsuite/ifuncmod3.c: New file.
2604 * testsuite/ifuncmain4.c: New file.
2605 * testsuite/ifuncmain5.c: New file.
2606 * testsuite/ifuncmod5.c: New file.
2607 * testsuite/ifuncmain6pie.c: New file.
2608 * testsuite/ifuncmod6.c: New file.
2609 * testsuite/ifuncmain7.c: New file.
2610 * configure, testsuite/Makefile.in: Rebuild.
2615 (Output_section_incremental_inputs::write_input_files): Add cast
2616 to avoid signed/unsigned comparison warning.
2617 (Output_section_incremental_inputs::write_info_blocks): Likewise.
2621 * common.cc (Sort_commons::operator()): Remove unnecessary code.
2625 * testsuite/incremental_test_1.c: Add prototype to avoid warning.
2630 * resolve.cc (Symbol_table::should_override): When a weak dynamic
2631 defintion overrides non-weak undef, remember that the original undef
2633 * symtab.cc (Symbol_table::sized_write_global): For undef without
2634 an original weak binding, set binding to global in output.
2635 * testsuite/Makefile.am: Add new test strong_ref_weak_def.
2636 * testsuite/Makefile.in: Regenerate.
2637 * testsuite/strong_ref_weak_def.sh: New file.
2638 * testsuite/strong_ref_weak_def_1.c: Ditto.
2639 * testsuite/strong_ref_weak_def_2.c: Ditto.
2643 * testsuite/incremental_test.sh: Rewrite.
2644 * testsuite/incremental_test_1.c: Rewrite.
2645 * testsuite/incremental_test_2.c: Rewrite.
2649 * arm.cc (Target_arm::got_size): Add const.
2650 (Target_arm::got_entry_count): New function.
2651 (Target_arm::plt_entry_count): New function.
2652 (Target_arm::first_plt_entry_offset): New function.
2653 (Target_arm::plt_entry_size): New function.
2654 (Output_data_plt_arm::entry_count): New function.
2655 (Output_data_plt_arm::first_plt_entry_offset): New function.
2656 (Output_data_plt_arm::get_plt_entry_size): New function.
2657 * i386.cc (Target_i386::got_size): Add const.
2658 (Target_i386::got_entry_count): New function.
2659 (Target_i386::plt_entry_count): New function.
2660 (Target_i386::first_plt_entry_offset): New function.
2661 (Target_i386::plt_entry_size): New function.
2662 (Output_data_plt_i386::entry_count): New function.
2663 (Output_data_plt_i386::first_plt_entry_offset): New function.
2664 (Output_data_plt_i386::get_plt_entry_size): New function.
2665 * incremental-dump.cc (dump_incremental_inputs): Adjust call to
2666 find_incremental_inputs_sections. Dump incremental_got_plt section.
2667 * incremental.cc: Include target.h.
2668 (Sized_incremental_binary::do_find_incremental_inputs_sections): Add
2669 parameter. Adjust all callers. Find incremental_got_plt section.
2670 (Incremental_inputs::create_data_sections): Create incremental_got_plt
2672 (Output_section_incremental_inputs::set_final_data_size): Calculate
2673 size of incremental_got_plt section.
2674 (Output_section_incremental_inputs::do_write): Write the
2675 incremental_got_plt section.
2676 (Got_plt_view_info): New struct.
2677 (Local_got_offset_visitor): New class.
2678 (Global_got_offset_visitor): New class.
2679 (Global_symbol_visitor_got_plt): New class.
2680 (Output_section_incremental_inputs::write_got_plt): New function.
2681 * incremental.h (Incremental_binary::find_incremental_inputs_sections):
2682 Add parameter. Adjust all callers.
2683 (Incremental_binary::do_find_incremental_inputs_sections): Likewise.
2684 (Incremental_inputs::got_plt_section): New function.
2685 (Incremental_inputs::got_plt_section_): New data member.
2686 (Incremental_got_plt_reader): New class.
2687 * layout.cc (Layout::create_incremental_info_sections): Add the
2688 incremental_got_plt section.
2689 * object.h (Got_offset_list::get_list): New function.
2690 (Got offset_list::for_all_got_offsets): New function.
2691 (Sized_relobj::local_got_offset_list): New function.
2692 * powerpc.cc (Target_powerpc::got_size): Add const.
2693 (Target_powerpc::got_entry_count): New function.
2694 (Target_powerpc::plt_entry_count): New function.
2695 (Target_powerpc::first_plt_entry_offset): New function.
2696 (Target_powerpc::plt_entry_size): New function.
2697 (Output_data_plt_powerpc::entry_count): New function.
2698 (Output_data_plt_powerpc::first_plt_entry_offset): New function.
2699 (Output_data_plt_powerpc::get_plt_entry_size): New function.
2700 * sparc.cc (Target_sparc::got_size): Add const.
2701 (Target_sparc::got_entry_count): New function.
2702 (Target_sparc::plt_entry_count): New function.
2703 (Target_sparc::first_plt_entry_offset): New function.
2704 (Target_sparc::plt_entry_size): New function.
2705 (Output_data_plt_sparc::entry_count): New function.
2706 (Output_data_plt_sparc::first_plt_entry_offset): New function.
2707 (Output_data_plt_sparc::get_plt_entry_size): New function.
2708 * symtab.h (Symbol::got_offset_list): New function.
2709 (Symbol_table::for_all_symbols): New function.
2710 * target.h (Sized_target::got_entry_count): New function.
2711 (Sized_target::plt_entry_count): New function.
2712 (Sized_target::plt_entry_size): New function.
2713 * x86_64.cc (Target_x86_64::got_size): Add const.
2714 (Target_x86_64::got_entry_count): New function.
2715 (Target_x86_64::plt_entry_count): New function.
2716 (Target_x86_64::first_plt_entry_offset): New function.
2717 (Target_x86_64::plt_entry_size): New function.
2718 (Output_data_plt_x86_64::entry_count): New function.
2719 (Output_data_plt_x86_64::first_plt_entry_offset): New function.
2720 (Output_data_plt_x86_64::get_plt_entry_size): New function.
2724 * archive.cc: Include incremental.h.
2725 (Archive::Archive): Initialize incremental_info_.
2726 (Archive::include_member): Record archive members in incremental info.
2727 (Add_archive_symbols::run): Record begin and end of an archive in
2729 (Lib_group::include_member): Record objects in incremental info.
2730 * archive.h (Incremental_archive_entry): Forward declaration.
2731 (Archive::set_incremental_info): New member function.
2732 (Archive::incremental_info): New member function.
2733 (Archive::Unused_symbol_iterator): New class.
2734 (Archive::unused_symbols_begin): New member function.
2735 (Archive::unused_symbols_end): New member function.
2736 (Archive::incremental_info_): New data member.
2737 * incremental-dump.cc (find_input_containing_global): New function.
2738 (dump_incremental_inputs): Dump new incremental info sections.
2739 * incremental.cc: Include symtab.h.
2740 (Output_section_incremental_inputs): New class.
2741 (Sized_incremental_binary::do_find_incremental_inputs_sections): Support
2742 new incremental info sections.
2743 (Sized_incremental_binary::do_check_inputs): Likewise.
2744 (Incremental_inputs::report_archive): Remove.
2745 (Incremental_inputs::report_archive_begin): New function.
2746 (Incremental_inputs::report_archive_end): New function.
2747 (Incremental_inputs::report_object): New function.
2748 (Incremental_inputs::finalize_inputs): Remove.
2749 (Incremental_inputs::report_input_section): New function.
2750 (Incremental_inputs::report_script): Rewrite.
2751 (Incremental_inputs::finalize): Do nothing but finalize string table.
2752 (Incremental_inputs::create_incremental_inputs_section_data): Remove.
2753 (Incremental_inputs::sized_create_inputs_section_data): Remove.
2754 (Incremental_inputs::create_data_sections): New function.
2755 (Incremental_inputs::relocs_entsize): New function.
2756 (Output_section_incremental_inputs::set_final_data_size): New function.
2757 (Output_section_incremental_inputs::do_write): New function.
2758 (Output_section_incremental_inputs::write_header): New function.
2759 (Output_section_incremental_inputs::write_input_files): New function.
2760 (Output_section_incremental_inputs::write_info_blocks): New function.
2761 (Output_section_incremental_inputs::write_symtab): New function.
2762 * incremental.h (Incremental_script_entry): Forward declaration.
2763 (Incremental_object_entry): Forward declaration.
2764 (Incremental_archive_entry): Forward declaration.
2765 (Incremental_inputs): Forward declaration.
2766 (Incremental_inputs_header_data): Remove.
2767 (Incremental_inputs_header): Remove.
2768 (Incremental_inputs_header_write): Remove.
2769 (Incremental_inputs_entry_data): Remove.
2770 (Incremental_inputs_entry): Remove.
2771 (Incremental_inputs_entry_write): Remove.
2772 (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER.
2773 (Incremental_binary::find_incremental_inputs_sections): Add parameters.
2774 (Incremental_binary::do_find_incremental_inputs_sections): Likewise.
2775 (Sized_ncremental_binary::do_find_incremental_inputs_sections):
2777 (Incremental_input_entry): New class.
2778 (Incremental_script_entry): New class.
2779 (Incremental_object_entry): New class.
2780 (Incremental_archive_entry): New class.
2781 (Incremental_inputs::Incremental_inputs): Initialize new data members.
2782 (Incremental_inputs::report_inputs): Remove.
2783 (Incremental_inputs::report_archive): Remove.
2784 (Incremental_inputs::report_archive_begin): New function.
2785 (Incremental_inputs::report_archive_end): New function.
2786 (Incremental_inputs::report_object): Change prototype.
2787 (Incremental_inputs::report_input_section): New function.
2788 (Incremental_inputs::report_script): Change prototype.
2789 (Incremental_inputs::get_reloc_count): New function.
2790 (Incremental_inputs::set_reloc_count): New function.
2791 (Incremental_inputs::create_data_sections): New function.
2792 (Incremental_inputs::create_incremental_inputs_section_data): Remove.
2793 (Incremental_inputs::inputs_section): New function.
2794 (Incremental_inputs::symtab_section): New function.
2795 (Incremental_inputs::relocs_section): New function.
2796 (Incremental_inputs::get_stringpool): Add const.
2797 (Incremental_inputs::command_line): Add const.
2798 (Incremental_inputs::inputs): Remove.
2799 (Incremental_inputs::command_line_key): New function.
2800 (Incremental_inputs::input_file_count): New function.
2801 (Incremental_inputs::input_files): New function.
2802 (Incremental_inputs::relocs_entsize): New function.
2803 (Incremental_inputs::sized_create_inputs_section_data): Remove.
2804 (Incremental_inputs::finalize_inputs): Remove.
2805 (Incremental_inputs::Input_info): Remove.
2806 (Incremental_inputs::lock_): Remove.
2807 (Incremental_inputs::inputs_): Change type.
2808 (Incremental_inputs::inputs_map_): Remove.
2809 (Incremental_inputs::current_object_entry_): New data member.
2810 (Incremental_inputs::inputs_section_): New data member.
2811 (Incremental_inputs::symtab_section_): New data member.
2812 (Incremental_inputs::relocs_section_): New data member.
2813 (Incremental_inputs::reloc_count_): New data member.
2814 (Incremental_inputs_reader): New class.
2815 (Incremental_symtab_reader): New class.
2816 (Incremental_relocs_reader): New class.
2817 * layout.cc (Layout::finalize): Move finalization of incremental info
2818 and creation of incremental info sections to follow finalization of
2819 symbol table. Set offsets for postprocessing sections.
2820 (Layout::create_incremental_info_sections): Call
2821 Incremental_inputs::create_data_sections. Add incremental symtab
2822 and relocs sections. Set sh_entsize and sh_link fields. Arrange for
2823 sections to layout after input sections.
2824 * layout.h (struct Timespec): Forward declaration.
2825 (Layout::incremental_inputs): Add const.
2826 (Layout::create_incremental_info_sections): Add parameter.
2827 * main.cc (main): Remove call to Incremental_inputs::report_inputs.
2828 * object.cc: Include incremental.h.
2829 (Relobj::finalize_incremental_relocs): New function.
2830 (Sized_relobj::do_layout): Record input sections in incremental info.
2831 * object.h (Object::output_section): New function.
2832 (Object::output_section_offset): Moved from Relobj.
2833 (Object::get_incremental_reloc_base): New function.
2834 (Object::get_incremental_reloc_count): New function.
2835 (Object::do_output_section): New function.
2836 (Object::do_output_section_offset): Moved from Relobj.
2837 (Object::do_get_incremental_reloc_base): New function.
2838 (Object::do_get_incremental_reloc_count): New function.
2839 (Object::Object): Initialize new data members.
2840 (Relobj::output_section): Renamed do_output_section and moved to
2842 (Relobj::output_section_offset): Moved to Object.
2843 (Relobj::do_get_incremental_reloc_base): New function.
2844 (Relobj::do_get_incremental_reloc_count): New function.
2845 (Relobj::allocate_incremental_reloc_counts): New function.
2846 (Relobj::count_incremental_reloc): New function.
2847 (Relobj::finalize_incremental_relocs): New function.
2848 (Relobj::next_incremental_reloc_index): New function.
2849 (Relobj::reloc_counts_): New data member.
2850 (Relobj::reloc_bases_): New data member.
2851 (Sized_relobj::do_relocate_sections): Add parameter. Change caller.
2852 (Sized_relobj::relocate_sections): Add parameter. Change all callers.
2853 (Sized_relobj::incremental_relocs_scan): New function.
2854 (Sized_relobj::incremental_relocs_scan_reltype): New function.
2855 (Sized_relobj::incremental_relocs_write): New function.
2856 (Sized_relobj::incremental_relocs_write_reltype): New function.
2857 * plugin.cc (Plugin_manager::add_input_file): Rewrite test for
2859 * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of
2860 archives and object files elsewhere.
2861 (Add_symbols::run): Report object files here.
2862 (Finish_group::run): Report end of archive at end of group.
2863 * reloc.cc: Include layout.h, incremental.h.
2864 (Sized_relobj::do_read_relocs): Need relocations for incremental link.
2865 (Sized_relobj::do_scan_relocs): Record relocations for incremental link.
2866 (Sized_relobj::incremental_relocs_scan): New function.
2867 (Sized_relobj::incremental_relocs_scan_reltype): New function.
2868 (Sized_relobj::do_relocate_sections): Write incremental relocations.
2869 (Sized_relobj::incremental_relocs_write): New function.
2870 (Sized_relobj::incremental_relocs_write_reltype): New function.
2871 * script.cc (read_input_script): Rewrite test for incremental link.
2872 Change call to Incremental_inputs::report_script.
2873 * symtab.h (Symbol_table::first_global_index): New function.
2874 (Symbol_table::output_count): New function.
2878 * arm.cc (Target_arm::merge_object_attributes): Check command line
2879 options --no-wchar-size-warning and --no-enum-size-warning.
2880 * options.h (General_options): Add ld-compatible options
2881 --no-enum-size-warning and --no-wchar-size-warning.
2885 * x86_64.cc (Target_x86_64::Scan::local): Use
2886 R_X86_64_GNU_VTINHERIT instead of R_386_GNU_VTINHERIT and
2887 R_X86_64_GNU_VTENTRY instead of R_386_GNU_VTENTRY.
2888 (Target_x86_64::Scan::global): Likewise.
2889 (Target_x86_64::Relocate::relocate): Likewise.
2890 (Target_x86_64::Relocatable_size_for_reloc::get_size_for_reloc):
2895 * merge.cc (Output_merge_string::do_add_input_section): Count strings
2896 to reserve space in merged_strings vector. Keep total input size
2898 (Output_merge_string::do_print_merge_stats): Print total input size.
2899 * merge.h (Output_merge_string): Add input_size_ field.
2900 * stringpool.cc (Stringpool_template::string_length): Move
2901 implementations out of Stringpool_template class and place in
2903 * stringpool.h (string_length): Move out of Stringpool_template.
2908 * layout.cc (relaxation_loop_body): If address of load segment is
2909 set, adjust address to include headers if possible.
2913 * version.cc (version_string): Bump to 1.10.
2918 * layout.h (enum Output_section_order): Define.
2919 (class Layout): Update declarations.
2920 * layout.cc (Layout::get_output_section): Add order parameter.
2921 Remove is_interp, is_dynamic_linker_section, is_last_relro, and
2922 is_first_non_relro parameters. Change all callers.
2923 (Layout::choose_output_section): Likewise.
2924 (Layout::add_output_section_data): Likewise.
2925 (Layout::make_output_section): Likewise. Set order.
2926 (Layout::default_section_order): New function.
2927 (Layout::layout_eh_frame): Call add_output_section_to_nonload.
2928 * output.cc (Output_section::Output_section): Initialize order_.
2929 Don't initialize deleted fields.
2930 (Output_segment::Output_segment): Don't initialize deleted
2932 (Output_segment::add_output_section_to_load): New function
2933 replacing add_output_section. Change all callers to call this or
2934 add_output_section_to_nonload.
2935 (Output_segment::add_output_section_to_nonload): New function.
2936 (Output_segment::remove_output_section): Rewrite.
2937 (Output_segment::add_initial_output_data): Likewise.
2938 (Output_segment::has_any_data_sections): Likewise.
2939 (Output_segment::is_first_section_relro): Likewise.
2940 (Output_segment::maximum_alignment): Likewise.
2941 (Output_segment::has_dynamic_reloc): New function replacing
2942 dynamic_reloc_count. Change all callers.
2943 (Output_segment::has_dynamic_reloc_list): New function replacing
2944 dynamic_reloc_count_list. Change all callers.
2945 (Output_segment::set_section_addresses): Rewrite.
2946 (Output_segment::set_offset): Rewrite.
2947 (Output_segment::find_first_and_last_list): Remove.
2948 (Output_segment::set_tls_offsets): Rewrite.
2949 (Output_segment::first_section_load_address): Likewise.
2950 (Output_segment::output_section_count): Likewise.
2951 (Output_segment::section_with_lowest_load_address): Likewise.
2952 (Output_segment::write_section_headers): Likewise.
2953 (Output_segment::print_sections_to_map): Likewise.
2954 * output.h (class Output_data): Remove dynamic_reloc_count_
2955 field. Add has_dynamic_reloc_ field. Make bools into bitfields.
2956 (Output_data::add_dynamic_reloc): Rewrite.
2957 (Output_data::has_dynamic_reloc): New function.
2958 (Output_data::dynamic_reloc_count): Remove.
2959 (class Output_section): Add order_ field. Remvoe is_relro_local_,
2960 is_last_relro_, is_first_non_relro_, is_interp_,
2961 is_dynamic_linker_section_ fields. Add order and set_order
2962 functions. Remove is_relro_local, set_is_relro_local,
2963 is_last_relro, set_is_last_relro, is_first_non_relro,
2964 set_is_first_non_relro functions, is_interp, set_is_interp,
2965 is_dynamic_linker_section, and set_is_dynamic_linker_section
2967 (class Output_segment): Change Output_data_list from std::list to
2968 std:;vector. Add output_lists_ field. Remove output_data_ and
2969 output_bss_ fields. Update declarations.
2973 * arm.cc (Target_arm::gc_process_relocs): Use typename.
2974 * powerpc.cc (Target_powerpc::gc_process_relocs): Likewise.
2975 * sparc.cc (Target_sparc::gc_process_relocs): Likewise.
2980 * script.cc (Script_options::Script_options): Initialize
2981 symbol_definitions_ and symbol_references_.
2982 (Script_options::add_symbol_assignment): Update
2983 symbol_definitions_ and symbol_references_.
2984 (Script_options::add_symbol_reference): New function.
2985 (script_symbol): New function.
2986 * script.h (class Script_options): Add symbol_definitions_ and
2987 symbol_references_ fields.
2988 (Script_options::referenced_const_iterator): New type.
2989 (Script_options::referenced_begin): New function.
2990 (Script_options::referenced_end): New function.
2991 (Script_options::is_referenced): New function.
2992 (Script_options::any_unreferenced): New function.
2993 * script-c.h (script_symbol): Declare.
2994 * yyscript.y (exp): Call script_symbol.
2995 * symtab.cc: Include "script.h".
2996 (Symbol_table::gc_mark_undef_symbols): Add layout parameter.
2997 Change all callers. Check symbols referenced by scripts.
2998 (Symbol_table::add_undefined_symbols_from_command_line): Add
2999 layout parameter. Change all callers.
3000 (Symbol_table::do_add_undefined_symbols_from_command_line):
3001 Likewise. Break out loop body. Check symbols referenced by
3003 (Symbol_table::add_undefined_symbol_from_command_line): New
3004 function broken out of
3005 do_add_undefined_symbols_from_command_line.
3006 * symtab.h (class Symbol_table): Update declarations.
3007 * archive.cc: Include "layout.h".
3008 (Archive::should_include_member): Add layout parameter. Change
3009 all callers. Check for symbol mentioned in expression.
3010 * archive.h (class Archive): Update declaration.
3011 * object.cc (Sized_relobj::do_should_include_member): Add layout
3013 * object.h (Object::should_include_member): Add layout parameter.
3015 (Object::do_should_include_member): Add layout parameter.
3016 (class Sized_relobj): Update declaration.
3017 * dynobj.cc (Sized_dynobj::do_should_include_member): Add layout
3019 * dynobj.h (class Sized_dynobj): Update declaration.
3020 * plugin.cc (Sized_pluginobj::do_should_include_member): Add
3022 * plugin.h (class Sized_pluginobj): Update declaration.
3027 * output.cc (Output_segment::set_offset): Search for the first and
3028 last sections rather than assuming that the list is in order.
3029 (Output_segment::find_first_and_last_list): New function.
3030 * output.h (class Output_segment): Update declarations.
3031 * testsuite/Makefile.am (check_PROGRAMS): Add relro_strip_test.
3032 (relro_strip_test_SOURCES): New variable.
3033 (relro_strip_test_DEPENDENCIES): New variable.
3034 (relro_strip_test_LDFLAGS): New variable.
3035 (relro_strip_test_LDADD): New variable.
3036 (relro_strip_test.so): New target.
3040 * i386.cc (class Target_i386): Add got_tlsdesc_ field.
3041 (Target_i386::Target_i386):: Initialize got_tlsdesc_.
3042 (Target_i386::got_tlsdesc_section): New function.
3043 (Target_i386::got_section): Create space for GOT entries for
3044 TLSDESC relocations.
3045 (Target_i386::Scan::local): Use TLSDESC GOT for unoptimized
3047 (Target_i386::Scan::global): Likewise.
3048 (Target_i386::Relocate::relocate_tls): Adjust GOT offset when
3050 * x86_64.cc (class Target_x86_64): Add got_tlsdesc_ field.
3051 (Target_x86_64::Target_x86_64):: Initialize got_tlsdesc_.
3052 (Target_x86_64::got_tlsdesc_section): New function.
3053 (Target_x86_64::got_section): Create space for GOT entries for
3054 TLSDESC relocations.
3055 (Target_x86_64::Scan::local): Use TLSDESC GOT for unoptimized
3057 (Target_x86_64::Scan::global): Likewise.
3058 (Target_x86_64::Relocate::relocate_tls): Adjust GOT offset when
3063 * testsuite/final_layout.sh: Use dc to convert from hex to
3068 * arm.cc (Target_arm<big_endian>::gc_process_relocs): Add template
3069 paramter to the call to gold::gc_process_relocs.
3070 * i386.cc (Target_i386<big_endian>::gc_process_relocs): Add template
3071 paramter to the call to gold::gc_process_relocs.
3072 * x86_64.cc (Target_x86_64<big_endian>::gc_process_relocs): Add template
3073 parameter to the call to gold::gc_process_relocs.
3074 * powerpc.cc (Target_powerpc<big_endian>::gc_process_relocs): Add
3075 template parameter to the call to gold::gc_process_relocs.
3076 * sparc.cc (Target_sparc<big_endian>::gc_process_relocs): Add template
3077 paramter to the call to gold::gc_process_relocs.
3078 * gc.h (get_embedded_addend_size): New function.
3079 (gc_process_relocs): Save the size of the reloc for use by ICF.
3080 * icf.cc (get_section_contents): Get the addend from the text section
3081 for SHT_REL relocation sections.
3082 * icf.h (Icf::Reloc_addend_size_info): New typedef.
3083 (Icf::Reloc_info): Add new member reloc_addend_size_info.
3084 * int_encoding.h (read_from_pointer): New overloaded function.
3085 * testsuite/Makefile.am (icf_sht_rel_addend_test): New test.
3086 * testsuite/icf_sht_rel_addend_test.sh: New file.
3087 * testsuite/icf_sht_rel_addend_test_1.cc: New file.
3088 * testsuite/icf_sht_rel_addend_test_2.cc: New file.
3092 * configure.ac (AM_INIT_AUTOMAKE): Use parallel-tests option.
3093 * Makefile.in: Regenerate.
3094 * testsuite/Makefile.in: Regenerate.
3098 * testsuite/debug_msg.sh: Test mixed weak/strong symbol behavior.
3099 * gold/testsuite/debug_msg.cc: Likewise.
3100 * gold/testsuite/odr_violation1.cc
3101 * gold/testsuite/odr_violation2.cc
3105 * merge.h (Output_merge_string::Merged_string): Remove object, shndx,
3106 string, and length fields.
3107 (Output_merge_string::Merged_strings_list): New type.
3108 (Output_merge_string::Merged_strings_lists): New typedef.
3109 (Output_merge_string): Replace merged_strings_ with
3110 merged_strings_lists_.
3111 * merge.cc (Output_merge_string::do_add_input_section): Allocate new
3112 Merged_strings_list per input object and section. Don't store pointer
3113 to the string. Don't store length with each merged string entry.
3114 (Output_merge_string::finalize_merged_data): Loop over list of merged
3115 strings lists. Recompute length of each merged string.
3119 * plugin.cc (Plugin_finish::run): Don't call cleanup handlers from
3124 * descriptors.cc (Descriptors::open): Report correct name in error
3129 * arm.cc (Arm_input_section::Arm_input_section): For a
3130 SHT_ARM_EXIDX section, always keeps the input sections.
3131 (Arm_input_section::set_exidx_section_link): New method.
3132 (Arm_exidx_input_section::Arm_exidx_input_section): Initialize
3133 has_errors_ to false.
3134 (Arm_exidx_input_section::has_errors,
3135 Arm_exidx_input_section::set_has_errors): New methods.
3136 (Arm_exidx_input_section::has_errors_): New data member.
3137 (Arm_relobj::get_exidx_shndx_list): New method.
3138 (Arm_output_section::append_text_sections_to_list): Do not skip
3139 section without SHF_EXECINSTR.
3140 (Arm_output_section::fix_exidx_coverage): Skip input sections with
3142 (Arm_relobj::make_exidx_input_section): Add new parameter for text
3143 section header. Make error messages more verbose. Check for
3144 a non-executable section linked to an EXIDX section.
3145 (Arm_relobj::do_read_symbols): Remove error checking, which has been
3146 moved to Arm_relobj::make_exidx_input_section. Add an assertion to
3147 check that there is no deferred EXIDX section if we exit early.
3148 Instead of not making an EXIDX section in case of an error, make one
3149 and set the has_errors flag of it.
3150 (Target_arm::do_finalize_sections): Fix up links of EXIDX sections
3151 in a relocatable link.
3152 (Target_arm::do_relax): Look for the EXIDX output section instead of
3153 assuming that it is called .ARM.exidx.
3154 (Target_arm::fix_exidx_coverage): Add a new parameter for input
3155 section list. Do not check for SHF_EXECINSTR section flags but
3156 skip any input section with errors.
3157 * output.cc (Output_section::Output_section): Initialize
3158 always_keeps_input_sections_ to false.
3159 (Output_section::add_input_section): Check for
3160 always_keeps_input_sections_.
3161 * output.h (Output_section::always_keeps_input_sections,
3162 Output_section::set_always_keeps_input_sections): New methods.
3163 (Output_section::always_keeps_input_sections): New data member.
3167 * fileread.cc (try_extra_search_path, find_file): Move to Input_file.
3168 * fileread.h (Input_file): Add try_extra_search_path and find_file.
3173 * output.h (Output_section_lookup_maps::add_merge_section):
3174 Correct check of whether value was inserted.
3175 (Output_section_lookup_maps::add_merge_input_section): Likewise.
3176 (Output_section_lookup_maps::add_relaxed_input_section):
3178 * arm.cc (Target_arm::got_section): Remove used local os.
3179 * i386.cc (Target_i386::got_section): Likewise.
3180 * x86_64.cc (Target_x86_64::got_section): Likewise.
3181 * sparc.cc (Target_sparc::got_section): Likewise.
3182 (Target_sparc::relocate): Remove unused local have_got_offset.
3183 * powerpc.cc (Target_powerpc::relocate): Likewise.
3187 * compressed_output.cc (zlib_decompress): Fix signature in
3190 * archive.cc (Archive::include_member): Unlock an external member
3191 of a thin archive. Don't bother to delete an object we know is
3196 * compressed_output.cc (zlib_decompress): New function.
3197 (get_uncompressed_size): New function.
3198 (decompress_input_section): New function.
3199 * compressed_output.h (get_uncompressed_size): New function.
3200 (decompress_input_section): New function.
3201 * dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info)
3202 Handle compressed debug sections.
3203 * layout.cc (is_compressed_debug_section): New function.
3204 (Layout::output_section_name): Map compressed section names to
3206 * layout.h (is_compressed_debug_section): New function.
3207 (is_debug_info_section): Recognize compressed debug sections.
3208 * merge.cc: Include compressed_output.h.
3209 (Output_merge_data::do_add_input_section): Handle compressed
3211 (Output_merge_string::do_add_input_section): Handle compressed
3213 * object.cc: Include compressed_output.h.
3214 (Sized_relobj::Sized_relobj): Initialize new data members.
3215 (build_compressed_section_map): New function.
3216 (Sized_relobj::do_read_symbols): Handle compressed debug sections.
3217 * object.h (Object::section_is_compressed): New method.
3218 (Object::do_section_is_compressed): New method.
3219 (Sized_relobj::Compressed_section_map): New type.
3220 (Sized_relobj::do_section_is_compressed): New method.
3221 (Sized_relobj::compressed_sections_): New data member.
3222 * output.cc (Output_section::add_input_section): Handle compressed
3224 * reloc.cc: Include compressed_output.h.
3225 (Sized_relobj::write_sections): Handle compressed debug sections.
3229 * resolve.cc (Symbol_table::resolve): Remember whether undef was
3230 weak when resolving to a dynamic def.
3231 (Symbol_table::should_override): Add adjust_dyndef flag; set it
3232 for weak undef/dynamic def cases. Adjust callers.
3233 * symtab.cc (Symbol::init_fields): Initialize undef_binding_set_ and
3234 undef_binding_weak_.
3235 (Symbol_table::sized_write_globals): Adjust symbol binding.
3236 (Symbol_table::sized_write_symbol): Add binding parameter.
3237 * symtab.h (Symbol::set_undef_binding): New method.
3238 (Symbol::is_undef_binding_weak): New method.
3239 (Symbol::undef_binding_set_, Symbol::undef_binding_weak_): New members.
3240 (Symbol_table::should_override): Add new parameter.
3241 (Symbol_table::sized_write_symbol): Add new parameter.
3243 * testsuite/weak_undef_file1.cc: Add new test case.
3244 * testsuite/weak_undef_file2.cc: Fix header comment.
3245 * testsuite/weak_undef_test.cc: Add new test case.
3249 * arm-reloc-property.cc (Arm_reloc_property::Arm_reloc_property):
3250 Initialize USE_SYMBOL_.
3251 * arm-reloc-property.h (Arm_reloc_property::uses_symbol): New method
3253 (Arm_reloc_property::uses_symbol_): New data member declaration.
3254 * arm.cc (Target_arm::Relocate::relocate): Exit early if relocation
3255 uses symbol value and symbol is undefined but not weakly undefined.
3259 * plugin.cc (Plugin::load): Use dlerror.
3263 * symtab.cc (detect_odr_violations): When reporting an ODR
3264 violation, report an object where the symbol is defined.
3268 * arm.cc (Target_arm::can_check_for_functions_pointers): Return true.
3269 (Target_arm::section_may_have_icf_unsafe_pointers): New method
3271 (Target_arm::Scan::local_reloc_may_be_function_pointer,
3272 Target_arm::Scan::global_reloc_may_be_function_pointer): Implement
3273 target hook to detect function points.
3274 (Target_arm::Scan::possible_function_pointer_reloc): New method.
3275 * icf.h (Icf::check_section_for_function_pointers): Change type of
3276 parameter SECTION_NAME to const reference to std::string. Use
3277 target hook to determine if section may have unsafe pointers.
3278 * target.h (Target::section_may_have_icf_unsafe_pointers): New
3283 * fileread.cc (Input_file::find_fie): New
3284 (Input_file::open): Use Input_file::find_fie.
3285 * fileread.h (Input_file::find_fie): New
3286 * plugin.cc (set_extra_library_path): New.
3287 (Plugin::load): Add set_extra_library_path to the transfer vector.
3288 (Plugin_manager::set_extra_library_path): New.
3289 (Plugin_manager::add_input_file): Use the extra search path if set.
3290 (set_extra_library_path(): New.
3291 * plugin.h (Plugin_manager): Add set_extra_library_path and
3296 * layout.cc (gdb_sections): Add .debug_types.
3297 (lines_only_debug_sections): Likewise.
3301 * plugin.cc (add_input_file,add_input_library)
3302 (Plugin_manager::add_input_file): Make filename arguments const.
3303 * plugin.h (Plugin_manager::add_input_file): Make filename arguments
3308 * arm.cc (Target_arm::do_finalize_sections): Do not emit an
3309 .ARM.attributes section if we have not merged any input
3310 attributes sections.
3314 * arm.cc: Allow combining objects with no EABI version
3319 * plugin.cc (Plugin_hook::run): Set in_real_elf for the start symbol.
3323 * fileread.cc: Only #include <sys/uio.h> if HAVE_READV.
3324 (struct iovec): Correct !HAVE_READV definition.
3328 * object.cc (Sized_relobj::do_layout): Defer layout for reloc sections.
3329 (Sized_relobj::do_layout_deferred_sections): Do layout for deferred
3331 * object.h (Sized_relobj::deferred_layout_relocs_): New data member.
3334 * symtab.h (Symbol::is_placeholder): New member function.
3335 * target-reloc.h (relocate_section): Check for placeholder symbols.
3337 * testsuite/Makefile.am (plugin_test_8): New test.
3338 (plugin_test_9): New test.
3339 * testsuite/Makefile.in: Regenerate.
3343 * yyscript.y (input_list_element): Allow strings prefixed with
3344 the '-' character. Treat these as libraries.
3345 * script.cc (script_add_library): New function. Adds a library
3346 specified by "-l<name>" found in an input script.
3347 * script-c.h: Add prototype for script_add_library.
3351 * arm.cc (Target_arm::do_relax): Reserve more space for stubs.
3352 Restrict stub-group size to be within long conditional branch
3353 range when working around cortex-A8 erratum.
3357 * gold-threads.cc (Lock_impl_threads::Lock_impl_threads): Correct
3364 (Output_section::Input_section_sort_entry::compare_section_ordering):
3365 Change to return non-zero correctly.
3366 (Output_section::Input_section_sort_section_order_index_compare
3367 ::operator()): Change to fix ambiguity in comparisons.
3371 * gold.h (is_wildcard_string): New function.
3372 * layout.cc (Layout::layout): Pass this pointer to add_input_section.
3373 (Layout::layout_eh_frame): Ditto.
3374 (Layout::find_section_order_index): New method.
3375 (Layout::read_layout_from_file): New method.
3376 * layout.h (Layout::find_section_order_index): New method.
3377 (Layout::read_layout_from_file): New method.
3378 (Layout::input_section_position_): New private member.
3379 (Layout::input_section_glob_): New private member.
3380 * main.cc (main): Call read_layout_from_file here.
3381 * options.h (--section-ordering-file): New option.
3382 * output.cc (Output_section::input_section_order_specified_): New
3384 (Output_section::Output_section): Initialize new member.
3385 (Output_section::add_input_section): Add new parameter.
3386 Keep input sections when --section-ordering-file is used.
3387 (Output_section::set_final_data_size): Sort input sections when
3388 section ordering file is specified.
3389 (Output_section::Input_section_sort_entry): Add new parameter.
3391 (Output_section::Input_section_sort_entry::compare_section_ordering):
3393 (Output_section::Input_section_sort_compare::operator()): Change to
3394 consider section_order_index.
3395 (Output_section::Input_section_sort_init_fini_compare::operator()):
3396 Change to consider section_order_index.
3397 (Output_section::Input_section_sort_section_order_index_compare
3398 ::operator()): New method.
3399 (Output_section::sort_attached_input_sections): Change to sort
3400 according to section order when specified.
3401 (Output_section::add_input_section<32, true>): Add new parameter.
3402 (Output_section::add_input_section<64, true>): Add new parameter.
3403 (Output_section::add_input_section<32, false>): Add new parameter.
3404 (Output_section::add_input_section<64, false>): Add new parameter.
3405 * output.h (Output_section::add_input_section): Add new parameter.
3406 (Output_section::input_section_order_specified): New
3408 (Output_section::set_input_section_order_specified): New method.
3409 (Input_section::Input_section): Initialize section_order_index_.
3410 (Input_section::section_order_index): New method.
3411 (Input_section::set_section_order_index): New method.
3412 (Input_section::section_order_index_): New member.
3413 (Input_section::Input_section_sort_section_order_index_compare): New
3415 (Output_section::input_section_order_specified_): New member.
3416 * script-sections.cc (is_wildcard_string): Delete and move modified
3418 (Output_section_element_input::Output_section_element_input): Modify
3419 call to is_wildcard_string.
3420 (Output_section_element_input::Input_section_pattern
3421 ::Input_section_pattern): Ditto.
3422 (Output_section_element_input::Output_section_element_input): Ditto.
3423 * testsuite/Makefile.am (final_layout): New test case.
3424 * testsuite/Makefile.in: Regenerate.
3425 * testsuite/final_layout.cc: New file.
3426 * testsuite/final_layout.sh: New file.
3430 * plugin.cc (Plugin::load): Pass the output name to the plugin.
3434 * plugin.cc (Sized_pluginobj::::do_add_symbols): Correctly set the
3435 visibility of symbols.
3439 * object.cc (Sized_relobj::do_finalize_local_symbols): Use offset
3440 from start of output section instead of address for a local symbol
3441 in a merged or relaxed section when doing a relocatable link.
3446 * gold/object.cc(Sized_relobj::do_layout_deferred_sections): Avoid
3447 adding sections the garbage collector removed.
3448 * gold/testsuite/Makefile.am: Add test.
3449 * gold/testsuite/Makefile.in: Regenerate.
3450 * gold/testsuite/plugin_test_7.sh: New.
3451 * gold/testsuite/plugin_test_7_1.c: New.
3452 * gold/testsuite/plugin_test_7_2.c: New.
3456 * script-sections.cc (Output_section_definition::set_section_addresses):
3457 Check for --section-start.
3461 * arm.cc (Arm_scan_relocatable_relocs): New class.
3462 (Target_arm::relocate_special_relocatable): New method.
3463 (Arm_relocate_functions::arm_branch_common): Handle relocatable link.
3464 (Arm_relocate_functions::thumb_branch_common): Same.
3465 (Target_arm::scan_relocatable_relocs): Use Arm_scan_relocatable_relocs
3466 instead of Default_scan_relocatable_relocs.
3467 * target-reloc.h (relocate_for_relocatable): Let target handle
3468 relocation strategy Relocatable_relocs::RELOC_SPECIAL.
3469 * target.h (Sized_target::relocate_special_relocatable): New method.
3473 * timer.cc: Only #include <sys/times.h> if HAVE_TIMES is defined.
3477 * arm.cc (Arm_input_section::do_output_offset): Use convert_types
3479 (Target_arm::apply_cortex_a8_workaround): Rewrite a conditional branch
3480 with a direct branch, not a conditional branch, to a stub.
3481 * merge.cc (Output_merge_base::record_input_section): New method
3483 (Output_merge_data::do_add_input_section): Record input section if
3484 keeps-input-sections flag is set.
3485 (Output_merge_string::do_add_input_section): Ditto.
3486 * merge.h (Output_merge_base::Output_merge_base): Initialize new data
3487 members KEEPS_INPUT_SECTIONS_, FIRST_RELOBJ_, FIRST_SHNDX_ and
3489 (Output_merge_base::keeps_input_sections,
3490 Output_merge_base::set_keeps_input_sections,
3491 Output_merge_base::first_relobj, Output_merge_base::first_shndx): New
3493 (Output_merge_base::Input_sections): New type declaration.
3494 (Output_merge_base::input_sections_begin,
3495 Output_merge_base::input_sections_end,
3496 Output_merge_base::do_set_keeps_input_sections): New method definitions.
3497 (Output_merge_base::bool keeps_input_sections_,
3498 Output_merge_base::first_relobj_, Output_merge_base::first_shndx_,
3499 Output_merge_base::input_sections_): New data members.
3500 (Output_merge_data::do_set_keeps_input_sections): New method
3502 (Output_merge_string::do_set_keeps_input_sections): Ditto.
3503 * output.cc (Output_section::Input_section::relobj): Move method
3504 defintion from class declaration to here and handle merge sections.
3505 (Output_section::Input_section::shndx): Ditto.
3506 (Output_section::Output_section): Remove initializations of removed
3507 data members and initialize new data member LOOKUP_MAPS_.
3508 (Output_section::add_input_section): Set keeps-input-sections flag
3509 for a newly created merge output section as appropriate. Adjust code
3510 to use Output_section_lookup_maps class.
3511 (Output_section::add_relaxed_input_section): Adjst code for lookup
3512 maps code refactoring.
3513 (Output_section::add_merge_input_section): Add a new parameter
3514 KEEPS_INPUT_SECTION. Adjust code to use Output_section_lookup_maps
3515 class. If adding input section to a newly created merge output
3516 section fails, remove the new merge section.
3517 (Output_section::convert_input_sections_in_list_to_relaxed_input_sections):
3518 Adjust code for use of the Output_section_lookup_maps class.
3519 (Output_section::find_merge_section): Ditto.
3520 (Output_section::build_lookup_maps): New method defintion.
3521 (Output_section::find_relaxed_input_section): Adjust code to use
3522 Output_section_lookup_maps class.
3523 (Output_section::get_input_sections): Export merge sections. Adjust
3524 code to use Output_section_lookup_maps class.
3525 (Output_section:::add_script_input_section): Adjust code to use
3526 Output_section_lookup_maps class. Update lookup maps for merge
3528 (Output_section::discard_states): Use Output_section_lookup_maps.
3529 (Output_section::restore_states): Same.
3530 * output.h (Merge_section_properties): Move class defintion out of
3532 (Output_section_lookup_maps): New class.
3533 (Output_section::Input_section::is_merge_section): New method
3535 (Output_section::Input_section::relobj): Move defintion out of class
3536 defintion. Declare method only.
3537 (Output_section::Input_section::shndx): Ditto.
3538 (Output_section::Input_section::output_merge_base): New method defintion.
3539 (Output_section::Input_section::u2_.pomb): New union field.
3540 (Output_section::Merge_section_by_properties_map,
3541 Output_section::Output_section_data_by_input_section_map,
3542 Output_section::Ouptut_relaxed_input_section_by_input_section_map):
3544 (Output_section::add_merge_input_section): Add new parameter
3545 KEEPS_INPUT_SECTIONS.
3546 (Output_section::build_lookup_maps): New method declaration.
3547 (Output_section::merge_section_map_,
3548 Output_section::merge_section_by_properties_map_,
3549 Output_section::relaxed_input_section_map_,
3550 Output_section::is_relaxed_input_section_map_valid_): Remove data
3552 (Output_section::lookup_maps_): New data member.
3557 * arm.cc (Arm_input_section::do_output_offset): Add a cast to
3558 avoid a compilation error.
3562 * script-sections.cc (Output_section_definition::allocate_to_segment):
3563 Update the phdrs_list even when the output section is NULL.
3564 * testsuite/Makefile.am: Add test.
3565 * testsuite/Makefile.in: Regenerate.
3566 * testsuite/script_test_9.cc: New.
3567 * testsuite/script_test_9.sh: New.
3568 * testsuite/script_test_9.t: New.
3572 * arm.cc (Arm_input_section::original_size): New method.
3573 (Arm_input_section::do_addralign): Add a cast.
3574 (Arm_input_section::do_output_offset): Remove static cast.
3575 (Arm_input_section::original_addralign,
3576 Arm_input_section::original_size_): Change type to uint32_t.
3577 (Arm_input_section::init): Add safe casts for section alignment
3579 (Arm_input_section::set_final_data_size): Do not set address and
3580 offset of stub table.
3581 (Arm_output_section::fix_exidx_coverage): Change use of of
3582 Output_section::Simple_input_section to that of
3583 Output_section::Input_section.
3584 (Target_arm::do_relax): Set addresses and file offsets of Stub_tables
3585 except for the first pass.
3586 * output.cc (Output_section::get_input_sections): Change type of
3587 input_sections to std::list<Input_section>.
3588 (Output_section::add_script_input_section): Rename from
3589 Output_section::add_simple_input_section. Change type of SIS
3590 parameter from Simple_input_section to Input_section.
3591 * output.h (Output_section::Simple_input_section): Remove class.
3592 (Output_section::Input_section): Change class visibility to public.
3593 (Output_section::Input_section::addralign): Use stored alignments
3594 for special input sections if set.
3595 (Output_section::Input_section::set_addralign): New method.
3596 (Output_section::get_input_sections): Change parameter type from
3597 list of Simple_input_section to list of Input_section.
3598 (Output_section::add_script_input_section): Rename from
3599 Output_section::add_simple_input_section. Change first parameter's
3600 type from Simple_input_section to Input_section and remove the
3601 second and third parameters.
3602 * script-sections.cc (Input_section::Input_section_list): Change
3603 type to list of Output_section::Input_section/
3604 (Input_section_info::Input_section_info): Change parameter type of
3605 INPUT_SECTION to Output_section::Input_section.
3606 (Input_section_info::input_section): Change return type.
3607 (Input_section_info::input_section_): Change type to
3608 Output_section::Input_section.
3609 (Output_section_element_input::set_section_addresses): Adjust code
3610 to use Output_section::Input_section instead of
3611 Output_section::Simple_input_section. Adjust code for renaming
3612 of Output_section::add_simple_input_section.
3613 (Orphan_output_section::set_section_addresses): Ditto.
3617 * gold.h (Unordered_multimap, Unordered_map): Fix defines for
3618 when neither HAVE_TR1_UNORDERED_MAP nor HAVE_EXT_HASH_MAP are set.
3622 * options.cc (General_options::finalize): Handle -nostdlib.
3623 * options.h (nostdlib): New option.
3624 * script.cc (script_add_search_dir): Handle -nostdlib.
3628 * arm.cc (Target_arm::do_finalize_sections): Create an empty
3629 attributes section only if there no attributes section after merging.
3630 (Target_arm::merge_object_attributes): Move value of
3631 Tag_MPextension_use_legacy to that of Tag_MPextension_use.
3632 Handle Tag_DIV_use and Tag_MPextension_use_legacy.
3633 * testsuite/Makefile.am (check_SCRIPTS): Add arm_attr_merge.sh
3634 (check_DATA): Add arm_attr_merge_6.stdout, arm_attr_merge_6r_stdout
3635 and arm_attr_merge_7.stdout.
3636 (arm_attr_merge_6.stdout, arm_attr_merge_6 arm_attr_merge_6a.o
3637 arm_attr_merge_6b.o, arm_attr_merge_6r.stdout, arm_attr_merge_6r,
3638 arm_attr_merge_7.stdout, arm_attr_merge_7, arm_attr_merge_7a.o,
3639 arm_attr_merge_7b.o): New rules.
3640 (MOSTLYCLEANFILES): Add arm_attr_merge_6, arm_attr_merge_6r and
3642 * testsuite/Makefile.in: Regenerate.
3643 * testsuite/arm_attr_merge.sh: New file.
3644 * testsuite/arm_attr_merge_[67][ab].s: Same.
3648 * po/es.po: Updated Spanish translation.
3652 * Makefile.am (install-exec-local): Properly install gold as
3653 default cross linker.
3654 * Makefile.in: Regenerated.
3659 * configure.ac (install_as_default): Define and set to false
3660 unless --enable-gold or --enable-gold=both/gold has been
3662 * configure: Regenerate.
3664 * Makefile.am (install-exec-local): Install the executable as
3665 'ld.gold'. If install_as_default is true then also install it as
3667 * Makefile.in: Regenerated.
3671 * layout.cc (Layout::layout_reloc): In relocatable link don't
3672 combine reloc sections for grouped sections.
3676 * gc.h (gc_process_relocs): Pass information on relocs pointing to
3677 sections that are not ordinary to icf.
3678 * icf.cc (get_section_contents): Handle relocation pointing to section
3679 with no object or shndx information.
3680 * testsuite/Makefile.am: Remove icf_virtual_function_folding_test.sh
3681 * testsuite/Makefile.in: Regenerate.
3682 * testsuite/icf_virtual_function_folding_test.cc: Remove printf.
3683 * testsuite/icf_virtual_function_folding_test.sh: Delete file.
3687 * expression.cc (Expression::Expression_eval_info): Add
3688 result_alignment_pointer field.
3689 (Expression::eval_with_dot): Add result_alignment_pointer
3690 parameter. Change all callers.
3691 (Expression::eval_maybe_dot): Likewise.
3692 (class Binary_expression): Add alignment_pointer parameter to
3693 left_value and right_value. Change all callers.
3694 (BINARY_EXPRESSION): Set result alignment.
3695 (class Trinary_expression): Add alignment_pointer parameter to
3696 arg2_value and arg3_value. Change all callers.
3697 (Trinary_cond::value): Set result alignment.
3698 (Max_expression::value, Min_expression::value): Likewise.
3699 (Align_expression::value): Likewise.
3700 * script-sections.cc (class Sections_element): Add dot_alignment
3701 parameter to set_section_addresses virtual function. Update
3703 (class Output_section_element): Likewise.
3704 (Script_sections::create_segments): Add dot_alignment parameter.
3706 (Script_sections::create_segments_from_phdrs_clause): Likewise.
3707 (Script_sections::set_phdrs_clause_addresses): Likewise.
3708 * script-sections.h: Update declarations.
3709 * script.h: Update declarations.
3710 * output.h (Output_segment::set_minimum_p_align): Don't decrease
3712 * testsuite/script_test_3.t: Set large alignment.
3713 * testsuite/script_test_3.sh: Make sure that at least one LOAD
3714 segment has expected alignment.
3718 * po/gold.pot: Updated by the Translation project.
3719 * po/vi.po: Updated Vietnamese translation.
3723 * testsuite/Makefile.am (check_PROGRAMS): Add
3724 icf_virtual_function_folding_test.
3725 * testsuite/Makefile.in: Regenerated.
3729 * options.h (merge_exidx_entries): New option.
3730 * arm.cc (class Arm_exidx_fixup): Add new arg, merge_exidx_entries.
3731 (class Arm_exidx_fixup::merge_exidx_entries_): New member.
3732 (Output_section::fix_exidx_coverage): Add new arg, merge_exidx_entries.
3733 (Target_arm::merge_exidx_entries): New function.
3734 (process_exidx_entry): Don't merge if merge_exidx_entries_ is false.
3735 (Arm_output_section::fix_exidx_coverage): Pass merge_exidx_entries
3736 to Arm_exidx_fixup constructor.
3737 Add new arg, merge_exidx_entries.
3738 (Target_arm::fix_exidx_coverage): pass merge_exidx_entries to
3739 Arm_output_section::fix_exidx_coverage.
3743 * icf.cc (get_section_contents): Check for preemptible functions.
3744 Ignore addend when appropriate.
3745 * symtab.cc (should_add_dynsym_entry): Add new parameter. Check for
3747 (add_from_relobj): Check for section folded.
3748 (set_dynsym_indexes): Fix call to should_add_dynsym_entry.
3749 * symtab.h (should_add_dynsym_entry): Add new parameter.
3750 * target-reloc.h (scan_relocs): Check for section folded.
3751 * x86_64.cc (Target_x86_64::Scan::possible_function_pointer_reloc):
3752 Check reloc types for function pointers in shared objects.
3753 * testsuite/Makefile.am (icf_virtual_function_folding_test): New test
3755 (icf_preemptible_functions_test): New test case.
3756 (icf_string_merge_test): New test case.
3757 * testsuite.Makefile.in: Regenerate.
3758 * testsuite/icf_safe_so_test.sh: Change to not fold foo_glob and
3759 bar_glob. Refactor code.
3760 * testsuite/icf_preemptible_functions_test.cc: New file.
3761 * testsuite/icf_preemptible_functions_test.sh: New file.
3762 * testsuite/icf_string_merge_test.cc: New file.
3763 * testsuite/icf_string_merge_test.sh: New file.
3764 * testsuite/icf_virtual_function_folding_test.cc: New file.
3765 * testsuite/icf_virtual_function_folding_test.sh: New file.
3769 * arm.cc (Arm_output_section::fix_exidx_coverage): Mark object
3770 for local symbol recounting if we remove a section due to ICF.
3771 * gold.cc (queue_middle_gc_tasks): Create a dummy blocker if
3772 there are no regular objects in input.
3776 * arm.cc (Arm_input_section::set_final_data_size): Compute
3777 accurate final data size instead of using current data size.
3781 * layout.cc (Layout::choose_output_section): Handle script section
3783 (Layout::make_output_section_for_script): Add section type parameter.
3784 Handle script section types.
3785 * layout.h (Layout::make_output_section_for_script): Add section
3787 * output.cc (Output_section::Output_section): Initialize data member
3789 (Output_section::do_reset_address_and_file_offset): Do not set address
3790 to 0 if section is a NOLOAD section.
3791 * output.h (Output_section::is_noload): New method.
3792 (Output_section::set_is_noload): Ditto.
3793 (Output_section::is_noload_): New data member.
3794 * script-c.h (Script_section_type): New enum type.
3795 (struct Parser_output_section_header): Add new file section_type.
3796 * script-sections.cc (Sections_element::output_section_name): Add
3797 parameter for returning script section type.
3798 (Output_section_definition::output_section_name): Ditto.
3799 (Output_section_definition::section_type)P; New method.
3800 (Output_section_definiton::script_section_type_name): Ditto.
3801 (Output_section_definition::script_section_type_): New data member.
3802 (Output_section_definition::Output_section_definition): Initialize
3803 data member Output_section_definition::script_section_type_.
3804 (Output_section_definition::create_sections): Pass script section type
3805 to Layout::make_output_section_for_script.
3806 (Output_section_definition::output_section_name): Return script
3807 section type to caller.
3808 (Output_section_definition::set_section_address): Do not advance
3809 dot value and load address if section type is NOLOAD. Set address
3810 of NOLOAD sections regardless of section flags.
3811 (Output_section_definition::print): Print section type if it is
3812 not SCRIPT_SECTION_TYPE_NONE.
3813 (Output_section_definition::section_type): New method.
3814 (Output_section_definition::script_section_type_name): Ditto.
3815 (Script_sections::output_section_name): Add new parameter
3816 PSECTION_TYPE for returning script section type. Pass it to
3817 section elements. Handle discard sections.
3818 (Sort_output_sections::operator()): Handle NOLOAD sections.
3819 * script-sections.h (Script_sections::Section_type): New enum type.
3820 (Script_sections::output_section_name): Add a new parameter for
3821 returning script section type.
3822 * script.cc (script_keyword_parsecodes): Add keywords COPY, DSECT,
3824 * yyscript.y (union): Add new field SECTION_TYPE.
3825 (COPY, DSECT, INFO, NOLOAD): New tokens.
3826 (opt_address_and_section_type): Change type to output_section_header.
3827 (section_type): New non-terminal
3828 (section_header): Handle section type.
3829 (opt_address_and_section_type): Return section type value.
3833 * testsuite/plugin_common_test_1.c (foo): Add prototype.
3834 * testsuite/plugin_common_test_2.c (foo): Likewise.
3838 * merge.cc (Output_merge_data::set_final_data_size): Handle empty
3840 * output.cc (Output_section::add_merge_input_section): Simplify
3841 code and return status of Output_merge_base::add_input_section.
3842 Update merge section map only if Output_merge_base::add_input_section
3847 * arm.cc (Arm_relobj::scan_section_for_cortex_a8_erratum): Warn
3848 if section is marked as containing instructions but has no mapping
3850 (Arm_relobj::do_count_local_symbols): Call adjust_sym_shndx to get
3851 correct section index.
3852 (Arm_relobj::find_linked_text_section): Ditto.
3856 * archive.cc (include_member): Destroy Read_symbols_data object before
3858 * object.cc (Read_symbols_data::~Read_symbols_data) New destructor.
3859 * object.h (Read_symbols_data::Read_symbols_data) New constructor.
3860 (Read_symbols_data::~Read_symbols_data) New destructor.
3861 (Section_relocs::Section_relocs) New constructor.
3862 (Section_relocs::~Section_relocs) New destructor.
3863 (Read_relocs_data::Read_relocs_data) New constructor.
3864 (Read_relocs_data::~Read_relocs_data) New destructor.
3865 * testsuite/binary_unittest.cc (Sized_binary_test): Set sd member
3866 pointers to NULL after deleting.
3870 * arm.cc: Replace "endianity" with "endianness" in comments.
3871 (Arm_exidx_cantunwind): Ditto.
3872 (Arm_relobj::Arm_relobj): Initialize merge_flags_and_attribures.
3873 (Arm_relobj::merge_flags_and_attributes): New method.
3874 (Arm_relobj::merge_flags_and_attributes_): New data member.
3875 (Arm_exidx_cantunwind::do_fixed_endian_write): Fix formatting.
3876 (Arm_relobj::scan_sections_for_stubs): Ditto.
3877 (Arm_relobj::do_read_symbols): Check to see if we really want to
3878 merge processor-specific flags and attributes. Exit early if
3879 an object is empty except for section names and the undefined symbol.
3880 (Target_arm::do_finalize_sections): Move check for ELF format to
3881 Arm_relobj::do_read_symbols. Merge processor specific flags and
3882 attributes from a regular object only when we have determined that
3883 it is aapropriate. Do not create an .ARM.attributes section in
3884 output if there is no regular input object.
3885 (Target_arm::merge_processor_specific_flags): Check
3886 --warn-mismatch before printing any error.
3887 (Target_arm::merge_object_attributes): Ditto.
3888 * gold.cc (queue_middle_tasks): Handle the case in which there is
3889 no regular object in input.
3890 * options.cc (General_options::parse_EB): New method.
3891 (General_options::parse_EL): Same.
3892 (General_options::General_options): Initialize endianness_.
3893 * options.h (-EB, -EL, -no-pipeline-knowledge, -p, --warn-mismatch):
3895 (General_options::Endianness): New enum.
3896 (General_options::endianness): New method.
3897 (General_options::endianness_): New data member.
3898 * parameters.cc (Parameters::set_options): Check target endianness.
3899 (Parameters::set_target_once): Ditto.
3900 (Parameters::check_target_endianness): New method.
3901 (parameters_force_valid_target): If either -EL or -EB is specified,
3902 use it to define endianness of default target.
3903 * parameters.h (Parameters::check_target_endianness): New method
3905 * target.h (class Target): Change "endianity" to "endianness"
3910 * configure.ac (AM_INIT_AUTOMAKE): Add option no-dist.
3911 * configure: Regenerate.
3912 * Makefile.in: Regenerate.
3913 * testsuite/Makefile.in: Regenerate.
3918 * plugin.cc (Pluginobj::get_symbol_resolution_info): Check for
3919 prevailing definitions of common symbols.
3920 * testsuite/plugin_test_6.sh: New test case.
3921 * testsuite/plugin_common_test_1.c: New test case.
3922 * testsuite/plugin_common_test_2.c: New test case.
3923 * testsuite/Makefile.am (plugin_test_6): New test case.
3924 * testsuite/Makefile.in: Regenerate.
3928 * po/vi.po: New Vietnamese translation.
3932 * arm.cc (Target_arm::using_thumb_only): Handle v6-M
3936 * gold/arm.cc (Arm_exidx_fixup::update_offset_map): Rearrange code
3937 to avoid a conversion warning on a 32-bit host.
3941 * testsuite/script_test_3.t: Add a TLS segment.
3942 * testsuite/Makefile.am (check_PROGRAMS): Add
3943 tls_phdrs_script_test.
3944 (tls_phdrs_script_test_SOURCES): Define.
3945 (tls_phdrs_script_test_DEPENDENCIES): Define.
3946 (tls_phdrs_script_test_LDFLAGS): Define.
3947 (tls_phdrs_script_test_LDADD): Define.
3948 * testsuite/Makefile.in: Rebuild.
3952 * fileread.cc (find_or_make_view): Fix comment.
3956 * script-sections.cc (class Orphan_section_placement): Define
3957 PLACE_TLS and PLACE_TLS_BSS.
3958 (Orphan_section_placement::Orphan_section_placement): Initialize
3960 (Orphan_section_placement::find_place): Handle SHF_TLS sections.
3961 * testsuite/Makefile.am (check_PROGRAMS): Add tls_script_test.
3962 (tls_script_test_SOURCES): Define.
3963 (tls_script_test_DEPENDENCIES): Define.
3964 (tls_script_test_LDFLAGS): Define.
3965 (tls_script_test_LDADD): Define.
3966 * testsuite/Makefile.in: Rebuild.
3970 * arm.cc (Arm_relocate_functions::abs8,
3971 Arm_relocate_functions::abs16): Use correct check for overflow
3972 specified in the ARM ELF specs.
3973 (Arm_relocate_functions): thumb_branch_common. Handle bit 1 of branch
3974 target of a BLX instruction specially.
3975 (Reloc_stub::stub_type_for_reloc): Ditto.
3976 (Relocate::relocate): Use symbolic names instead of numeric relocation
3977 codes to report error.
3978 (Target_arm::do_relox): Reduce default stub-group size for Cortex-A8
3980 * testsuite/Makefile.am (check_DATA): add thumb_blx_in_range.stdout,
3981 thumb_blx_out_of_range.stdout, thumb2_blx_in_range.stdout and
3982 thumb2_blx_out_of_range.stdout
3983 (thumb_bl_out_of_range, thumb_bl_out_of_range.o,
3984 thumb2_bl_out_of_range, thumb2_bl_out_of_range.o): Fix dependenices.
3985 (thumb_blx_in_range.stdout, thumb_blx_in_range, thumb_blx_in_range.o,
3986 thumb_blx_out_of_range.stdout, thumb_blx_out_of_range,
3987 thumb_blx_out_of_range.o, thumb2_blx_in_range.stdout,
3988 thumb2_blx_in_range, thumb2_blx_in_range.o,
3989 thumb2_blx_out_of_range.stdout, thumb2_blx_out_of_range,
3990 thumb2_blx_out_of_range.o): New rules.
3991 (MOSTLYCLEANFILES): Add thumb_blx_in_range, thumb_blx_out_of_range,
3992 thumb2_blx_in_range and thumb2_blx_out_of_range.
3993 * testsuite/Makefile.in: Regenerate.
3994 * arm_branch_in_range.sh: Add tests for THUMB BLX.
3995 * testsuite/thumb_blx_in_range.s: New file.
3996 * testsuite/thumb_blx_out_of_range.s: New file.
4000 * archive.cc (Should_include): Move to archive.h.
4001 (should_include_member): Make it a member of Archive.
4003 (Add_lib_group_symbols): New.
4004 * archive.h: Include options.h.
4005 (Archive_member): Moved from Archive.
4006 (Should_include): Moved from archive.cc.
4008 (Add_lib_group_symbols): New.
4009 * dynobj.cc (do_should_include_member): New.
4010 * dynobj.h (do_should_include_member): New.
4011 * gold.cc (queue_initial_tasks): Update call to queue.
4012 * main.cc (main): Print lib group stats.
4013 * object.cc (do_should_include_member): New.
4014 * object.h: Include archive.h.
4015 (Object::should_include_member): New.
4016 (Object::do_should_include_member): New.
4017 (Sized_relobj::do_should_include_member): New.
4018 * options.cc (General_options::parse_start_lib): New.
4019 (General_options::parse_end_lib): New.
4020 (Input_arguments::add_file): Handle lib groups.
4021 (Input_arguments::start_group): Check we are not in a lib.
4022 (Input_arguments::start_lib): New.
4023 (Input_arguments::end_lib): New.
4024 * options.h (General_options): Add start_lib and end_lib.
4025 (Input_argument::lib_): New.
4026 (Input_argument::lib): New.
4027 (Input_argument::is_lib): New.
4028 (Input_file_lib): New.
4029 (Input_arguments::in_lib_): New.
4030 (Input_arguments::in_lib): New.
4031 (Input_arguments::start_lib): New.
4032 (Input_arguments::end_lib_): New.
4033 * plugin.cc (Pluginobj::get_symbol_resolution_info): Mark symbols
4034 in unused members as preempted.
4035 (Sized_pluginobj::do_should_include_member): New.
4036 * plugin.h (Sized_pluginobj::do_should_include_member): New.
4037 * readsyms.cc (Read_symbols::locks): If we are just reading a member,
4039 (Read_symbols::do_whole_lib_group): New.
4040 (Read_symbols::do_lib_group): New.
4041 (Read_symbols::do_read_symbols): Handle lib groups.
4042 (Read_symbols::get_name): Handle lib groups.
4043 * readsyms.h (Read_symbols): Add an archive member pointer.
4044 (Read_symbols::do_whole_lib_group): New.
4045 (Read_symbols::do_lib_group): New.
4046 (Read_symbols::member_): New.
4047 * script.cc (read_input_script): Update call to queue_soon.
4051 * arm.cc (Stub_table::Stub_table): Initialize new data members
4052 Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_.
4053 (Stub_table::add_reloc_stub): Assign stub offset and update
4054 Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_.
4055 (Stub_table::reloc_stubs_size_, Stub_table::reloc_stubs_addralign_):
4057 (Stub_table::update_data_size_and_addralign): Use
4058 Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_
4059 instead of going over all reloc stubs.
4060 (Stub_table::finalize_stubs): Do not assign reloc stub offsets.
4061 * stringpool.cc (Stringpool_template::Stringpool_template): Initialize
4062 Stringpool_template::offset_ to size of Stringpool_char.
4063 (Stringpool_template::new_key_offset): Remove code to initialize
4064 Stringpool_template::offset_.
4065 * stringpool.h (Stringpool_template::set_no_zero_null): Set
4066 Stringpool_template::offset_ to zero.
4070 * stringpool.cc (Stringpool_template::Stringpool_template): Initialize
4072 (Stringpool_template::new_key_offset): New method.
4073 (Stringpool_template::add_string): Assign offsets when adding new
4075 (Stringpool_template::set_string_offsets): Do not set string offsets
4076 when not optimizing.
4077 * stringpool.h (Chunked_vector::Chunked_vector): Initialize data
4079 (Chunked_vector::clear): Clear size_.
4080 (Chunked_vector::reserve): Call reserve method of all Element_vectors.
4081 (Chunked_vector::size): Return size_.
4082 (Chunked_vector::push_back): Use size_ to find insert position.
4083 (Chunked_vector::size_): New data member.
4084 (Stringpool_template::set_no_zero_null): Assert string set is empty.
4085 (Stringpool_template::new_key_offset): New method declaration.
4086 (Stringpool_template::offset_): New data member.
4090 * readsyms.cc (Read_symbols::do_read_symbols): Update calls to
4091 Add_symbols' constructor.
4092 * readsyms.h (Add_symbols): Remove the input_group member.
4096 * reloc.cc (Sized_relobj::split_stack_adjust_reltype): Call the
4097 target to ask whether a reference to a symbol requires a stack
4099 * target.h (Target::is_call_to_non_split): New function.
4100 (Target::do_is_call_to_non_split): Declare virtual function.
4101 * target.cc: Include "symtab.h".
4102 (Target::do_is_call_to_non_split): New function.
4103 * i386.cc (Target_i386::do_is_call_to_non_split): New function.
4107 * fileread.cc (File_read::~File_read): Don't delete whole_file_view_.
4108 (File_read::open[1]): Remove initial mapping of whole_file_view_.
4109 (File_read::open[2]): Add whole_file_view_ to list of views.
4110 (File_read::make_view): Remove test of whole_file_view_.
4111 (File_read::find_or_make_view): Create whole_file_view_ if
4113 (File_read::clear_views): Replace bool parameter with enum;
4114 adjust all callers. Don't delete views with permanent data;
4115 do delete cached views and views from archives if
4116 --no-keep-files-mapped is set. Set whole_file_view_ to NULL
4117 if clearing the corresponding view.
4118 * fileread.h (File_read::Clear_views_mode): New enum.
4119 (File_read::View::is_permanent_view): New method.
4120 (File_read::clear_views): Replace bool parameter
4121 with enum; adjust all callers.
4122 * options.h (General_options): Change keep_files_mapped option;
4123 add map_whole_files.
4124 * readsyms.cc (Add_symbols::run): Delete sd_ object before
4126 * reloc.cc (Scan_relocs::run): Delete rd_ object before releasing
4131 * sparc.cc (Target_sparc::Scan::local): Accept R_SPARC_WPLT30.
4135 * icf.cc (get_section_contents): Add '@' marker after processing the
4140 * gold/arm.cc (Arm_exidx_fixup::update_offset_map): Fix build breakage
4141 due to a conversion warning.
4142 (Arm_relobj::update_output_local_symbol_count): Check for local
4143 symbol with unset output index.
4147 * options.h (class General_options): Add --spare-dynamic-tags.
4148 * output.cc (Output_data_dynamic::set_final_data_size): Implement
4149 --spare-dynamic-tags.
4153 * incremental.cc: Include "libiberty.h".
4157 * dynobj.h (Verdef::Verdef): Add is_info arg, is_info member
4158 function, is_info_ member.
4159 * dynobj.cc (Verdef::write): Set VER_FLG_INFO if this->is_info_.
4160 (Versions::Versions): Update caller.
4161 (Versions::define_base_version): Likewise.
4162 (Versions::add_def): Likewise.
4166 * i386.cc (Target_i386::can_check_for_function_pointers): New function.
4167 (Scan::possible_function_pointer_reloc): New function.
4168 (Scan::local_reloc_may_be_function_pointer): Change to call
4169 possible_function_pointer_reloc.
4170 (Scan::global_reloc_may_be_function_pointer): Ditto.
4171 * icf.h (Icf::check_section_for_function_pointers): Change to reject
4172 relocations in ".data.rel.ro._ZTV" section.
4173 * testsuite/icf_safe_so_test.sh: Change to pass i386.
4174 * testsuite/icf_safe_so_test.cc: Ditto.
4175 * testsuite/icf_safe_test.cc: Ditto.
4176 * testsuite/icf_safe_test.sh: Ditto.
4181 * target-reloc.h (relocate_section): Check the symbol table index
4182 for -1U before setting the local symbol index.
4183 (scan_relocatable_relocs): If copying the relocation, record that
4184 the local symbol is required.
4185 * object.h (Symbol_value::is_output_symtab_index_set): New
4187 (Symbol_value::may_be_discarded_from_output_symtab): New
4189 (Symbol_value::has_output_symtab_entry): New function.
4190 (Symbol_value::needs_output_symtab_entry): Remove.
4191 (Symbol_value::output_symtab_index): Make sure the symbol index is
4193 (Symbol_value::set_output_symtab_index): Make sure the symbol
4194 index is not set. Make sure the new index is valid.
4195 (Symbol_value::set_must_have_output_symtab_entry): New function.
4196 (Symbol_value::has_output_dynsym_entry): New function.
4197 (Symbol_value::set_output_dynsym_index): Make sure the new index
4199 (Sized_relobj::set_must_have_output_symtab_entry): New function.
4200 * object.cc (Sized_relobj::do_count_local_symbols): Only discard a
4201 local symbol if permitted.
4202 (Sized_relobj::do_finalize_local_symbols): Call
4203 is_output_symtab_index_set rather than needs_output_symtab_entry.
4204 (Sized_relobj::write_local_symbols): Call has_output_symtab_entry
4205 rather than needs_output_symtab_entry. Call
4206 has_output_dynsym_entry rather than needs_output_dynsym_entry.
4207 * arm.cc (Arm_relobj::update_output_local_symbol_count): Call
4208 is_output_symtab_index_set rather than needs_output_symtab_entry.
4209 * testsuite/discard_locals_relocatable_test.c: New file.
4210 * testsuite/discard_locals_test.sh: Test -r.
4211 * testsuite/Makefile.am (check_DATA): Add
4212 discard_locals_relocatable_test1.syms,
4213 discard_local_relocatable_test2.syms.
4214 (MOSTLYCLEANFILES): Likewise. Also add
4215 discard_locals_relocatable_test1.lout and
4216 discard_locals_relocatable_test2.out.
4217 (discard_locals_relocatable_test1.syms): New target.
4218 (discard_locals_relocatable_test.o): New target.
4219 (discard_locals_relocatable_test1.out): New target.
4220 (discard_locals_relocatable_test2.syms): New target.
4221 (discard_locals_relocatable_test2.out): New target.
4222 (various): Add missing ../ld-new dependencies.
4223 * testsuite/Makefile.in: Rebuild.
4227 * po/fi.po: New Finnish translation.
4231 * layout.cc (Layout::Layout): Force section types of .init_array*,
4232 .preinit_array* and .fini_array* sections.
4233 * output.cc (Output_section::Input_section_sort_entry::has_priority):
4234 Fix check of return value of std::string::find.().
4235 (Output_section::Input_section_sort_compare::operator()): Remove
4236 comment about .init_array.
4237 (Output_section::Input_section_sort_init_fini_compare::operator()):
4239 (Output_section::sort_attached_input_sections): Handle .init_array
4240 and .fini_array specially.
4241 * output.h (Output_section::Inut_section_sort_compare): Update
4243 (Output_section::Input_section_sort_init_fini_compare): New struct.
4247 * arm.cc (Target_arm::Relocate::reloc_is_non_pic): Treat
4248 R_ARM_PREL31 and R_ARM_SBREL31 as position independent.
4249 * testsuite/debug_msg.sh: Avoid matching source line number for
4250 use of global variable undef_int.
4254 * arm.cc (Target_arm::scan_reloc_for_stub): Move code handling
4255 R_ARM_V4BX to Target_arm::scan_reloc_section_for_stubs.
4256 (Target_arm::scan_reloc_section_for_stubs): Instead of calling
4257 scan_reloc_for_stub, do all processing of R_ARM_V4BX here.
4258 * options.cc (General_options::General_options): Initialize member
4260 * testsuite/Makefile.am (check_SCRIPTS): Add arm_fix_v4bx.sh
4261 (check_DATA): Add arm_fix_v4bx.stdout, arm_fix_v4bx_interworking.stdout
4262 and rm_no_fix_v4bx.stdout
4263 (arm_fix_v4bx.stdout, arm_fix_v4bx, arm_fix_v4bx.o,
4264 arm_fix_v4bx_interworking.stdout, arm_fix_v4bx_interworking,
4265 arm_no_fix_v4bx.stdout, arm_no_fix_v4bx): New make rules.
4266 (MOSTLYCLEANFILES): Add arm_fix_v4bx, arm_fix_v4bx_interworking
4267 and arm_no_fix_v4bx.
4268 * Makefile.in: Regenerate.
4269 * testsuite/arm_fix_v4bx.s: New file.
4270 * testsuite/arm_fix_v4bx.sh: Ditto.
4274 * arm.cc (Target_arm::got_section): Make the .got section the first
4275 non RELRO section in the data segment.
4276 * testsuite/script_test_5.sh: Fix match patterns to avoid matching
4277 suffixes of section names.
4281 * arm.cc (Target_arm::do_finalize_sections): Skip processor specific
4282 flags and attributes merging if an input file is a binary file.
4283 * fileread.cc (Input_file::open): Record format of original file.
4284 * fileread.h (Input_file::Format): New enum type.
4285 (Input_file::Input_file): Initialize data member format_.
4286 (Input_file::format): New method definition.
4287 (Input_file::format_):: New data member.
4291 * arm.cc (Arm_output_data_got): New class.
4292 (ARM_TCB_SIZE): New constant
4293 (Target_arm): Use Arm_output_data_got instead of Output_data_got.
4294 (Arm_output_section::fix_exidx_coverage): Add a parameter for layout.
4295 If user uses a script with a SECTIONS clause, issue only a warning
4296 for a misplaced EXIDX input section. Otherwise, issue an error.
4297 (Arm_relobj::do_gc_process_relocs): Exit early if we are not doing
4299 (Target_arm::got_mode_index_entry): Handle static linking.
4300 (Target_arm::Scan::local): Ditto.
4301 (Target_arm::Scan::global): Ditto.
4302 (Target_arm::Relocate::relocate_tls): Handle static linking. Fix
4303 all incorrectly implemented relocations.
4304 (Target_arm::fix_exidx_coverage): Pass layout to
4305 Arm_output_section::fix_exidx_coverage.
4306 * layout.cc (Layout::section_name_mapping): Remove trailing dots
4307 from ".ARM.exidx." and ".ARM.extab.".
4311 * arm.cc (Target_arm::do_finalize_sections): Create attribute
4312 section if it does not already exist.
4313 * attributes.cc (Attributes_section_data::Attributes_section_data):
4314 Don't crash if size is zero.
4319 * gold.cc (queue_middle_tasks): If no input files were opened,
4321 * workqueue.h (Task_function::Task_function): Assert that there is
4326 * gold-threads.h (Once::~Once): Explicitly define virtual destructor.
4327 * icf.cc (get_section_contents): Cast snprintf arguments to long long
4328 types to avoid warnings due to different uint64_t implementations
4333 * arm.cc (Arm_relocate_functions::arm_branch_common): Fix bug in
4334 handling of the maximum backward branch offset.
4335 (Arm_relocate_functions::thumb_branch_common): Ditto.
4336 * testsuite/Makefile.am (check_SCRIPTS): Add arm_branch_in_range.sh.
4337 (check_DATA): Add arm_bl_in_range.stdout, arm_bl_out_of_range.stdout
4338 thumb_bl_in_range.stdout, thumb_bl_out_of_range.stdout,
4339 thumb2_bl_in_range.stdout and thumb2_bl_out_of_range.stdout.
4340 (arm_bl_in_range.stdout, arm_bl_in_range, arm_bl_in_range.o,
4341 arm_bl_out_of_range.stdout, arm_bl_out_of_range,
4342 arm_bl_out_of_range.o, thumb_bl_in_range.stdout, thumb_bl_in_range,
4343 thumb_bl_in_range.o, thumb_bl_out_of_range.stdout,
4344 thumb_bl_out_of_range thumb_bl_out_of_range.o,
4345 thumb2_bl_in_range.stdout, thumb2_bl_in_range, thumb2_bl_in_range.o
4346 thumb2_bl_out_of_range.stdout, thumb2_bl_out_of_range,
4347 thumb2_bl_out_of_range.o): New rules.
4348 (MOSTLYCLEANFILES): Add arm_bl_in_range, arm_bl_out_of_range,
4349 thumb_bl_in_range, thumb_bl_out_of_range, thumb2_bl_in_range and
4350 thumb2_bl_out_of_range
4351 * testsuite/Makefile.in: Regenerate.
4352 * testsuite/arm_bl_in_range.s: New file.
4353 * testsuite/arm_bl_out_of_range.s: Ditto.
4354 * testsuite/arm_branch_in_range.sh: Ditto.
4355 * testsuite/arm_branch_range.t: Ditto.
4356 * testsuite/thumb2_branch_range.t: Ditto.
4357 * testsuite/thumb_bl_in_range.s: Ditto.
4358 * testsuite/thumb_bl_out_of_range.s: Ditto.
4359 * testsuite/thumb_branch_range.t: Ditto.
4363 * gc.h (gc_process_relocs): Change vectors to point to the new list.
4364 Add reloc offset information.
4365 * icf.cc (get_section_contents): Change iterators to point to the new
4366 vectors. Add reloc offset information to the contents.
4367 * icf.h (Icf::Sections_reachable_info): New typedef.
4368 (Icf::Sections_reachable_list): New typedef.
4369 (Icf::Offset_info): New typedef.
4370 (Icf::Reloc_info): New struct typedef.
4371 (Icf::Reloc_info_list): New typedef.
4372 (Icf::symbol_reloc_list): Delete method.
4373 (Icf::addend_reloc_list): Delete method.
4374 (Icf::section_reloc_list): Delete method.
4375 (Icf::reloc_info_list): New method.
4376 (Icf::reloc_info_list_): New member.
4380 * arm-reloc.def: Mark R_ARM_TLS_GD32, R_ARM_TLS_LDM32,
4381 R_ARM_TLS_LDO32, R_ARM_TLS_IE32 and R_ARM_TLS_LE32 are implemented.
4382 * arm.cc (Arm_relocation_functions): New forward declaration.
4383 (Target_arm::Target_arm): Initialize new data members
4384 got_mod_index_offset_ and tls_base_symbol_defined_.
4385 (Target_arm::Relocate::relocate_tls): New method.
4386 (Target_arm::optimize_tls_reloc, Target_arm::define_tls_base_symbol,
4387 Target_arm::got_mod_index_entry, Target_arm::rel_tls_desc_section):
4389 (Target_arm::Got_type): Add GOT_TYPE_TLS_NOFFSET, GOT_TYPE_OFFSET,
4390 GOT_TYPE_TLS_PAIR and GOT_TYPE_TLS_DESC.
4391 (Target_arm::got_mod_index_offset_,
4392 Target_arm::tls_base_symbol_defined_): New data members.
4393 (Target_arm::Scan::local, Target::Scan::global,
4394 Target_arm::Relocate::relocate): Handle 32-bit initial TLS
4399 * arm.cc (Arm_relobj::find_linked_text_section): New method.
4400 (Arm_relobj::make_exidx_input_section): Pass section index of linked
4401 text section as a parameter becuase some broken tools may not set
4402 the link in section header.
4403 (Target_arm::has_got_section): New method.
4404 (Target_arm::scan_section_for_cortex_a8_stubs): Treat an input section
4405 without any mapping symbol as data only. Remove warning.
4406 (Arm_relobj::do_read_synbols): If an EXIDX input section has no
4407 link in its section header, try to discover the link by inspecting the
4408 REL31 relocation at the beginning of the section.
4409 (Target_arm::Scan::check_non_pic): Report name of offending relocation
4411 (Target_arm::Scan::global): Treat any reference to the symbol
4412 _GLOBAL_OFFSET_TABLE_ as a GOT access.
4416 * arm.cc (Scan::local_reloc_may_be_function_pointer): New function.
4417 (Scan::global_reloc_may_be_function_pointer): New function.
4418 * sparc.cc (Scan::local_reloc_may_be_function_pointer): New function.
4419 (Scan::global_reloc_may_be_function_pointer): New function.
4420 * powerpc.cc (Scan::local_reloc_may_be_function_pointer): New function.
4421 (Scan::global_reloc_may_be_function_pointer): New function.
4422 * i386.cc (Scan::local_reloc_may_be_function_pointer): New function.
4423 (Scan::global_reloc_may_be_function_pointer): New function.
4424 * x86_64.cc (Scan::local_reloc_may_be_function_pointer): New function.
4425 (Scan::global_reloc_may_be_function_pointer): New function.
4426 (Scan::possible_function_pointer_reloc): New function.
4427 (Target_x86_64::can_check_for_function_pointers): New function.
4428 * gc.h (gc_process_relocs): Scan relocation types to determine if
4429 function pointers were taken for targets that support it.
4430 * icf.cc (Icf::find_identical_sections): Include functions for
4431 folding in safe ICF whose pointer is not taken.
4432 * icf.h (Secn_fptr_taken_set): New typedef.
4433 (fptr_section_id_): New member.
4434 (section_has_function_pointers): New function.
4435 (set_section_has_function_pointers): New function.
4436 (check_section_for_function_pointers): New function.
4437 * options.h: Fix comment for safe ICF option.
4438 * target.h (can_check_for_function_pointers): New function.
4439 * testsuite/Makefile.am: Add icf_safe_so_test test case.
4440 Modify icf_safe_test for X86-64.
4441 * testsuite/Makefile.in: Regenerate.
4442 * testsuite/icf_safe_so_test.cc: New file.
4443 * testsuite/icf_safe_so_test.sh: New file.
4444 * testsuite/icf_safe_test.cc (kept_func_3): New function.
4445 (main): Change to take pointer to function kept_func_3.
4446 * testsuite/icf_safe_test.sh (arch_specific_safe_fold): Check if safe
4447 folding is done correctly for X86-64.
4451 * output.h (Output_reloc<SHT_REL>::Output_reloc): Add
4452 is_symbolless parameter.
4453 (Output_reloc<SHT_REL>::is_symbolless): New.
4454 (Output_reloc<SHT_REL>::is_symbolless_): New.
4455 (Output_reloc<SHT_REL>::type_): Decrease to 29 bits.
4456 (Output_reloc<SHT_RELA>::Output_reloc): Add is_symbolless parameter.
4457 (Output_reloc<SHT_RELA>::is_symbolless): New.
4458 (Output_data_reloc::add_global): Handle is_symbolless.
4459 (Output_data_reloc::add_global_relative): Likewise.
4460 (Output_data_reloc::add_local): Likewise.
4461 (Output_data_reloc::add_local_relative): Likewise.
4462 (Output_data_reloc::add_symbolless_global_addend): New.
4463 (Output_data_reloc::add_symbolless_local_addend): New.
4464 * output.cc (Output_reloc<SHT_REL>::Output_reloc): Handle
4466 (Output_reloc::set_needs_dynsym_index): Test ->is_symbolless_
4467 instead of ->is_relative_
4468 (Output_reloc::write): Likewise.
4469 (Output_reloc::get_symbol_index): Return 0 when ->is_symbolless_
4470 (Output_reloc::write_rel): Simplify.
4472 * sparc.cc (Target_sparc::Scan::local): Use
4473 ->add_symbolless_local_addend as needed.
4474 (Target_sparc::Scan::global): Use ->add_symbolless_global_addend as
4475 needed. Also, emit appropriate unaligned vs. aligned dynamic reloc
4476 based upon relocation offset.
4480 * arm.cc (Target_arm::Scan::local): Fix bugs in relocation handling.
4481 (Target_arm::Scan::global): Ditto. Also remove a comment before the
4482 beginning of function.
4483 (Target_arm::Relocate::relocate): Remove error messages for MOVW_ABS
4484 and MOVT_ABS relocations. Those are non issued in scanning. Fix
4485 parameter is_32bit in calls to should_apply_static_reloc.
4486 * testsuite/Makefile.am (check_SCRIPTS): Add arm_abs_global.sh.
4487 (check_DATA): Add arm_abs_global.stdout.
4488 (arm_abs_lib.o, libarm_abs.so, arm_abs_global.o, arm_abs_global,
4489 arm_abs_global.stdout): New rules.
4490 (MOSTLLYCLEANFILES): Add arm_abs_global
4491 * Makefile.in: Regenerate.
4492 * testsuite/arm_abs_global.s: New file.
4493 * testsuite/arm_abs_global.sh: Ditto.
4494 * testsuite/arm_abs_lib.s: Ditto.
4498 * gold.cc (queue_middle_gc_tasks): Use a separate blocker for each
4500 (queue_middle_tasks): Likewise, and also for Scan_relocs. Run
4501 Allocate_commons_task first.
4502 * reloc.cc (Read_relocs::run): Pass next_blocker_ down to next
4503 task, rather than symtab_lock_.
4504 (Gc_process_relocs::~Gc_process_relocs): New function.
4505 (Gc_process_relocs::is_runnable): Check this_blocker_.
4506 (Gc_process_relocs::locks): Use next_blocker_ rather than
4508 (Scan_relocs::~Scan_relocs): New function.
4509 (Scan_relocs::is_runnable): Check this_blocker_ rather than
4511 (Scan_relocs::locks): Drop symtab_lock_ and blocker_. Add
4513 * reloc.h (class Read_relocs): Drop symtab_lock_ and blocker_
4514 fields. Add this_blocker_ and next_blocker_ fields. Adjust
4515 constructor accordingly.
4516 (class Gc_process_relocs): Likewise.
4517 (class Scan_relocs): Likewise.
4518 * common.h (class Allocate_commons_task): Remove symtab_lock_
4519 field, and corresponding constructor parameter.
4520 * common.cc (Allocate_commons_tasK::is_runnable): Remove use of
4522 (Allocate_commons_task::locks): Likewise.
4526 * gold-threads.h (class Once): Define.
4527 (class Initialize_lock): Rewrite as child of Once.
4528 * gold-threads.cc (class Once_initialize): Define.
4529 (once_pointer_control): New static variable.
4530 (once_pointer, once_arg): New static variables.
4531 (c_run_once): New static function.
4532 (Once::Once, Once::run_once, Once::internal_run): New functions.
4533 (class Initialize_lock_once): Remove.
4534 (initialize_lock_control): Remove.
4535 (initialize_lock_pointer): Remove.
4536 (initialize_lock_once): Remove.
4537 (Initialize_lock::Initialize_lock): Move to gold-threads.h.
4538 (Initialize_lock::initialize): Rewrite.
4539 (Initialize_lock::do_run_once): New function.
4540 * archive.cc (Archive::interpret_header): Only clear name if it is
4542 * fileread.cc: Include "gold-threads.h"
4543 (file_counts_lock): New static variable.
4544 (file_counts_initialize_lock): Likewise.
4545 (File_read::release): Only increment counts when using --stats.
4546 Use a lock around the increment.
4547 * parameters.cc (class Set_parameters_target_once): Define.
4548 (set_parameters_target_once): New static variable.
4549 (Parameters::Parameters): Move here from parameters.h.
4550 (Parameters::set_target): Rewrite.
4551 (Parameters::set_target_once): New function.
4552 (Parameters::clear_target): Move here and rewrite.
4553 * parameters.h (class Parameters): Update declarations. Add
4554 set_parameters_target_once_ field.
4555 (Parameters::Parameters): Move to parameters.cc.
4556 (Parameters::clear_target): Likewise.
4557 * readsyms.cc (Read_symbols::do_group): Create a Start_group
4559 (Start_group::~Start_group): New function.
4560 (Start_group::is_runnable): New function.
4561 (Start_group::locks, Start_group::run): New functions.
4562 (Finish_group::run): Change saw_undefined to size_t.
4563 * readsyms.h (class Start_group): Define.
4564 (class Finish_group): Change saw_undefined_ field to size_t.
4565 (Finish_group::Finish_group): Remove saw_undefined and
4566 this_blocker parameters. Change all callers.
4567 (Finish_group::set_saw_undefined): New function.
4568 (Finish_group::set_blocker): New function.
4569 * symtab.h (class Symbol_table): Change saw_undefined to return
4570 size_t. Change saw_undefined_ field to size_t.
4571 * target-select.cc (Set_target_once::do_run_once): New function.
4572 (Target_selector::Target_selector): Initialize set_target_once_
4573 field. Don't initialize lock_ and initialize_lock_ fields.
4574 (Target_selector::instantiate_target): Rewrite.
4575 (Target_selector::set_target): New function.
4576 * target-select.h (class Set_target_once): Define.
4577 (class Target_selector): Update declarations. Make
4578 Set_target_once a friend. Remove lock_ and initialize_lock_
4579 fields. Add set_target_once_ field.
4583 * dirsearch.cc (Dirsearch::initialize): Add all blockers before
4585 * gold.cc (queue_middle_gc_tasks): Likewise. Fix final blocker.
4586 (queue_middle_tasks): Add all blockers before queueing any tasks.
4587 (queue_final_tasks): Likewise.
4588 * token.h (Task_token::add_blockers): New function.
4589 * object.h (Input_objects::number_of_relobjs): New function.
4593 * i386.cc (Relocate::relocate_tls): A local symbol is final if not
4594 shared, not if not position independent.
4595 * x86_64.cc (Relocate::relocate_tls): Likewise.
4596 * testsuite/Makefile.am (check_PROGRAMS): Add tls_pie_pic_test.
4597 (tls_pie_pic_test): New target.
4598 * testsuite/Makefile.in: Rebuild.
4600 * testsuite/Makefile.am (check_PROGRAMS): Add tls_pie_test.
4601 (tls_test_main_pie.o, tls_test_pie.o): New targets.
4602 (tls_test_file2_pie.o, tls_test_c_pie.o, tls_pie_test): Likewise.
4603 * testsuite/Makefile.in: Rebuild.
4607 * sparc.cc (Target_sparc::Scan::local): Do not emit relocs other than
4608 R_SPARC_RELATIVE using ->add_local_relative().
4609 (Target_sparc::Scan::global): Likewise for ->add_global_relative().
4611 * output.h (Output_data_dynamic::add_section_size): New method
4612 that takes two Output_data objects.
4613 (Output_data_dynamic::Dynamic_entry): Create storage for secondary
4614 entry param. Handle it in initializers.
4615 * output.cc (Output_data_dynamic::Dynamic_entry::write): For
4616 DYNAMIC_SECTION_SIZE, add in second object size if non-NULL.
4617 * layout.h (Layout::add_target_dynamic_tags): Add dynrel_includes_plt
4619 * layout.cc (Layout::add_target_dynamic_tags): If dynrel_includes_plt,
4620 and .rela.plt exists, set DT_REL{,A}SZ to sum of .rela.dyn and .rela.plt
4621 * arm.cc (Target_arm::do_finalize_sections): Update to pass false
4622 for dynrel_includes_plt.
4623 * i386.cc (Target_i386::do_finalize_sections): Likewise.
4624 * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
4625 * sparc.cc (Target_sparc::make_plt_entry): Force .rela.dyn to be output
4627 (Target_sparc::do_finalize_sections): Update to pass true for
4628 dynrel_includes_plt.
4629 * powerpc.cc (Target_powerpc::make_plt_entry): Force .rela.dyn to be
4630 output before .rela.plt
4631 (Target_powerpc::do_finalize_sections): Update to pass true for
4632 dynrel_includes_plt when 32-bit.
4636 * arm.cc (Arm_relobj::simple_input_section_output_address): New
4638 (Arm_relobj::section_needs_cortex_a8_stub_scanning,
4639 Arm_relobj::scan_section_for_cortex_a8_stubs,
4640 Arm_relobj::do_relocation_section): Instead of calling
4641 Output_section::output_address, use faster
4642 Arm_relobj::simple_input_section_output_address.
4646 * sparc.cc (Target_sparc::Relocate::relocate): If relocation offset is
4647 unaligned for R_SPARC_16, R_SPARC_32, or R_SPARC_64, use the unaligned
4648 relocation helper function.
4650 * sparc.cc (Target_sparc::Scan::local): Handle R_SPARC_GOTDATA_OP*
4651 just like R_SPARC_GOT{10,13,22}.
4652 (Target_sparc::Scan::local): Likewise.
4653 (Target_sparc::Relocate:relocate): Likewise.
4657 * configure.ac: Rewrite targetobjs duplicate removal code to use
4658 only shell constructs.
4659 * configure: Rebuild.
4664 * arm.cc (Arm_relobj::section_is_scannable): New method.
4665 (Arm_relobj::section_needs_reloc_stub_scanning): Use it.
4666 (Arm_relobj::section_needs_cortex_a8_stub_scanning): Same.
4671 * arm-reloc-property.cc (cstdio): Include.
4672 * configure.ac (targetobjs): Remove duplicates.
4673 * configure: Regenerate.
4674 * resolve.cc (Symbol_table::resolve): Explicit instantiate both
4675 big and little endian version for a given address size.
4679 * arm-reloc-property.cc
4680 (Arm_reloc_property_table::reloc_name_in_error_message): New method
4682 * arm-reloc-property.h
4683 (Arm_reloc_property_table::get_implemented_static_reloc_property):
4684 New method definition.
4685 (Arm_reloc_property_table::reloc_name_in_error_message): New method
4687 * arm-reloc.def (THM_MOVT_ABS, THM_MOVT_PREL, THM_MOVT_BREL): Change
4689 (GOT_PREL): Change implemented to Y.
4690 * arm.cc (Target_arm::reloc_uses_thumb_bit): Remove method.
4691 (Target_arm::Relocate::reloc_needs_sym_origin): Remove method.
4692 (Arm_relocate_functions::movw_abs_nc): Remove method.
4693 (Arm_relocate_functions::movt_abs): Ditto.
4694 (Arm_relocate_functions::thm_movw_abs_nc): Ditto.
4695 (Arm_relocate_functions::thm_movt_abs): Ditto.
4696 (Arm_relocate_functions::movw_rel_nc): Ditto.
4697 (Arm_relocate_functions::movw_rel): Ditto.
4698 (Arm_relocate_functions::movt_rel): Ditto.
4699 (Arm_relocate_functions:thm_movw_rel_nc): Ditto.
4700 (Arm_relocate_functions:thm_movw_rel): Ditto.
4701 (Arm_relocate_functions:thm_movt_rel): Ditto.
4702 (Arm_relocate_functions::movw, Arm_relocate_functions::movt,
4703 (Arm_relocate_functions::thm_movw, Arm_relocate_functions::thm_movt):
4704 New method definitions.
4705 (Arm_relocation_functions::arm_grp_alu): Add assertion for group index.
4706 (Arm_relocation_functions::arm_grp_ldr): Ditto.
4707 (Arm_relocation_functions::arm_grp_ldrs): Ditto.
4708 (Arm_relocation_functions::arm_grp_ldc): Ditto.
4709 (Target_arm::Relocate::relocate): Check for non-static or
4710 unimplemented relocation code and exit early. Change calls to
4711 Target_arm::reloc_uses_thumb_bit and
4712 Target_arm::Reloc::reloc_needs_sym_origin to use relocation property
4713 instead. Refactor code to handle similar relocations to increase
4714 code sharing. Remove check for unsupported relocation code in switch
4716 (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): Use
4717 relocation property table to find out size. Change error message to
4718 print out the name of a relocation code instead of the numeric value.
4719 (Target_arm::scan_reloc_for_stub): Use relocation property table
4720 instead of calling Target_arm::reloc_uses_thumb_bit().
4724 * arm.cc (Target_arm::relocate_section): Do view adjustment for all
4725 types of relaxed input section.
4729 * Makefile.am (HFILES): Add arm-reloc-property.h.
4731 (TARGETSOURCES): Add arm-reloc-property.cc
4732 (ALL_TARGETOBJS): Add arm-reloc-property.$(OBJEXT)
4733 (libgold_a_SOURCES): $(DEFFILES)
4734 * Makefile.in: Regenerate.
4735 * arm-reloc-property.cc: New file.
4736 * arm-reloc-property.h: New file.
4737 * arm-reloc.def: New file.
4738 * arm.cc: Update comments.
4739 (arm-reloc-property.h): New included header.
4740 (arm_reloc_property_table): New global variable.
4741 (Target_arm::do_select_as_default_target): New method definition.
4742 * configure.tgt (armeb*-*-*,armbe*-*-*,arm*-*-*): Add
4743 arm-reloc-property to targ_extra_obj.
4744 * parameters.cc (set_parameters_target): Call
4745 Target::select_as_default_target().
4746 * target.h (Target::select_as_default_target): New method definition.
4747 (Target::do_select_as_default_target): Same.
4751 * arm.cc (Arm_exidx_fixup::Arm_exidx_fixup): Initialize
4752 first_output_text_section_.
4753 (Arm_exidx_fixup::first_output_text_section): New method definition.
4754 (Arm_exidx_fixup::first_output_text_section_): New data member.
4755 (Arm_exidx_fixup::process_exidx_section): Record the first text
4756 output section seen.
4757 (Arm_output_section::fix_exidx_coverage): Set correct linked section
4758 and entsize in output section header.
4762 * gold/arm.cc: Added support for the ARM relocations: R_ARM_THM_PC8,
4763 R_ARM_THM_PC12, R_ARM_THM_ALU_PREL_11_0.
4764 (Arm_relocate_functions::thm_alu11): New Method.
4765 (Arm_relocate_functions::thm_pc8): New Method.
4766 (Arm_relocate_functions::thm_pc12): New Method.
4767 (Target_arm::Scan::local): Handle the relocations.
4768 (Target_arm::Scan::global): Likewise.
4769 (Target_arm::Relocate::relocate): Likewise.
4770 (Target_arm:Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
4774 * arm.cc (Target_arm::Scan::global): General PLTs for the same set
4775 of relocation types as ld.
4779 * arm.cc (Arm_relocate_functions::arm_branch_common) Change visibility
4781 (Arm_relocate_functions::thumb_branch_common): Ditto.
4782 (Arm_relocate_functions::thm_call, Arm_relocate_functions::thm_jump24,
4783 Arm_relocate_functions::thm_xpc22, Arm_relocate_functions::plt32,
4784 Arm_relocate_functions::xpc25, Arm_relocate_functions::call,
4785 Arm_relocate_functions::jump24): Remove.
4786 (Target_arm::Relocate::relocate): Adjust code to call
4787 Arm_relocation_functions::arm_branch_common and
4788 Arm_relocation_functions::thumb_branch_common instead of their removed
4789 wrappers. Merge switch-cases together to reduce source code size.
4793 * arm.cc (Arm_relobj::Arm_relobj): Initialize new data member
4794 output_local_symbol_count_needs_update_.
4795 (Arm_relobj::output_local_symbol_count_needs_update,
4796 Arm_relobj::set_output_local_symbol_count_needs_update,
4797 Arm_relobj::update_output_local_symbol_count): New methods.
4798 (Arm_relobj::output_local_symbol_count_needs_update_): New data
4800 (Arm_exidx_cantunwind::do_fixed_endian_write): Write address
4801 of pointed function as in a R_ARM_PREL31 relocation.
4802 (Arm_output_section<big_endian>::fix_exidx_coverage): Mark objects
4803 for output local symbol count updating.
4804 (Target_arm::do_relax): Update output local symbol counts in objects
4806 * object.h (Sized_relobj::set_output_local_symbol_count): New method.
4810 * arm.cc: Added support for the ARM relocations:
4811 R_ARM_MOVW_BREL_NC, R_ARM_MOVT_BREL, R_ARM_MOVW_BREL,
4812 R_ARM_THM_MOVW_BREL_NC, R_ARM_THM_MOVT_BREL, R_ARM_THM_MOVW_BREL.
4813 (Arm_relocate_functions::movw_rel_nc): Renamed (was
4815 (Arm_relocate_functions::movw_rel): New method.
4816 (Arm_relocate_functions::movt_rel): Renamed (was movt_prel).
4817 (Arm_relocate_functions::thm_movw_rel_nc): Renamed (was
4819 (Arm_relocate_functions::thm_movw_rel): New method.
4820 (Arm_relocate_functions::thm_movt_rel): Renamed (was
4822 (Target_arm::Scan::local): Handle MOVW_BREL/MOVT_BREL
4824 (Target_arm::Scan::global): Likewise.
4825 (Target_arm::Relocate::relocate): Likewise.
4826 (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
4831 * arm.cc: Added support for ARM group relocations.
4832 (Target_arm::reloc_needs_sym_origin): New method.
4833 (Arm_relocate_functions::calc_grp_kn): New method.
4834 (Arm_relocate_functions::calc_grp_residual): New method.
4835 (Arm_relocate_functions::calc_grp_gn): New method.
4836 (Arm_relocate_functions::arm_grp_alu): New Method.
4837 (Arm_relocate_functions::arm_grp_ldr): New Method.
4838 (Arm_relocate_functions::arm_grp_ldrs): New Method.
4839 (Arm_relocate_functions::arm_grp_ldc): New Method.
4840 (Target_arm::Scan::local): Handle the ARM group relocations.
4841 (Target_arm::Scan::global): Likewise.
4842 (Target_arm::Relocate::relocate): Likewise.
4843 (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
4848 * arm.cc (set): Include.
4849 (class Arm_exidx_fixup): Change type of last_input_section_ to const
4851 (Arm_output_section::Text_section_list): New type.
4852 (Arm_output_section::append_text_sections_to_list): New method.
4853 (Arm_output_section::fix_exidx_coverage): Ditto.
4854 (Arm_relobj::Arm_relobj): Initialize exidx_section_map_.
4855 (Arm_relobj::convert_input_section_to_relaxed_section): Use
4856 Relobj::set_section_offset() instead of
4857 Sized_relobj::invalidate_section_offset().
4858 (Arm_relobj::section_needs_reloc_stub_scanning): Add an extra
4859 parameter for section headers. Ignore relocation sections for
4860 unallocated sections and EXIDX sections.
4861 (Target_arm::fix_exidx_coverage): New method.
4862 (Target_arm::output_section_address_less_than): New type.
4863 (Arm_exidx_fixup::add_exidx_cantunwind_as_needed): Use index of the
4864 linked text section instead of the EXIDX section.
4865 (Arm_output_section::create_stub_group): Add an assertion to check
4866 that this is not an EXIDX output section.
4867 (Arm_output_section::append_text_sections_to_list): New method.
4868 (Arm_output_section::fix_exidx_coverage): Ditto.
4869 (Arm_relobj::scan_sections_for_stubs): Adjust call to
4870 Arm_relobj::section_needs_reloc_stub_scanning.
4871 (Target_arm::do_relax): Fix EXIDX output section coverage in the
4873 (Target_arm::fix_exidx_coverage): New method.
4874 * object.h (Relobj::set_output_section): New method.
4875 (Sized_relobj::invalidate_section_offset): Remove method.
4876 (Sized_relobj::do_invalidate_section_offset): Remove method.
4877 (Sized_relobj::do_set_section_offset): Handle offset value -1.
4881 * arm.cc (Arm_exidx_merged_section::do_output_offset):
4882 Fix warning due to signed and unsigned comparison on a 32-bit host.
4886 * arm.cc (Target_arm::do_relax): Record an output section for section
4887 offset adjustment it contains any stub table that has changed.
4888 * layout.cc (Layout::clean_up_after_relaxation): Adjust section
4889 offsets in an output section if necessary.
4890 * output.cc (Output_section::Output_section): Initialize
4891 section_offsets_need_adjustments_.
4892 (Output_section::add_input_section_for_script): Renamed to
4893 Output_section::add_simple_input_section.
4894 (Output_section::save_states): Add a comment.
4895 (Output_section::discard_states): New method defintion.
4896 (Output_section::adjust_section_offsets): Same.
4897 * output.h (Output_section::add_input_section_for_script): Renamed to
4898 Output_section::add_simple_input_section.
4899 (Output_section::discard_states): New method declaration.
4900 (Output_section::adjust_section_offsets): Same.
4901 (Output_section::section_offsets_need_adjustment,
4902 Output_section::set_section_offsets_need_adjustment): New method
4904 (Output_section::section_offsets_need_adjustment_): New data member.
4905 * script-sections.cc
4906 (Output_section_element_input::set_section_address): Adjust code for
4907 renaming of Output_section::add_input_section_for_script.
4908 (Orphan_output_section::set_section_address): Same.
4912 * gold/arm.cc (Target_arm): Updated fix_v4bx method and usage of
4913 Fix_v4bx enum values .
4914 * gold/options.h (General_options): New option definitions.
4915 (General_options::fix_v4bx): New method.
4916 (General_options::Fix_v4bx): New enum.
4917 * gold/options.cc (General_options::parse_fix_v4bx): New method.
4918 (General_options::parse_fix_v4bx_interworking): New method.
4922 * arm.cc (Arm_exidx_fixup): New class.
4926 * arm.cc (Arm_exidx_cantunwind, Arm_exidx_merged_section): New
4928 (Arm_exidx_section_offset_map): New type.
4932 * arm.cc (Arm_exidx_input_section): New class.
4933 (Arm_relobj::exidx_input_section_by_link,
4934 Arm_relobj::exidx_input_section_by_shndx,
4935 Arm_relobj::make_exidx_input_section): New methods.
4936 (read_arm_attributes_section): Remove.
4937 (Arm_relobj::do_read_symbols): Look for ARM.exidx sections and record
4938 information about them.
4939 (Arm_dynobj::do_read_symbols): Move code in read_arm_attributes_section
4944 * arm.cc (Target_arm::Arm_input_section_map): Change key type from
4945 Input_section_specifier to Section_id.
4946 (Target_arm::new_arm_input_section: Adjust code for change of key
4948 (Target_arm::find_arm_input_section): Ditto.
4949 * gc.h (object.h): Include for Section_id nand Section_id_hash.
4950 (Section_id): Remove.
4951 (Garbage_collection::Section_id_hash): Remove.
4952 * icf.h (object.h): Include for Section_id nand Section_id_hash.
4953 (Section_id): Remove.
4954 (Icf::Section_id_hash): Remove.
4955 * object.h (Section_id, Const_section_id, Section_id_hash,
4956 Const_section_id_hash): New type definitions.
4957 * output.cc (Output_section::add_relaxed_input_section): Change to
4958 use Const_section_id instead of Input_section_specifier as key type.
4959 (Output_section::add_merge_input_section): Ditto.
4960 (Output_section::build_relaxation_map): Change to use Section_id
4961 instead of Input_section_specifier as key type.
4962 (Output_section::convert_input_sections_in_list_to_relaxed_sections):
4964 (Output_section::convert_input_sections_to_relaxed_sections): Change
4965 to use Const_section_id instead of Input_section_specifier as key type.
4966 (Output_section::find_merge_section): Ditto.
4967 (Output_section::find_relaxed_input_section): Ditto.
4968 * output.h (Input_section_specifier): Remove class.
4969 (Output_section::Output_section_data_by_input_section_map): Change
4970 key type to Const_section_id.
4971 (Output_section::Output_relaxed_input_section_by_input_section_map):
4973 (Output_section::Relaxation_map): Change key type to Section_id.
4977 * gold/arm.cc: Added support for R_ARM_V4BX relocation
4978 (class Arm_v4bx_stub): New class.
4979 (DEF_STUBS): Updated definition to support v4_veneer_bx.
4980 (Stub_factory::make_arm_v4bx_stub): New method.
4981 (Stub_factory::elf32_arm_stub_v4_veneer_bx): New veneer template.
4982 (Stub_table::empty): Handle v4bx stubs.
4983 (Stub_table::add_arm_v4bx_stub): New method.
4984 (Stub_table::find_arm_v4bx_stub): New method.
4985 (Arm_relocate_functions::v4bx): New method.
4986 (Target_arm::fix_v4bx): New method.
4987 (Target_arm::Target_arm): Handle R_ARM_V4BX.
4988 (Stub_table::relocate_stubs): Likewise.
4989 (Stub_table::do_write): Likewise.
4990 (Stub_table::update_data_size_and_addralign): Likewise.
4991 (Stub_table::finalize_stubs): Likewise.
4992 (Target_arm::Scan::local): Likewise.
4993 (Target_arm::Scan::global): Likewise.
4994 (Target_arm::do_finalize_sections): Likewise.
4995 (Target_arm::Relocate::relocate): Likewise.
4996 (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
4998 (Target_arm::scan_reloc_for_stub): Likewise.
4999 (Target_arm::scan_reloc_section_for_stubs): Likewise.
5003 * output.cc (Output_section_headers::do_sized_write): Write large
5004 segment count to sh_info field.
5005 (Output_file_header::do_sized_write): For large segment count,
5006 write PN_XNUM to e_phnum field.
5010 * arm.cc (Arm_relocate_functions::thm_jump6): New function.
5011 (Arm_relocate_functions::thm_jump8): New function.
5012 (Arm_relocate_functions::thm_jump11): New function.
5013 (Target_arm::Scan::local): Handle R_ARM_THM_JUMP6, R_ARM_THM_JUMP8,
5015 (Target_arm::Scan::global): Likewise.
5016 (Target_arm::Relocate::relocate): Likewise.
5017 (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
5022 * arm.cc (map, utility): Include headers.
5023 (Target_arm::apply_cortex_a8_workaround): New method.
5024 (Arm_relobj::do_relocate_sections): Apply any Cortex-A8 workaround.
5025 (Target_arm::Scan::local): Handle R_ARM_THM_JUMP24, R_ARM_THM_JUMP19.
5026 (Target_arm::Scan::global): R_ARM_THM_JUMP19.
5027 (Target_arm::do_finalize_sections): Set fix_cortex_a8_ according to
5028 the --[no-]fix-cortex-a8 command line options.
5029 (Target_arm::Relocate::relocate): Handle R_ARM_JUMP19.
5030 (Target_arm::relocate_stub): Use addend in instruction template.
5031 * options.h (DEFINE_bool): Set the user-set flag.
5032 (General_options): Add --[no-]-fix-cortex options.
5033 * output.cc (Output_section::convert_input_sections_to_relaxed_sections)
5034 : Update fast look-up map after conversion.
5038 * object.cc (Sized_relobj::do_layout): Change to call layout_gnu_stack
5039 in the first pass of do_layout.
5043 * arm.cc (Arm_relobj::section_needs_reloc_stub_scanning,
5044 Arm_relobj::scan_sections_for_stubs): Rearrange code to avoid an
5045 apparent compiler problem of not folding static constant integral
5046 data members of elfcpp::Elf_sizes<32>.
5050 * arm.cc (Arm_relobj::section_needs_reloc_stub_scanning,
5051 Arm_relobj::section_needs_cortex_a8_stub_scanning,
5052 Arm_relobj::scan_section_for_cortex_a8_erratum,
5053 Arm_relobj::scan_span_for_cortex_a8_erratum): New methods.
5054 (Arm_relobj::scan_sections_for_stubs): Move code deciding what
5055 sections to scan for relocation stubs into a new method
5056 Arm_relobj::section_needs_reloc_stub_scanning. Handle both
5057 relocation and Cortex-A8 stub scanning.
5058 (Target_arm::do_relax): Force stubs to be after stubbed sections
5059 if fixing the Cortex-A8 erratum. Remove all Cortex-A8 stubs at
5060 the beginning of a new relaxation pass. Update a comment.
5061 (Target_arm::scan_span_for_cortex_a8_erratum): New method definition.
5065 * target-reloc.h (visibility_error): New inline function.
5066 (relocate_section): Call visibility_error.
5067 * testsuite/Makefile.am (check_DATA): Add protected_3.err.
5068 (MOSTLYCLEANFILES): Likewise.
5069 (protected_4_pic.o, protected_3.err): New targets.
5070 * testsuite/protected_4.cc: New file.
5074 * arm.cc (Cortex_a8_reloc): New class.
5075 (Target_arm::Target_arm): Initialize new data members fix_cortex_a8_
5076 and cortex_a8_relocs_info_.
5077 (Target_arm::fix_cortex_a8): New method definition.
5078 (Target_arm::Cortex_a8_relocs_info): New type.
5079 (Target_arm::fix_cortex_a8_, Target_arm::cortex_a8_relocs_info_):
5080 New data member declarations.
5081 (Target_arm::scan_reloc_for_stub): Record information about
5082 relocations for THUMB branches that might be exempted from the
5083 Cortex-A8 workaround.
5084 (Target_arm::do_relax): Clear all Cortex-A8 relocation information
5085 at the beginning of a relaxation pass.
5089 * arm.cc (Arm_relobj::mapping_symbols_info_): New data member.
5090 (Arm_relobj::Mapping_symbol_position,
5091 Arm_reloj::Mapping_symbol_position_less,
5092 Arm_relobj::Mapping_symbols_info): New types.
5093 (Target_arm::is_mapping_symbol_name): New method definition.
5094 (Arm_relobj::do_count_local_symbols): Save information about mapping
5099 * arm.cc (Arm_relocate_functions::thumb32_branch_offset,
5100 Arm_relocate_functions::thumb32_branch_upper,
5101 Arm_relocate_functions::thumb32_branch_lower,
5102 Arm_relocate_functions::thumb32_cond_branch_offset,
5103 Arm_relocate_functions::thumb32_cond_branch_upper,
5104 Arm_relocate_functions::thumb32_cond_branch_lower,
5105 Arm_relocate_functions::thm_jump19): New methods to handle THUMB
5106 branch offset encoding.
5107 (Arm_relocate_functions::thumb_branch_common): Use new branch
5108 offset encoding methods to avoid code duplication.
5109 (Stub_template::Stub_template) Handle THUMB16_SPECIAL_TYPE.
5110 (Stub_addend_reader::operator()): Use new branch encoding method
5111 to avoid code duplication.
5115 * arm.cc (Arm_relobj::do_gc_process_relocs): New method.
5116 (Target_arm::do_finalize_sections): Define special EXIDX section
5117 symbols only if referenced.
5118 * gc.h (Garbage_collection::add_reference): New method.
5119 (gc_process_relocs): Use Garbage_collection::add_reference to avoid
5124 * script.cc (Version_script_info::build_expression_list_lookup):
5125 Change complaing about duplicate wildcard match from error to
5128 * script.cc (class Lazy_demangler): Recreate--revert part of patch
5130 (Version_script_info::Version_script_info): Initialize globs_,
5131 default_version_, default_is_global_, and exact_. Don't
5132 initialize globals_ or locals_.
5133 (Version_script_info::build_lookup_tables): Build local symbols
5135 (Version_script_info::unquote): New function.
5136 (Version_script_info::add_exact_match): New function.
5137 (Version_script_info::build_expression_list_lookup): Remove lookup
5138 parameter. Add is_global parameter. Change all callers. Handle
5139 wildcard pattern specially. Unquote pattern. Call
5141 (Version_script_info::get_name_to_match): New function.
5142 (Version_script_info::get_symbol_version): New function.
5143 (Version_script_info::get_symbol_version_helper): Remove.
5144 (Version_script_info::check_unmatched_names): Call unquote.
5145 * script.h (class Version_script_info): Change get_symbol_version
5146 to be non-inline and add is_global parameter; change all callers.
5147 Rewrite symbol_is_local. Update declarations. Define struct
5148 Version_tree_match, Exact, Globs. Don't define struct Lookup.
5149 Remove globals_ and locals_ members. Add exact_, globs_,
5150 default_version_, is_global_.
5151 (Version_script_info::Glob): Remove pattern, add expression and
5152 is_global. Update constructor. Change all callers.
5153 * dynobj.cc (Versions::finalize): Mark the version symbol as the
5155 (Versions::symbol_section_contents): If a symbol is undefined, or
5156 defined in a dynamic object, set the version index to
5158 * symtab.cc (Symbol_table::add_from_relobj): Don't call
5160 (Symbol_table::add_from_pluginobj): Likewise.
5161 * testsuite/ver_matching_test.sh: blaza1 and blaza go into V2.
5165 * Makefile.am (incremental_dump_DEPENDENCIES): Add libintl dependency.
5166 (incremental_dump_LDADD): Add linking option for libintl.
5167 * Makefile.in: Regenerate.
5172 * testsuite/Makefile.am (dynamic_list.stdout): Use --dyn-syms
5174 * testsuite/Makefile.in: Regenerated.
5178 * options.h (DEFINE_var): Use parentheses around argument varname__
5179 in macro body to avoid any unintended subsequent substitutions.
5183 * resolve.cc (Symbol_table::resolve): Add symbols to list of ODR
5184 candidates before doing symbol resolution.
5186 * resolve.cc (Symbol_table::resolve): Add symbols to the list of
5187 ODR candidates if only one is weak.
5191 * script.cc (Version_script_info::build_expression_list_lookup):
5192 Don't warn about ambiguous version, just record the ambiguity.
5193 (Version_script_info::get_symbol_version_helper): Give error if
5194 version is ambiguous.
5198 * arm.cc (Stub_table::Stub_table): Initalize cortex_a8_stubs_,
5199 prev_data_size_ and prev_addralign_. Remove initializer for
5200 deleted data member has_been_changed_.
5201 (Stub_table::empty): Look at both reloc_stubs_ and cortex_a8_stubs_
5202 to determine if the table is empty.
5203 (Stub_table::has_been_changed, Stub_table_set_has_been_changed):
5205 (Stub_table::add_reloc_stub): Define method in class definition
5206 instead of just declaring it there.
5207 (Stub_table::add_cortex_a8_stub): New method definition.
5208 (Stub_table::update_data_size_and_addralign): Ditto.
5209 (Stub_table::finalize_stubs): Ditto.
5210 (Stub_table::apply_cortex_a8_workaround_to_address_range): Ditto.
5211 (Stub_table::do_addralign_): Return address alignment in the
5212 (Stub_table::do_reset_address_and_file_offset): Define method in
5213 class definition instead of declaring it there. Set current data
5214 size to be the data size of the previous pass.
5215 (Stub_table::set_final_data_size): Use current data size as the
5217 (Stub_table::relocate_stub): Change parameter type of stub from
5218 Reloc_stub pointer to Stub pointer.
5219 (Stub_table::addralign_, Stub_table::has_been_changed_): Remove.
5220 (Stub_table::Cortex_a8_stub_list): New typedef.
5221 (Stub_table::cortex_a8_stubs_, Stub_table::prev_data_size_,
5222 Stub_table::prev_addralign_): New data member.
5223 (Arm_relobj::Arm_relobj): Initialize data member
5224 section_has_cortex_a8_workaround_.
5225 (Arm_relobj::section_has_cortex_a8_workaround,
5226 Arm_relobj::mark_section_for_cortex_a8_workaround): New method
5228 (Arm_relobj::section_has_cortex_a8_workaround_): New data member
5230 (Target_arm::relocate_stub): Change parameter type of stub from
5231 Reloc_stub pointer to Stub pointer.
5232 (Insn_template::size, Insn_template::alignment): Handle
5233 THUMB16_SPECIAL_TYPE.
5234 (Stub_table::remove_all_cortex_a8_stubs, Stub_table::finalize_stubs,
5235 Stub_table::update_data_size_and_addralign,
5236 Stub_table::apply_cortex_a8_workaround_to_address_range): New method
5238 (Stub_table::relocate_stubs): Handle Cortex-A8 stubs.
5239 (Stub_table::do_write): Ditto.
5240 (Target_arm::do_relax): Adjust code for changes in Stub_table.
5245 * symtab.h (class Symbol): Remove fields is_target_special_ and
5246 has_plt_offset_. Add field is_defined_in_discarded_section_.
5247 (Symbol::is_defined_in_discarded_section): New function.
5248 (Symbol::set_is_defined_in_discarded_section): New function.
5249 (Symbol::has_plt_offset): Rewrite.
5250 (Symbol::set_plt_offset): Verify that new offset is not -1U.
5251 * symtab.cc (Symbol::init_fields): Initialize plt_offset_ to -1U.
5252 Don't initialize is_target_special_ or has_plt_offset_.
5253 Initialize is_defined_in_discarded_section_.
5254 (Symbol_table::add_from_relobj): If appropriate, set
5255 is_defined_in_discarded_section.
5256 * resolve.cc (Symbol::override_base_with_special): Don't test
5257 is_target_special_. Change has_plt_offset_ to has_plt_offset().
5258 * target-reloc.h (relocate_section): Do special handling for
5259 symbols defined in discarded sections for global symbols as well
5264 * dynobj.cc (big_endian>::find_dynsym_sections): Set pi to NULL in
5265 the SHT_SYMTAB case.
5269 * object.cc (Sized_relobj::do_layout): Don't get confused if
5270 layout_eh_frame returns NULL.
5275 * dynobj.cc (Sized_dynobj::find_dynsym_sections): If there is no
5276 dynamic symbol table, use the normal symbol table.
5277 (Sized_dynobj::do_read_symbols): Remove assertion about type of
5283 * layout.cc (Layout::include_section): Remove .gnu_debuglink
5288 * version.cc (print_version): Change to "Copyright 2010".
5294 * i386.cc (class Target_i386): Change return type of plt_section
5296 (class Output_data_plt_i386): Add tls_desc_rel_ field.
5297 (Output_data_plt_i386::Output_data_plt_i386): Initialize
5298 tls_desc_rel_ field.
5299 (Output_data_plt_i386::rel_tls_desc): New function.
5300 (Target_i386::rel_tls_desc_section): New function.
5301 (Target_i386::Scan::local): Rewrite R_386_TLS_GOTDESC handling.
5302 (Target_i386::Scan::global): For R_386_TLS_GOTDESC put
5303 R_386_TLS_DESC reloc in rel_tls_desc_section.
5304 * x86_64.cc (class Target_x86_64): Add tlsdesc_reloc_info_ field.
5305 Define struct Tlsdesc_info.
5306 (Target_x86_64::Target_x86_64): Initialize tlsdesc_reloc_info_.
5307 (Target_x86_64::do_reloc_symbol_index): New function.
5308 (Target_x86_64::add_tlsdesc_info): New function.
5309 (class Output_data_plt_x86_64): Add tlsdesc_rel_ field.
5310 (Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize
5312 (Output_data_plt_x86_64::rela_plt): Rename from rel_plt. Change
5314 (Output_data_plt_x86_64::rela_tlsdesc): New function.
5315 (Target_x86_64::rela_tlsdesc_section): New function.
5316 (Target_x86_64::Scan::local): Rewrite R_X86_64_GOTPC32_TLSDESC
5318 (Target_x86_64::Scan::global): For R_X86_64_GOTPC32_TLSDESC put
5319 (Target_x86_64::do_reloc_addend): New function.
5320 R_X86_64_TLSDESC reloc in rela_tlsdesc_section.
5321 * output.h (class Output_reloc) [SHT_REL]: Add new constructor
5322 declarations. Define TARGET_CODE. Add arg field to u1_ union.
5323 (Output_reloc::type): New function.
5324 (Output_reloc::is_local_section_symbol): Check for TARGET_CODE.
5325 (Output_reloc::is_target_specific): New function.
5326 (Output_reloc::target_arg): New function.
5327 (class Output_reloc) [SHT_RELA]: Add four new constructors for
5328 absolute relocs and target specific relocs.
5329 (class Output_data_reloc) [SHT_REL]: Add add_absolute and
5330 add_target_specific.
5331 (class Output_data_reloc) [SHT_RELA]: Likewise.
5332 * output.cc (Output_reloc::Output_reloc): Add four new versions
5333 for absolute relocs and target specific relocs.
5334 (Output_reloc::set_needs_dynsym_index): Add TARGET_CODE case.
5335 (Output_reloc::get_symbol_index): Likewise.
5336 (Output_reloc::local_section_offset): Check that local_sym_index_
5337 is not TARGET_CODE or 0.
5338 (Output_reloc::symbol_value): Likewise.
5339 (Output_reloc::write) [SHT_RELA]: Call target for target specific
5341 * target.h (class Target): Add reloc_symbol_index and reloc_addend
5342 functions. Add do_reloc_symbol_index and do_reloc_addend virtual
5344 * layout.cc (add_target_dynamic_tags): Use output section for
5345 DT_PLTRELSZ and DT_JMPREL.
5350 * output.h (class Output_reloc) [SHT_RELA]: Add is_relative
5352 (class Output_data_reloc_generic): Define.
5353 (class Output_data_reloc_base): Change base class to
5354 Output_data_reloc_generic. Change add() method to call
5355 bump_relative_reloc_count for a relative reloc. Remove
5357 * output.cc (Output_data_reloc_base::do_write): Change sort_reloc_
5359 * layout.cc (Layout::add_target_dynamic_tags): Change dyn_rel to
5360 Output_data_reloc_generic*. Add DT_RELCOUNT/DT_RELACOUNT tag if
5362 * layout.h (class Layout): Update declaration.
5366 * output.h (class Output_data): Add const version of
5367 output_section and do_output_section.
5368 (class Output_section_data): Add const version of
5370 (class Output_section): Likewise.
5371 * layout.cc (Layout::add_target_dynamic_tags): New function.
5372 * layout.h (class Layout): Update declarations.
5373 * arm.cc (Target_arm::do_finalize_sections): Use
5374 add_target_dynamic_tags.
5375 * i386.cc (Target_i386::do_finalize_sections): Likewise.
5376 * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
5377 * sparc.cc (Target_sparc::do_finalize_sections): Likewise.
5378 * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
5383 * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Mark the dynamic
5390 * object.cc: Instantiate Xindex::initialize_symtab_xindex and
5391 Xindex::read_symtab_xindex.
5395 * arm.cc (Insn_template::Type): New enum value THUMB16_SPECIAL_TYPE.
5396 (Insn_template::thumb16_bcond_insn): New method declaration.
5397 (Insn_template): Fix spelling.
5398 (Stub::thumb16_special): New method declaration.
5399 (Stub::do_write): Define virtual method which was previously pure
5401 (Stub::do_thumb16_special): New method declaration.
5402 (Stub::do_fixed_endian_write): New template member.
5403 (Reloc_stub::do_write): Remove.
5404 (Reloc_stub::do_fixed_endian_write): Remove.
5405 (Cortex_a8_stub): New class definition.
5406 (Stub_factory::make_cortex_a8_stub): New method definition.
5407 (Stub_factory::Stub_factory): Add missing static storage class
5408 qualifier for elf32_arm_stub_a8_veneer_blx.
5413 * options.h (class General_options): Add --warn-unresolved-symbols
5414 and --error-unresolved-symbols.
5415 * errors.cc (Errors::undefined_symbol): Implement
5416 --warn-unresolved-symbols.
5418 * options.h (class General_options): Add -z text and -z textoff.
5419 * layout.cc (Layout::finish_dynamic_section): Implement -z text.
5423 * gc.h (Garbage_collection::Cident_section_map): New typedef.
5424 (Garbage_collection::cident_sections): New function.
5425 (Garbage_collection::add_cident_section): New function.
5426 (Garbage_collection::cident_sections_): New member.
5427 (gc_process_relocs): Add references to sections whose names are C
5429 * gold.h (cident_section_start_prefix): New constant.
5430 (cident_section_stop_prefix): New constant.
5431 (is_cident): New function.
5432 * layout.cc (Layout::define_section_symbols): Replace string constants
5433 with the newly defined constants.
5434 * object.cc (Sized_relobj::do_layout): Track sections whose names are
5436 * testsuite/Makefile.am: Add gc_orphan_section_test.
5437 * testsuite/Makefile.in: Regenerate.
5438 * testsuite/gc_orphan_section_test.cc: New file.
5439 * testsuite/gc_orphan_section_test.sh: New file.
5444 * options.h (class General_options): Add --warn-shared-textrel.
5445 * layout.cc (Layout::finish_dynamic_section): Implement
5446 --warn-shared-textrel.
5449 * options.h (class General_options): Add --warn-multiple-gp.
5453 * Makefile.am (incremental_dump_DEPENDENCIES): Remove
5454 $(THREADSLIB) and $(LIBDL).
5455 * Makefile.in: Rebuild.
5460 * options.cc (General_options::parse_section_start): New function.
5461 (General_options::section_start): New function.
5462 (General_options::General_options): Initialize all members.
5463 * options.h: Include <map>
5464 (class General_options): Add --section-start. Add section_starts_
5466 * layout.cc (Layout::attach_allocated_section_to_segment): If
5467 --section-start was used, set the address of the segment. Remove
5468 local sort_sections.
5469 (Layout::relaxation_loop_body): If the address of the load segment
5470 has been set by --section-start, don't use it.
5471 * output.h (Output_segment::update_flags_for_output_section): New
5473 * output.cc (Output_segment::add_output_section): Call
5474 update_flags_for_output_section.
5479 * options.h (class General_options): Add --undefined-version.
5480 * script.cc (struct Version_expression): Add was_matched_by_symbol
5482 (Version_script_info::matched_symbol): New function.
5483 (Version_script_info::get_symbol_version_helper): Call
5485 (Version_script_info::check_unmatched_names): New function.
5486 * script.h (class Version_script_info): Update declarations.
5487 * gold.cc (queue_middle_tasks): Handle --no-undefined-version.
5489 * options.h (class General_options): Use DEFINE_bool_alias for
5490 allow_multiple_definition.
5491 * resolve.cc (Symbol_table::should_override): Don't test
5492 allow_multiple_definition.
5495 * options.h (class General_options): Add --cref.
5496 * main.cc (main): Print cref table if --cref. Don't close mapfile
5497 until after printing cref table.
5498 * cref.cc: Include "symtab.h".
5499 (class Cref_inputs): Define Cref_table_compare and Cref_table.
5500 (Cref_table_compare::operator()): New function.
5501 (Cref_inputs::gather_cref): New function.
5502 (filecol): New static const.
5503 (Cref_inputs::print_cref): New function.
5504 (Cref::print_cref): New function.
5505 * cref.h: Include <cstdio>.
5506 (class Cref): Update declarations.
5507 * mapfile.h (Mapfile::file): New function.
5508 * object.h (class Object): Define Symbols. Declare virtual
5509 do_get_global_symbols.
5510 (Object::get_global_symbols): New function.
5511 * object.cc (Input_objects::add_object): Pass object to cref_ if
5513 (Input_objects::archive_start): Likewise.
5514 (Input_objects::archive_stop): Likewise.
5515 (Input_objects::print_cref): New function.
5516 * dynobj.h (Sized_dynobj::do_get_global_symbols): New function.
5517 * dynobj.cc (big_endian>::do_add_symbols): Create symbols_ if
5519 * plugin.cc (Sized_pluginobj::do_get_global_symbols): New
5521 * plugin.h (class Sized_pluginobj): Update declarations.
5525 * symtab.cc (Symbol_table::add_from_object): Rename def parameter
5526 to is_default_version. Rename insdef to insdefault.
5527 (Symbol_table::add_from_relobj): Rename def to is_default_version
5528 and local to is_forced_local.
5529 (Symbol_table::add_from_pluginobj): Likewise.
5530 (Symbol_table::add_from_dynobj): Likewise.
5531 (Symbol_table::define_special_symbol): Rename insdef to
5537 * options.h (class General_options): Add
5538 --allow-multiple-definition and -z muldefs.
5539 * resolve.cc (Symbol_table::should_override): Don't warn about a
5540 multiple symbol definition if --allow-multiple-definition or -z
5544 * options.h (class General_options): Add --add-needed and
5545 --copy-dt-needed-entries. Tweak --as-needed help entry.
5546 * object.cc (Input_objects::check_dynamic_dependencies): Give an
5547 error if --copy-dt-needed-entries aka --add-needed is used and
5548 would cause a change in behaviour.
5551 * options.h (class General_options): Add -G as a short version of
5552 --shared. Add no-op options -assert, -g, and -i.
5556 * gc.h (gc_process_relocs): Call is_section_foldable_candidate to
5557 check for .text or .gnu.linkonce.t sections.
5558 * icf.cc (Icf::find_identical_sections): Ditto.
5559 Change the detection for mangled function name within the section
5561 * icf.h (is_section_foldable_candidate): New function.
5566 * options.h (class General_options): Permit two dashes with
5567 --retain-symbols-file.
5572 * layout.cc (Layout::relaxation_loop_body): If -Ttext was used,
5573 don't put the file header and segment headers in the text
5577 * common.cc (Sort_commons::operator()): Stabilize sort when both
5579 (Symbol_table::do_allocate_commons_list): When allocating common
5580 symbols, skip a symbol which is no longer common.
5581 * symtab.h (Symbol::is_common): Test whether the symbol comes from
5582 an object before checking its type.
5583 * testsuite/common_test_2.c: New file.
5584 * testsuite/common_test_3.c: New file.
5585 * testsuite/Makefile.am (check_PROGRAMS): Add common_test_2.
5586 (common_test_2_SOURCES, common_test_2_DEPENDENCIES): Define.
5587 (common_test_2_LDFLAGS, common_test_2_LDADD): Define.
5588 (common_test_2_pic.o, common_test_2.so): New targets.
5589 (common_test_3_pic.o, common_test_3.so): New targets.
5590 * testsuite/Makefile.in: Rebuild.
5593 * script.cc (read_input_script): If we see a new SECTIONS clause,
5594 and we have added an input section, give an error.
5595 * layout.h (class Layout): Add have_added_input_section function.
5596 Add have_added_input_section_ field.
5597 * layout.cc (Layout::Layout): Initialize
5598 have_added_input_section_.
5599 (Layout::layout): Set have_added_input_section_.
5600 (Layout::layout_eh_frame): Likewise.
5605 * options.h (class General_options): Add --sort-common option.
5606 * symtab.h (class Symbol_table): Define Sort_commons_order enum.
5607 * common.cc (Sort_common): Add sort_order parameter to
5608 constructor. Add sort_order_ field.
5609 (Sort_commons::operator): Check sort_order_.
5610 (Symbol_table::allocate_commons): Determine the sort order.
5611 (Symbol_table::do_allocate_commons): Add sort_order parameter.
5613 (Symbol_table::do_allocate_commons_list): Likewise.
5618 * symtab.cc (Symbol_table::add_from_relobj): When not exporting
5619 symbols from this object, don't change the visibility of an
5621 * testsuite/exclude_libs_test_1.c (lib1_ref): New function.
5626 * script.h (class Version_script_info): Define Language enum.
5627 Update declarations. Define Glob, Exact, and Lookup types. Add
5628 new fields globals_, locals_, and is_finalized_.
5629 * script.cc: Various formatting fixes.
5630 (class Parser_closure): Change language_stack_ from a vector of
5631 std::string to one of Version_script_info::Language. Adjust all
5633 (class Lazy_demangler): Remove.
5634 (struct Version_expression): Change language from std::string to
5635 Version_script_info::Language.
5636 (Version_script_info::Version_script_info): New function.
5637 (Version_script_info::~Version_script_info): Don't call clear.
5638 (Version_script_info::finalize): New function.
5639 (Version_script_info::build_lookup_tables): New function.
5640 (Version_script_info::build_expression_list_lookup): New
5642 (Version_script_info::get_symbol_version_helper): Rewrite to use
5644 (Version_script_info::print_expression_list): Adjust to use
5645 Version_script_info::Language.
5646 (script_push_lex_into_version_mode): Check that the version script
5647 has not been finalized.
5648 (version_script_push_lang): Change language string to
5649 Version_script_info::Language.
5650 * options.cc (Command_line::version_script): New function.
5651 * options.h (class General_options): Add finalize_dynamic_list
5652 function. Change version_script from declaration to definition.
5653 * testsuite/ver_test_4.script: Remove duplicate def of t2_2.
5654 * testsuite/version_script.map: Remove duplicate def of foo.
5655 * testsuite/Makefile.am (ver_matching_def.so): Depend upon
5657 * testsuite/Makefile.in: Rebuild.
5662 * target-reloc.h (relocate_for_relocatable): When copying a reloc,
5663 if the input symbol index is 0, make the output symbol index 0.
5668 * options.h (class General_options): Add -x/--discard-all.
5669 * object.cc (Sized_relobj::do_count_local_symbols): Handle
5670 --discard-all. If the local symbol needs a dynamic entry, check
5671 that before handling --discard-locals.
5676 * output.cc (Output_segment::Output_segment): If PT_TLS, set the
5678 (Output_segment::add_output_section): Don't change the flags if
5682 * dynobj.cc (Dynobj::create_gnu_hash_table): Add symbols to the
5683 GNU hash table if they need a dynamic value. Otherwise, don't add
5684 them if they are defined in a dynamic object or are forced local.
5689 * layout.cc (Layout::create_dynamic_symtab): Only set entsize of
5690 .gnu.hash table for a 32-bit target.
5693 * symtab.h (Symbol::needs_dynsym_entry): A symbol in both a
5694 regular and a dynamic object only needs a dynamic symbol table
5695 entry if it is externally visible.
5698 * i386.cc (class Target_i386): Initialize global_offset_table_ in
5699 constructor. Add global_offset_table_ field.
5700 (Target_i386::got_section): Set global_offset_table_.
5701 (Target_i386::do_finalize_sections): Set global_offset_table_
5703 * x86_64.cc (class Target_x86_64): Initialize global_offset_table_
5704 in constructor. Add global_offset_table_ field.
5705 (Target_x86_64::got_section): Set global_offset_table_.
5706 (Target_x86_64::do_finalize_sections): Set global_offset_table_
5709 * layout.cc (Layout::Layout): Initialize increase_relro_.
5710 (Layout::get_output_section): Add is_relro, is_last_relro, and
5711 is_first_non_relro parameters. Change all callers.
5712 (Layout::choose_output_section): Likewise.
5713 (Layout::add_output_section_data): Likewise.
5714 (Layout::make_output_section): Likewise.
5715 (Layout::set_segment_offsets): Clear increase_relro when using a
5717 * layout.h (class Layout): Add increase_relro method. Add
5718 increase_relro_ field. Update declarations.
5719 * output.cc (Output_section::Output_section): Initialize
5720 is_last_relro_ and is_first_non_relro_.
5721 (Output_segment::add_output_section): Group relro sections is
5722 do_sort is true. Handle is_last_relro and is_first_non_relro.
5723 (Output_segment::maximum_alignment): Remove relro handling.
5724 (Output_segment::set_section_addresses): Add increase_relro
5725 parameter. Change all callers. Add initial alignment to align
5726 relro sections on separate page. Remove old relro handling.
5727 (Output_segment::set_section_list_addresses): Remove in_relro
5728 parameter. Change all callers.
5729 (Output_segment::set_offset): Add increase parameter. Change all
5730 callers. Remove old relro handling.
5731 * output.h (class Output_section): Add new methods: is_last_relro,
5732 set_is_last_relro, is_first_non_relro, set_is_first_non_relro.
5733 Add is_last_relro_ and is_first_non_relro_ fields.
5734 * i386.cc (Target_i386::got_section): Don't call set_is_relro.
5735 Create separate .got.plt section. Call increase_relro.
5736 * x86_64.cc (Target_x86_64::got_section): Likewise.
5737 * testsuite/relro_script_test.t: Add .got.plt.
5740 * layout.cc (Layout::Layout): Initialize dynamic_symbol_ field.
5741 (Layout::create_initial_dynamic_sections): Set dynamic_symbol_.
5742 (Layout::finalize): Call set_dynamic_symbol_size.
5743 (Layout::set_dynamic_symbol_size): New function.
5744 * layout.h (class Layout): Add dynamic_symbol_ field. Declare
5745 set_dynamic_symbol_size.
5748 * output.h (class Output_section): Add is_entsize_zero_ field.
5749 * output.cc (Output_section::Output_section): Initialize
5751 (Output_section::set_entsize): If two different entsizes are
5752 requested, force it to zero.
5753 (Output_section::add_input_section): Set flags for .debug_str
5754 before updating section flags. Set entsize.
5755 (Output_section::update_flags_for_input_section): Set SHF_MERGE
5756 and SHF_STRING if all input sections have those flags.
5760 * main.cc (main): Fix the sys time reporting.
5761 * workqueue.cc (Workqueue::find_and_run_task): Fix the sys time
5766 * options.cc (General_options::parse_version): Allow -v to exit
5767 without an error if there is nothing to link.
5771 * configure.ac: Set the MCMODEL_MEDIUM conditional to false if
5772 using a version of gcc before 4.1.
5773 * configure: Rebuild.
5777 * attributes.cc (Output_attributes_section_data::do_write): Use
5778 std::vector::front rather than std::vector::data.
5782 * symtab.h (class Symbol_table): Add enum Defined.
5783 * resolve.cc (Symbol_table::should_override): Add defined
5784 parameter. Change all callers. Test whether object is NULL
5785 before calling a method on it.
5786 (Symbol_table::report_resolve_problem): Add defined parameter.
5788 (Symbol_table::should_override_with_special): Likewise.
5789 * symtab.cc (Symbol_table::define_in_output_data): Add defined
5790 parameter. Change all callers.
5791 (Symbol_table::do_define_in_output_data): Likewise.
5792 (Symbol_table::define_in_output_segment): Likewise.
5793 (Symbol_table::do_define_in_output_segment): Likewise.
5794 (Symbol_table::define_as_constant): Likewise.
5795 (Symbol_table::do_define_as_constant): Likewise.
5796 * script.h (class Symbol_assignment): Add is_defsym parameter to
5797 constructor; change all callers.
5798 * script.cc (Script_options::add_symbol_assignment): Add is_defsym
5799 parameter. Change all callers. Add is_defsym_ field.
5800 (class Parser_closure): Add parsing_defsym parameter to
5801 constructor; change all callers. Add parsing_defsym accessor
5802 function. Add parsing_defsym_ field.
5806 * gold.cc (queue_middle_tasks): Fix formatting.
5807 * object.cc (Relobj::is_section_name_included): Likewise.
5811 * i386.cc (Target_i386::do_calls_non_split): Recognize
5812 -fsplit-stack prologue for a function with a static chain.
5813 * x86_64.cc (Target_x86_64::do_calls_non_split): Recognize
5814 -fsplit-stack prologue when using %r11.
5818 * options.cc (General_options::parse_version): Make -v continue and do
5819 the link like GNU ld does.
5823 * Makefile.am (CCFILES): Add timer.cc.
5824 (HFILES): Add timer.h.
5825 * configure.ac: Check for sysconf and times.
5826 * main.cc: include timer.h.
5827 (main): Use Timer instead of get_run_time.
5830 * workqueue.cc: include timer.h.
5831 (Workqueue::find_and_run_task):
5832 Report user, sys and wall time.
5833 * Makefile.in: Regenerate.
5834 * config.in: Regenerate.
5835 * configure: Regenerate.
5839 * arm.cc (Arm_relobj::scan_sections_for_stubs): Exclude ICF-eliminated
5841 * object.cc (Sized_relobj::do_finalize_local_symbols): Handle
5842 relaxed input sections.
5843 * output.cc (Output_section::find_relaxed_input_section): Change
5844 return type to Output_relaxed_input_section pointer. Adjust code
5845 for new type of relaxed_input_section_map_.
5846 * output.h (Output_section::find_relaxed_input_section): Change
5847 return type to Output_relaxed_input_section pointer.
5848 (Output_section::Output_relaxed_input_section_by_input_section_map):
5850 (Output_section::relaxed_input_section_map_): Change type to
5851 Output_section::Output_relaxed_input_section_by_input_section_map.
5852 * symtab.cc (Symbol_table::compute_final_value): Handle relaxed
5857 * layout.cc (Layout::create_shstrtab): Only write out after input
5858 sections if we are compressing debug sections.
5862 * archive.cc (Archive::add_symbols): Only look up a symbol without
5863 a version if there is, in fact, a version.
5867 Revert -Wshadow changes, all changes from:
5870 * configure.ac: Remove -Wshadow when setting WARN_CXXFLAGS.
5874 * arm.cc (Target_arm::do_finalize_sections): Fix build breakage
5876 * attributes.cc (Object_attribute::size): Ditto.
5877 (Attributes_section_data::size): Ditto.
5878 (Attributes_section_data::Attributes_section_data): Ditto.
5879 (Output_attributes_section_data::do_write): Ditto.
5880 * attributes.h (Object_attribute::set_type): Ditto.
5881 * testsuite/tls_test_main.cc (safe_lock, safe_unlock): Ditto.
5885 * archive.cc: Fix shadowed variable warnings.
5887 * compressed_output.cc: Likewise.
5888 * compressed_output.h: Likewise.
5889 * configure: Likewise.
5890 * dwarf_reader.cc: Likewise.
5891 * dynobj.cc: Likewise.
5892 * dynobj.h: Likewise.
5893 * ehframe.cc: Likewise.
5894 * ehframe.h: Likewise.
5895 * errors.cc: Likewise.
5896 * expression.cc: Likewise.
5897 * fileread.cc: Likewise.
5898 * fileread.h: Likewise.
5899 * freebsd.h: Likewise.
5900 * i386.cc: Likewise.
5902 * incremental.h: Likewise.
5903 * layout.cc: Likewise.
5904 * layout.h: Likewise.
5905 * mapfile.cc: Likewise.
5906 * merge.cc: Likewise.
5907 * merge.h: Likewise.
5908 * object.cc: Likewise.
5909 * object.h: Likewise.
5910 * options.h: Likewise.
5911 * output.cc: Likewise.
5912 * output.h: Likewise.
5913 * parameters.cc: Likewise.
5914 * plugin.cc: Likewise.
5915 * powerpc.cc: Likewise.
5916 * reduced_debug_output.cc: Likewise.
5917 * reduced_debug_output.h: Likewise.
5918 * reloc.cc: Likewise.
5919 * reloc.h: Likewise.
5920 * resolve.cc: Likewise.
5921 * script-sections.cc: Likewise.
5922 * script.cc: Likewise.
5923 * script.h: Likewise.
5924 * sparc.cc: Likewise.
5925 * symtab.cc: Likewise.
5926 * symtab.h: Likewise.
5927 * target-select.cc: Likewise.
5928 * target-select.h: Likewise.
5929 * token.h: Likewise.
5930 * workqueue.cc: Likewise.
5931 * workqueue.h: Likewise.
5932 * x86_64.cc: Likewise.
5936 * arm.cc (attributes.h): New include.
5937 (Arm_relobj::Arm_relobj): Initialize attributes_section_data_.
5938 (Arm_relobj::~Arm_relobj): Delete object pointed by
5939 attributes_section_data_.
5940 (Arm_relobj::attributes_section_data): New method definition.
5941 (Arm_relobj::attributes_section_data_): New data member declaration.
5942 (Arm_dynobj::Arm_dynobj): Initialize attributes_section_data_.
5943 (Arm_dynobj::~Arm_dynobj): Delete object pointed by
5944 attributes_section_data_.
5945 (Arm_dynobj::attributes_section_data): New method definition.
5946 (Arm_dynobj::attributes_section_data_): New data member declaration.
5947 (Target_arm::Target_arm): Initialize attributes_section_data_. Change
5948 initialization value of may_use_blx_ to false.
5949 (Target_arm::using_thumb2, Target_arm::using_thumb_only,
5950 Target_arm::may_use_arm_nop, Target_arm::may_use_thumb2_nop): Use
5951 object attributes to compute results instead of hard-coding.
5952 (Target_arm::do_attribute_arg_type, Target_arm::do_attributes_order,
5953 Target_arm::get_secondary_compatible_arch,
5954 Target_arm::set_secondary_compatible_arch
5955 Target_arm::tag_cpu_arch_combine, Target_arm::aeabi_enum_name,
5956 Target_arm::tag_cpu_name_value, Target_arm::merge_object_attributes):
5957 New method declarations.
5958 (Target_arm::get_aeabi_object_attribute): New method definition.
5959 (Target_arm::attributes_section_data_): New data member declaration.
5960 (read_arm_attributes_section): New template definition.
5961 (Arm_relobj::do_read_symbols): Read attributes section if it exists.
5962 (Arm_dynobj::do_read_symbols): Ditto.
5963 (Target_arm::do_finalize_sections): Merge attributes sections from
5964 input. Check for BLX use after attributes section merging.
5965 Fix __exidx_start and __exidx_end visibility. Create an
5966 .ARM.attributes section if necessary.
5967 (Target_arm::get_secondary_compatible_arch,
5968 Target_arm::set_secondary_compatible_arch,
5969 Target_arm::tag_cpu_arch_combine, Target_arm::aeabi_enum_name,
5970 Target_arm::tag_cpu_name_value, Target_arm::merge_object_attributes,
5971 Target_arm::do_attribute_arg_type, Target_arm::do_attributes_order):
5972 New method definitions.
5976 * plugin.cc (Plugin::load): Don't cast from void* to a function
5981 * dynobj.cc (Sized_dynobj::do_read_symbols): Clear version
5986 * testsuite/Makefile.am (two_file_shared_1_pic_2_test_DEPENDENCIES):
5987 Replace two_file_shared_1.so with two_file_shared_2.so.
5988 * testsuite/Makefile.in: Regenerated.
5992 * Makefile.am (CCFILES): Add attributes.cc and int_encoding.cc.
5993 (HFILES): Add attributes.h and int_encoding.h.
5994 * Makefile.in: Regenerate.
5995 * dwarf_reader.cc (read_unsigned_LEB_128, read_signed_LEB_128): Move
5996 function definitions to int_encoding.cc
5997 * dwarf_reader.h (read_unsigned_LEB_128, read_signed_LEB_128): Move
5998 prototypes to int_encoding.h
5999 * reduced_debug_output.cc (int_encoding.h): New include.
6000 (write_unsigned_LEB_128, get_length_as_unsigned_LEB_128): Move
6001 function definitions to int_encoding.cc
6002 (insert_into_vector, read_from_pointer): Move template definitions to
6004 * attributes.cc: New file.
6005 * attributes.h: New file.
6006 * int_encoding.cc: New file.
6007 * int_encoding.h: New file.
6012 * incremental-dump.cc (dump_incremental_inputs): New.
6013 (main): Use dump_incremental_inputs.
6018 * i386.cc (Target_i386::Scan::globa): Use is_func instead of
6019 checking elfcpp::STT_FUNC.
6020 (Target_i386::Relocate::relocate): Likewise.
6021 * x86_64.cc (Target_x86_64::Scan::global): Likewise.
6023 * symtab.cc (Symbol_table::sized_write_symbol): Turn IFUNC
6024 symbols from shared libraries into normal FUNC symbols.
6026 * symtab.h (Symbol): Add is_func and use it.
6030 * arm.cc (Target_arm::arm_info): Initialize new fields
6031 attributes_section and attributes_vendor.
6032 * i386.cc (Target_i386::i386_info): Same.
6033 * object.cc (Sized_relobj::do_layout): Skip attribute section.
6034 * gold/powerpc.cc (Target_powerpc::powerpc_info): Initialize new
6035 fields attributes_section and attributes_vendor.
6036 * sparc.cc (Target_sparc::sparc_info): Same.
6037 * target.h (Target::attributes_section, Target::attributes_vendor,
6038 Target::is_attributes_section, Target::attribute_arg_type,
6039 Target::attributes_order): New method definitions.
6040 (Target::Target_info::attributes_section,
6041 Target::Target_info::attributes_vendor): New fields.
6042 (Target::do_attribute_arg_type, Target::do_attributes_order): New
6043 virtual method definitions.
6044 * x86_64.cc (Target_x86_64::x86_64_info): Initialize new fields
6045 attributes_section and attributes_vendor.
6046 * testsuite/testfile.cc (Target_test::test_target_info): Same.
6050 * arm.cc: Update comments about interworking and stub generation.
6051 (Target_arm::Relocate::reloc_is_non_pic): Update list of relocations
6052 considered as non-PIC.
6053 (Arm_relocate_functions::base_abs): Fix formatting.
6054 (Arm_relocate_functions::got_prel): Fix comment. Change interface
6055 of function to use GOT entry address instead of offset.
6056 (Target_arm::Scan::global): Issue an error if a symbol would need a
6057 PLT does not get one because it is untyped. Remove code to create
6058 dynamic symbols for relative branches.
6059 (Target_arm::Relocate::relocate: Use 0 instead of false since function
6060 takes unsigned integer instead of boolean.
6064 * testsuite/Makefile.am (constructor_test_LDADD): New. Empty.
6065 (two_file_test_LDADD): Likewise.
6066 (common_test_1_LDADD): Likewise.
6067 (exception_test_LDADD) Likewise.
6068 (weak_test_LDADD): Likewise.
6069 (many_sections_test_LDADD): Likewise.
6070 (initpri1_LDADD): Likewise.
6071 (script_test_1_LDADD): Likewise.
6072 (script_test_2_LDADD): Likewise.
6073 (justsyms_LDADD): Likewise.
6074 (binary_test_LDADD): Likewise.
6075 (large_LDADD): Likewise.
6076 * testsuite/Makefile.in: Regenerated.
6080 * resolve.cc (symbol_to_bits): Treat STB_GNU_UNIQUE as STB_GLOBAL.
6081 (Symbol_table::override_with_special): Likewise.
6082 (Symbol_table::add_from_object): Likewise.
6086 * incremental.cc (Incremental_inputs::sized_create_inputs_section_data):
6087 Don't set the data_offset twice.
6091 * testsuite/Makefile.in: Regenerate.
6095 * arm.cc: Remove comment about missing .ARM.exidx section symbols.
6096 (Target_arm::do_finalize_sections): Add parameter for symbol table
6097 pointer. Add __exidx_start and __exidx_end symbols as appropriate.
6098 * i386.cc (Target_i386::do_finalize_sections): Add an additional
6099 parameter for symbol table pointer.
6100 * layout.cc (Layout::finalize): Call Target::finalize_sections with
6101 an additional parameter for a pointer to symbol table.
6102 * powerpc.cc (Target_powerpc::do_finalize_sections): Add an additional
6103 parameter for a symbol table pointer.
6104 * sparc.cc (Target_sparc::do_finalize_sections): Ditto.
6105 * target.h (Target::finalize_sections, Target::do_finalize_sections):
6107 * x86_64.cc (Target_x86_64::do_finalize_sections): Add an additional
6108 parameter for a symbol table pointer.
6112 * incremental.cc (Incremental_inputs_header)
6113 (Incremental_inputs_header_write, Incremental_inputs_entry)
6114 (Incremental_inputs_entry_write): Move ...
6115 * incremental.h (Incremental_inputs_header)
6116 (Incremental_inputs_header_write, Incremental_inputs_entry)
6117 (Incremental_inputs_entry_write): here.
6121 * incremental.cc (make_sized_incremental_binary): Set the target.
6122 Error if it is incompatible.
6123 * output.h (Output_file): Add filename method.
6127 * incremental.cc (Incremental_inputs_entry): Remove unused argument
6128 from the get_* methods.
6132 * incremental-dump.cc (main): Check that the offeset of a script is 0.
6133 * incremental.cc (Incremental_inputs::sized_create_inputs_section_data):
6134 Write 0 for the data_offset of scripts.
6138 * testsuite/Makefile.am: Add the incremental_test.sh test.
6139 * testsuite/incremental_test.sh: New.
6140 * testsuite/incremental_test_1.c: New.
6141 * testsuite/incremental_test_2.c: New.
6145 * incremental-dump.cc (main): Fix typos.
6150 * incremental-dump.cc (main): Use llu to print 64 bit values.
6155 * Makefile.am (incremental_dump_DEPENDENCIES): Add $(THREADSLIB)
6157 (incremental_dump_LDADD): Likewise.
6158 * Makefile.in: Regenerated.
6166 * arm.cc (Target_arm::Target_arm): Move method definition
6167 outside of class definition. Add code to handle
6168 --target1-rel, --target1-abs and --target2= options.
6169 (Target_arm::get_reloc_reloc_type): Change method to be
6170 non-static and const.
6171 (Target_arm::target1_is_rel_, Target_arm::target2_reloc_):
6172 New data member declaration.
6173 (Target_arm::Scan::local, Target_arm::Scan::global,
6174 Target_arm::Relocate::relocate,
6175 Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
6176 Adjust call to Target_arm::get_real_reloc_type.
6177 (Target_arm::get_real_reloc_type): Use command line options
6178 to determine real types of R_ARM_TARGET1 and R_ARM_TARGET2.
6179 * options.h (--target1-rel, --target1-abs, --target2): New
6184 * arm.cc (Target_arm::Target_arm): Move method definition outside of
6185 class definition. Add code to handle --target1-rel, --target1-abs
6186 and --target2= options.
6187 (Target_arm::get_reloc_reloc_type): Change method to be non-static
6189 (Target_arm::target1_is_rel_, Target_arm::target2_reloc_): New data
6191 (Target_arm::Scan::local, Target_arm::Scan::global,
6192 Target_arm::Relocate::relocate,
6193 Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): Adjust
6194 call to Target_arm::get_real_reloc_type.
6195 (Target_arm::get_real_reloc_type): Use command line options to
6196 determine real types of R_ARM_TARGET1 and R_ARM_TARGET2.
6197 * options.h (--target1-rel, --target1-abs, --target2): New ARM-only
6202 * arm.cc (Target_arm::may_use_thumb2_nop): New method definition.
6203 (Arm_relocate_functions::thumb_branch_common): New metod declaration.
6204 (Arm_relocate_functions::abs12, Arm_relocate_functions::abs16): Fix
6206 (Arm_relocate_functions::thm_call): Replace body with a call to
6207 Arm_relocate_functions::thumb_branch_common.
6208 (Arm_relocate_functions::thm_jump24,
6209 Arm_relocate_functions::thm_xpc22): New method definitions.
6210 (Arm_relocate_functions::thumb_branch_common): New method definition.
6211 (Reloc_stub::stbu_type_for_reloc): Fix incorrect uses of bit-wise-or
6213 (Target_arm::Relocate::relocate): Adjust call to thm_call.
6214 Add code to handle R_ARM_THM_XPC22 and R_ARM_THM_JUMP24.
6218 * Makefile.am: Build incremental-dump
6219 * Makefile.in: Regenerate.
6220 * incremental-dump.cc: New.
6221 * incremental.cc (Incremental_inputs_header_data,
6222 Incremental_inputs_entry_data): Move to incremental.h
6223 * incremental.h: (Incremental_inputs_header_data,
6224 Incremental_inputs_entry_data): Move from incremental.cc
6228 * incremental.cc (Incremental_inputs_header,
6229 Incremental_inputs_header_write, Incremental_inputs_entry,
6230 Incremental_inputs_entry_write): Add a typedef with the data type.
6234 * incremental.cc (Incremental_inputs_header,
6235 Incremental_inputs_header_write, Incremental_inputs_entry,
6236 Incremental_inputs_entry_write): Update comment about which
6237 type has the filed descriptions.
6241 * arm.cc (Target_arm::may_use_arm_nop): New method definition.
6242 (Arm_relocate_functions::arm_branch_common): Change method defintion
6243 in class definition to a method declaration and update list of formal
6245 (Arm_relocate_functions::plt32, Arm_relocate_functions::call,
6246 Arm_relocation_functions::jump24): Adjust call to
6247 Arm_relocate_functions::arm_branch_common. Update list of formal
6249 (Arm_relocate_functions::xpc25): New method definition.
6250 (Arm_relocate_functions::arm_branch_common): Move method defintion
6251 out from class definition. Use stubs for mode-switching and extending
6253 (Target_arm::Relocate::relocate): Handle weakly-undefined symbols
6254 specially. Change code to enable use of stubs in ARM branches.
6258 * arm.cc (Arm_relobj::do_relocate_sections): Remove options parameter
6259 in method declaration.
6260 (Target_arm::relocate_stub): New method declaration.
6261 (Target_arm::default_target): Change to return a pointer instead of
6263 (Reloc_stub::stub_type_for_reloc): Adjust for the change in
6264 Target_arm::default_target.
6265 (Arm_Relobj::do_relocate_sections): Remove options paramater in
6267 (Target_arm::relocate_section): Adjust view.
6268 (Target_arm::relocate_stub): New method definition.
6272 * i386.cc (Target_i386::do_calls_non_split): Add a cast to avoid
6274 * incremental.cc (open_incremental_binary): Initialized local
6275 variables to avoid warnings.
6276 * object.cc (make_elf_object): Ditto.
6277 * x86_64.cc (Target_x86_64::do_calls_non_split): Add a cast to avoid
6283 * testsuite/plugin_test.c: Include "config.h".
6287 * arm.cc (Target_arm::fake_relnum_for_stubs): New constant.
6288 (arm_symbol_value): Remove.
6289 (Arm_relocate_functions::arm_branch_common,
6290 Arm_relocate_functions::abs8, Arm_relocate_functions::thm_abs5,
6291 Arm_relocate_functions::abs12, Arm_relocate_functions::abs16,
6292 Arm_relocate_functions::abs32, Arm_relocate_functions::rel32,
6293 Arm_relocate_functions::thm_call, Arm_relocate_functions::plt32,
6294 Arm_relocate_functions::call, Arm_relocate_functions::jump24,
6295 Arm_relocate_functions::prel31, Arm_relocate_functions::mov_abs_nc,
6296 Arm_relocate_functions::movt_abs, Arm_relocate_functions::movw_abs_nc,
6297 Arm_relocate_functions::thm_mobw_abs_nc,
6298 Arm_relocate_functions::thm_mov_abs,
6299 Arm_relocate_functions::movw_prel_nc,
6300 Arm_relocate_functions::thm_movt_abs,
6301 Arm_relocate_functions::movt_prel,
6302 Arm_relocate_functions::thm_movw_prel_nc,
6303 Arm_relocate_functions::thm_movt_prel): Adjust callers of the above.
6304 (Target_arm::Relocate::relocate): Only decompose address into two
6305 parts if relocation type uses the thumb-bit and pass the actual
6306 bit instead of a flag indicating that the thumb-bit is used. Adjust
6307 calls to methods in Arm_relocate_functions for this change.
6312 * reloc.cc: Instantiate
6313 Sized_relobj::initialize_input_to_output_maps and
6314 Sized_relobj:free_input_to_output_maps.
6319 * defstd.cc (in_segment): Set only_if_ref true for "end".
6323 * arm.cc (class Reloc_stub): Correct a comment.
6324 (Target_arm::Target_arm): Initialize arm_input_section_map_.
6325 (Target_arm::scan_section_for_stubs): New method declaration.
6326 (Target_arm::do_make_elf_object, Target_arm::do_make_output_section):
6327 Change methods from private to protected.
6328 (Target_arm::do_may_relax): New method definition.
6329 (Target_arm::do_relax, Target_arm::group_sections,
6330 Target_arm::scan_reloc_for_stub,
6331 Target_arm::scan_reloc_section_for_stubs): New method declarations.
6332 (Target_arm::arm_input_section_map_): New data member declaration.
6333 (Target_arm::scan_reloc_for_stub,
6334 Target_arm::scan_reloc_section_for_stubs,
6335 Target_arm::scan_section_for_stubs, Target_arm::group_sections,
6336 Target_arm::do_relax): New method definitions.
6340 * configure.ac: Check for (struct stat)::st_mtim
6341 * fileread.cc (File_read::get_mtime): Use st_mtim if available.
6342 * config.in: Regenerate.
6343 * configure: Regenerate.
6348 * output.cc (Output_segment::add_output_section): Add missing
6354 * object.h (class Object): Add is_needed and set_is_needed
6355 methods. Add is_needed_ field. Make bool fields into bitfields.
6356 * symtab.cc (Symbol_table::set_dynsym_indexes): If a symbol is
6357 defined in a dynamic object and referenced by a regular object,
6358 set is_needed for the dynamic object.
6359 * layout.cc (Layout::finish_dynamic_section): Don't add DT_NEEDED
6360 if the file is marked with as_needed and it is not needed.
6365 * arm.cc (Target_arm::do_finalize_sections): Don't add dynamic
6366 tags if data is discarded by linker script.
6367 * i386.cc (Target_i386::do_finalize_sections): Likewise.
6368 * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
6369 * sparc.cc (Target_sparc::do_finalize_sections): Likewise.
6370 * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
6374 * layout.cc (Layout::get_output_section): Add is_interp and
6375 is_dynamic_linker_section parameters. Change all callers.
6376 (Layout::choose_output_section): Likewise.
6377 (Layout::make_output_section): Likewise.
6378 (Layout::add_output_section_data): Add is_dynamic_linker_section
6379 parameter. Change all callers.
6380 * layout.h (class Layout): Update declarations.
6381 * output.h (class Output_section): Add is_interp, set_is_interp,
6382 is_dynamic_linker_section, set_is_dynamic_linker_section methods.
6383 Add is_interp_, is_dynamic_linker_section_ fields. Change
6384 generate_code_fills_at_write_ to a bitfield.
6385 * output.cc (Output_section::Output_sections): Initialize new
6387 (Output_segment::add_output_section): Add do_sort parameter.
6393 * options.h (class General_options): Add --warn-common.
6394 * resolve.cc (Symbol_table::resolve): Handle --warn-common when
6395 merging two common symbols.
6396 (Symbol_table::should_override): Handle --warn-common when merging
6397 a common symbol with a defined symbol. Use report_resolve_problem
6398 for multiple definitions.
6399 (Symbol_table::report_resolve_problem): New function.
6400 * symtab.h (class Symbol_table): Declare report_resolve_problem.
6404 * arm.cc (Target_arm::Target_arm): Initialize stub_tables_ and
6406 (Target_arm::stub_factory): New method definition.
6407 (Target_arm::new_arm_input_section,
6408 Target_arm::find_arm_input_section, Target_arm::new_stub_table,
6409 Target_arm::reloc_uses_thumb_bit): New method declarations.
6410 (Target_arm::Stub_table_list, Target_arm::Arm_input_section_map):
6411 New type definitions.
6412 (Target_arm::stub_tables_, Target_arm::stub_factory_): New data
6413 member declarations.
6414 (Target_arm::reloc_uses_thumb_bit, Target_arm::new_arm_input_section,
6415 Target_arm::find_arm_input_section, Target_arm::new_stub_table):
6416 New method definitions.
6420 * options.h (class General_options): Add --warn_constructors.
6425 * defstd.cc (in_section): Add entries for __rel_iplt_start,
6426 __rel_iplt_end, __rela_iplt_start, __rela_iplt_end, and __stack.
6431 * po/Make-in ($(srcdir)/$(PACKAGE).pot): Pass -C and
6432 --msgid-bugs-address.
6433 (install-pdf): New target.
6434 (install-data_yes): Look up one directory to find mkinstalldirs.
6438 * po/Make-in (.po.gmo): Don't generate .gmo files in source
6443 * arm.cc (Stub_addend_reader): Fix bug in previouls check-in.
6447 * arm.cc (Stub_addend_reader): New struct template definition
6448 and partial specializations.
6449 (Stub_addend_reader::operator()): New method definition for a
6450 partially specialized template.
6454 * arm.cc (Arm_relobj::processor_specific_flags): New method
6456 (Arm_relobj::do_read_symbols): New method declaration.
6457 (Arm_relobj::processor_specific_flags_): New data member declaration.
6458 (Arm_dynobj): New class definition.
6459 (Target_arm::do_finalize_sections): Add input_objects parameter.
6460 (Target_arm::do_adjust_elf_header): New method declaration.
6461 (Target_arm::are_eabi_versions_compatible,
6462 (Target_arm::merge_processor_specific_flags): New method declaration.
6463 (Target_arm::do_make_elf_object): New overloaded method definitions
6465 (Arm_relobj::do_read_symbols): New method definition.
6466 (Arm_dynobj::do_read_symbols): Ditto.
6467 (Target_arm::do_finalize_sections): Add input_objects parameters.
6468 Merge processor-specific flags from all input objects.
6469 (Target_arm::are_eabi_versions_compatible,
6470 Target_arm::merge_processor_specific_flags,
6471 Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object):
6472 New method definitions.
6473 * i386.cc (Target_i386::do_finalize_sections): Add unnamed
6474 Input_objects pointer type parameter.
6475 * layout.cc (Layout::finalize): Pass input objects to target's.
6476 finalize_sections function.
6477 * output.cc (Output_file_header::do_sized_write): Set ELF file
6478 header's processor-specific flags.
6479 * powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed
6480 Input_objects pointer type parameter.
6481 * sparc.cc (Target_sparc::do_finalize_sections): Same.
6482 * target.h (Input_objects): New forward class declaration.
6483 (Target::processor_specific_flags,
6484 Target::are_processor_specific_flags_sect): New method definitions.
6485 (Target::finalize_sections): Add input_objects parameter.
6486 (Target::Target): Initialize processor_specific_flags_ and
6487 are_processor_specific_flags_set_.
6488 (Target::do_finalize_sections): Add unnamed Input_objects pointer type
6490 (Target::set_processor_specific_flags): New method definition.
6491 (Target::processor_specific_flags_,
6492 Target::are_processor_specific_flags_set_): New data member
6494 * x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed
6495 Input_objects pointer type parameter.
6499 * arm.cc: Use Arm_address instead of elfcpp::Elf_types<32>::Elf_Addr.
6503 * object.h (class Relobj): Drop options parameter from
6504 gc_process_relocs, scan_relocs, relocate, do_gc_process_relocs,
6505 do_scan_relocs, do_relocate. Change all callers.
6506 (class Sized_relobj): Drop options parameters from
6507 do_gc_process_relocs, do_scan_relocs, do_relocate,
6508 do_relocate_sections, relocate_sections, emit_relocs_scan,
6509 emit_relocs_scan_reltype. Change all callers.
6510 (struct Relocate_info): Remove options field and all references to
6512 * reloc.h (class Read_relocs): Remove options constructor
6513 parameter and options_ field. Change all callers.
6514 (class Gc_process_relocs, class Scan_relocs): Likewise.
6515 (class Relocate_task): Likewise.
6516 * target-reloc.h (scan_relocs): Remove options parameter. Change
6518 (scan_relocatable_relocs): Likewise.
6519 * target.h (class Sized_target): Remove options parameter from
6520 gc_process_relocs, scan_relocs, scan_relocatable_relocs. Change
6522 * gc.h (gc_process_relocs): Remove options parameter. Change all
6524 * arm.cc: Update functions to remove options parameters.
6525 * i386.cc: Likewise.
6526 * powerpc.cc: Likewise.
6527 * sparc.cc: Likewise.
6528 * x86_64.cc: Likewise.
6529 * testsuite/testfile.cc: Likewise.
6533 * arm.cc (Arm_relobj): New class definition.
6534 (Arm_relobj::scan_sections_for_stubs,
6535 Arm_relobj::do_count_local_symbols, Arm_relobj::do_relocate_sections):
6536 New method definitions.
6540 * plugin.h (Plugin::Plugin): Initialize cleanup_done_.
6541 (Plugin::cleanup_done_): New member.
6542 (Plugin_manager::Plugin_manager): Remove cleanup_done_.
6543 (Plugin_manager::cleanup_done_): Remove.
6544 (Plugin_manager::add_input_file): Edit error message.
6545 * plugin.cc (Plugin::cleanup): Test and set cleanup_done_.
6546 (Plugin_manager::cleanup): Remove use of cleanup_done_.
6550 * fileread.cc: (File_read::View::~View): Use the new
6551 data_ownership_ filed.
6552 (File_read::~File_read): Dispose the new whole_file_view_.
6553 (File_read::open): Mmap the whole file if needed.
6554 (File_read::open): Use whole_file_view_ instead of contents_.
6555 (File_read::find_view): Use whole_file_view_ if applicable.
6556 (File_read::do_read): Use whole_file_view_ instead of contents_.
6557 (File_read::make_view): Use whole_file_view_ instead of contents_,
6558 update File_read::View::View call.
6559 (File_read::find_or_make_view): Update File_read::View::View
6561 * fileread.h: (File_read::File_read): Initialize whole_file_view_,
6563 (File_read::View::Data_ownership): New enum.
6564 (File_read::View::View): Replace bool mapped_ with Data_ownership
6566 (File_read::View::mapped_): Remove (replaced by data_ownership_).
6567 (File_read::View::data_ownership_): New field.
6568 (File_read::contents_): Remove (replaced by whole_file_view_).
6569 (File_read::whole_file_view_): New field.
6570 * options.h (class General_options): Add --keep-files-mapped.
6574 * symtab.cc (add_from_pluginobj): Pass correct value for is_ordinary.
6575 * testsuite/Makefile.am (plugin_test_5): New test case.
6576 * testsuite/Makefile.in: Regenerate.
6580 * object.h (Sized_relobj::View_size, Sized_relobj::Views): Change
6581 from private to protected to allow access by child class.
6582 (Sized_relobj::do_relocate_sections): New method declaration.
6583 (Sized_relobj::relocate_sections): Virtualize.
6584 * reloc.cc (Sized_relobj::do_relocate_sections): Rename from
6585 Sized_relobj::relocate_sections. Instantiate template explicitly
6586 for different target sizes and endianity.
6590 * arm.cc (Arm_output_section, Arm_relobj): Forward class declarations.
6591 (Arm_input_section::as_arm_input_section): New method.
6592 (Arm_output_section): New class definition.
6593 (Arm_output_section::create_stub_group,
6594 Arm_output_section::group_sections): New method definitions.
6598 * arm.cc (Arm_input_section): New class definition.
6599 (Arm_input_section::init, Arm_input_section:do_write,
6600 Arm_input_section::set_final_data_size,
6601 Arm_input_section::do_reset_address_and_file_offset): New method
6606 * arm.cc (Stub_table, Arm_input_section): New forward class
6608 (Stub_table): New class defintion.
6609 (Stub_table::add_reloc_stub, Stub_table::relocate_stubs
6610 Stub_table::do_reset_address_and_file_offset, Stub_table::do_write):
6611 New method definition.
6615 * arm.cc: Update copyright comments.
6616 (Target_arm): New forward class template declaration.
6617 (Arm_address): New type.
6618 (ARM_MAX_FWD_BRANCH_OFFSET, ARM_MAX_BWD_BRANCH_OFFSET,
6619 THM_MAX_FWD_BRANCH_OFFSET, THM_MAX_BWD_BRANCH_OFFSET,
6620 THM2_MAX_FWD_BRANCH_OFFSET, THM2_MAX_BWD_BRANCH_OFFSET): New
6622 (Insn_template): Same.
6623 (DEF_STUBS): New macro.
6624 (Stub_type): New enum type.
6625 (Stub_template): New class definition.
6628 (Stub_factory): Same.
6629 (Target_arm::Target_arm): Initialize may_use_blx_ and
6630 should_force_pic_veneer_.
6631 (Target_arm::may_use_blx, Target_arm::set_may_use_blx,
6632 Target_arm::should_force_pic_veneer,
6633 Target_arm::set_should_force_pic_veneer, Target_arm::using_thumb2,
6634 Target_arm::using_thumb_only, Target_arm:;default_target): New
6636 (Target_arm::may_use_blx_, Target_arm::should_force_pic_veneer_):
6637 New data member declarations.
6638 (Insn_template::size, Insn_template::alignment): New method defintions.
6639 (Stub_template::Stub_template): New method definition.
6640 (Reloc_stub::Key::name, Reloc_stub::stub_type_for_reloc,
6641 Reloc_stub::do_fixed_endian_write, Reloc_stub::do_write): Same.
6642 (Stub_factory::Stub_factory): New method definition.
6643 * gold.h (string_hash): New template.
6644 * output.h (Input_section_specifier::hash_value): Use
6646 (Input_section_specifier::string_hash): Remove.
6647 * stringpool.cc (Stringpool_template::string_hash): Use
6652 * object.cc (Sized_relobj::do_finalize_local_symbols): Handle section
6653 symbols of relaxed input sections.
6654 * output.h (Output_section::find_relaxed_input_section): Make
6659 * dynobj.cc (Versions::Versions): Initialize version_script_.
6660 Only insert base version symbol definition for a shared object
6661 if version script defines any version versions.
6662 (Versions::define_base_version): New method definition.
6663 (Versions::add_def): Check that base version is not needed.
6664 (Versions::add_need): Define base version lazily.
6665 * dynobj.h (Versions::define_base_version): New method declaration.
6666 (Versions::needs_base_version_): New data member declaration.
6667 * testsuite/Makefile.am (check_SCRIPTS): Add no_version_test.sh
6668 (check_DATA): Add no_version_test.stdout.
6669 (libno_version_test.so, no_version_test.o no_version_test.stdout):
6671 * testsuite/Makefile.in: Regenerate.
6672 * testsuite/no_version_test.c: New file.
6673 * testsuite/no_version_test.sh: Ditto.
6677 * expression.cc (class Segment_start_expression): New class definition.
6678 (Segment_start_expression::value): New method definition.
6679 (script_exp_function_segment_start): Return a new
6680 Segment_start_expression.
6681 * gold/script-c.h (script_saw_segment_start_expression): New function
6683 * script-sections.cc (Script_sections::Script_sections): Initialize
6684 SAW_SEGMENT_START_EXPRESSION_ to false.
6685 (Script_sections::set_section_addresses): Use -Ttext, -Tdata
6686 and -Tbbs options to specify section addresses if given in
6687 command line and no SEGMENT_START expression is seen in a script.
6688 * script-sections.h (Script_sections::saw_segment_start_expression,
6689 Script_sections::set_saw_segment_start_expression): New method
6691 (Script_sections::saw_segment_start_expression_): New data member
6693 * script.cc (script_saw_segment_start_expression): New function.
6694 * yyscript.y (SEGMENT_START): Call script_saw_segment_start_expression.
6695 * testsuite/Makefile.am (check_SCRIPTS): Add script_test_6.sh,
6696 script_test_7.sh and script_test_8.sh.
6697 (check_DATA): Add script_test_6.stdout, script_test_7.stdout and
6698 script_test_8.stdout.
6699 (MOSTLYCLEANFILES): Add script_test_6, script_test_7 and script_test_8.
6700 (script_test_6, script_test_6.stdout, script_test_7,
6701 script_test_7.stdout, script_test_8, script_test_8.stdout): New rules.
6702 * Makefile.in: Regenerate.
6703 * testsuite/script_test_6.sh: New file.
6704 * testsuite/script_test_6.t: Same.
6705 * testsuite/script_test_7.sh: Same.
6706 * testsuite/script_test_7.t: Same.
6707 * testsuite/script_test_8.sh: Same.
6711 * output.cc (Output_segment::set_section_list_address): Cast
6712 expressions to unsigned long long type to avoid format warnings.
6716 * script.cc (Script_options::add_symbol_assignment): Always add a
6717 dot assignment to script_sections_.
6718 * script-sections.cc (Script_sections::add_dot_assignment):
6719 Initialize if necessary.
6721 * layout.cc (Layout::relaxation_loop_body): Don't crash if we see
6722 program headers with no load segment if there is a linker script.
6724 * layout.cc (Layout::set_segment_offsets): Align the file offset
6725 to the segment aligment for -N or -n with no load segment.
6726 * output.cc (Output_segment::add_output_section): Don't crash if
6727 the first section is a TLS section.
6728 (Output_segment::set_section_list_addresses): Print an error
6729 message if the address moves backward in a linker script.
6730 * script-sections.cc
6731 (Output_section_element_input::set_section_addresses): Don't
6732 increase *dot_value for a SHF_TLS/SHT_NOBITS section.
6733 (Orphan_output_section::set_section_addresses): Likewise.
6737 * layout.cc (Layout::finish_dynamic_section): Generate tags
6738 DT_FINI_ARRAY, DT_FINI_ARRAYSZ, DT_INIT_ARRAY, DT_INIT_ARRAYSZ,
6739 DT_PREINIT_ARRAY, DT_PREINIT_ARRAYSZ as needed. If -Bsymbolic is
6740 used, add DT_SYMBOLIC and set DF_SYMBOLIC in DT_FLAGS.
6744 * object.h (class Relocate_info): Add reloc_shdr and data_shdr
6746 * object.cc (Sized_relobj::relocate_sections): Set reloc_shdr and
6747 data_shdr fields of relinfo.
6748 * i386.cc (class Target_i386::Relocate): Remove ldo_addrs_ field.
6749 (Target_i386::Relocate::relocate_tls): Don't call fix_up_ldo. For
6750 R_386_TLS_LDO_32, adjust based on section flags.
6751 (Target_i386::Relocate::fix_up_ldo): Remove.
6755 Add support for -pie.
6756 * options.h (class General_options): Add -pie and
6758 (General_options::output_is_position_independent): Test -pie.
6759 (General_options::output_is_executable): Return true if not shared
6760 and not relocatable.
6761 (General_options::output_is_pie): Remove.
6762 * options.cc (General_options::finalize): Reject incompatible uses
6764 * gold.cc (queue_middle_tasks): A -pie link is not static.
6765 * symtab.h (Symbol::needs_plt_entry): Return false if -pie.
6766 * symtab.cc (Symbol::final_value_is_known): Return false if
6767 output_is_position_independent.
6768 * layout.cc (Layout::set_segment_offsets): Start at address 0 if
6769 output_is_position_independent.
6770 * output.cc (Output_file_header::do_sized_write): Use ET_DYN if
6771 output_is_position_independent.
6772 * i386.cc (Output_data_plt_i386::do_write): Use the PIC PLT if
6773 output_is_position_independent.
6774 * testsuite/Makefile.am (check_PROGRAMS): Add basic_pie_test and
6776 (basic_pie_test.o, basic_pie_test): New targets.
6777 (two_file_test_1_pie.o, two_file_test_1b_pie.o): New targets.
6778 (two_file_test_2_pie.o, two_file_test_main_pie.o): New targets.
6779 (two_file_pie_test): New target.
6780 * testsuite/Makefile.in: Rebuild.
6781 * README: Remove note saying that -pie is not supported.
6785 * options.h (class General_options): Add -init and -fini.
6786 * layout.cc (Layout::finish_dynamic_section): Emit
6787 given init and fini functions.
6791 * gc.h (gc_process_relocs): Check if icf is enabled using new
6793 * gold.cc (queue_initial_tasks): Likewise.
6794 (queue_middle_tasks): Likewise.
6795 * object.cc (do_layout): Likewise.
6796 * symtab.cc (is_section_folded): Likewise.
6797 * main.cc (main): Likewise.
6798 * reloc.cc (Read_relocs::run): Likewise.
6799 (Sized_relobj::do_scan_relocs): Likewise.
6800 * icf.cc (is_function_ctor_or_dtor): New function.
6801 (Icf::find_identical_sections): Check if function is ctor or dtor when
6803 * options.h (General_options::icf): Change option to be an enum.
6804 (Icf_status): New enum.
6805 (icf_enabled): New method.
6806 (icf_safe_folding): New method.
6807 (set_icf_status): New method.
6808 (icf_status_): New variable.
6809 * (options.cc) (General_options::finalize): Set icf_status_.
6810 * testsuite/Makefile.am: Add commands to build icf_safe_test. Modify
6811 icf_test and icf_keep_unique_test to use the --icf enum flag.
6812 * testsuite/icf_safe_test.sh: New file.
6813 * testsuite/icf_safe_test.cc: New file.
6817 * symtab.h: Check for GOLD_SYMTAB_H before header includes. Remove
6818 includes to gc.h and icf.h.
6819 * arm.cc: Include gc.h.
6820 * gold.cc: Likewise.
6821 * i386.cc: Likewise.
6822 * powerpc.cc: Likewise.
6823 * sparc.cc: Likewise.
6824 * x86_64.cc: Likewise.
6825 * gc.h: Include icf.h.
6829 * plugin.cc: Include "gold.h" before other header files.
6833 * options.h (Input_file_argument::Input_file_type): New enum.
6834 (Input_file_argument::is_lib_): Replace with...
6835 (Input_file_argument::type_): New member.
6836 (Input_file_argument::Input_file_argument): Take Input_file_type
6837 'type' rather than boolean 'is_lib' as second argument.
6838 (Input_file_argument::is_lib): Use type_.
6839 (Input_file_argument::is_searched_file): New function.
6840 (Input_file_argument::may_need_search): Handle is_searched_file.
6841 * options.cc (General_options::parse_library): Support -l:filename.
6842 (General_options::parse_just_symbols): Update for Input_file_argument
6844 (Command_line::process): Likewise.
6845 * archive.cc (Archive::get_file_and_offset): Likewise.
6846 * plugin.cc (Plugin_manager::release_input_file): Likewise.
6847 * script.cc (read_script_file, script_add_file): Likewise.
6848 * fileread.cc (Input_file::Input_file): Likewise.
6849 (Input_file::will_search_for): Handle is_searched_file.
6850 (Input_file::open): Likewise.
6851 * readsyms.cc (Read_symbols::get_name): Likewise.
6852 * testsuite/Makefile.am (searched_file_test): New test.
6853 * testsuite/Makefile.in: Regenerate.
6854 * testsuite/searched_file_test.cc: New file.
6855 * testsuite/searched_file_test_lib.cc: New file.
6860 * descriptor.cc: Include <cstdio> and "binary-io.h".
6861 (Descriptors::open): Open the files in binary mode always.
6862 * script.cc (Lex::get_token): Treat \r as whitespace.
6866 * testsuite/retain_symbols_file_test.sh: Don't test for __tcf_0.
6871 * configure.ac: Check for readv function also.
6872 * fileread.cc (readv): Define if not HAVE_READV.
6873 * fileread.h (File_read:: max_readv_entries): Set to 1 if readv
6875 * config.in: Regenerate.
6876 * configure: Regenerate.
6880 * layout.cc (Layout::make_output_section): Call target hook to make
6881 ordinary output section.
6882 (Layout::finalize): Adjust parameter list of call the
6883 Target::may_relax().
6884 * layout.h (class Layout::section_list): New method.
6885 * merge.h (Output_merge_base::entsize): Change visibility to public.
6886 (Output_merge_base::is_string, Output_merge_base::do_is_string):
6888 (Output_merge_string::do_is_string): New method.
6889 * object.cc (Sized_relobj::do_setup): renamed from
6890 Sized_relobj::set_up.
6891 * object.h (Sized_relobj::adjust_shndx,
6892 Sized_relobj::initializ_input_to_output_maps,
6893 Sized_relobj::free_input_to_output_maps): Change visibilities to
6895 (Sized_relobj::setup): Virtualize.
6896 (Sized_relobj::do_setup): New method declaration.
6897 (Sized_relobj::invalidate_section_offset,
6898 Sized_relobj::do_invalidate_section_offset): New method decfinitions.
6899 (Sized_relobj::elf_file, Sized_relobj::local_values): New methods.
6900 * options.cc (parse_int): New function.
6901 * options.h (parse_int): New declaration.
6902 (DEFINE_int): New macro.
6903 (stub_group_size): New option.
6904 * output.cc (Output_section::Output_section): Initialize memebers
6905 merge_section_map_, merge_section_by_properties_map_,
6906 relaxed_input_section_map_, is_relaxed_input_section_map_valid_.
6907 (Output_section::add_input_section): Handled deferred code-fill
6908 generation and remove an old comment.
6909 (Output_section::add_relaxed_input_section): New method definition.
6910 (Output_section::add_merge_input_section): Use merge section by
6911 properties map to speed to search. Update merge section maps
6913 (Output_section::build_relaxation_map): New method definition.
6914 (Output_section::convert_input_sections_in_list_to_relaxed_sections):
6916 (Output_section::relax_input_section): Renamed to
6917 Output_section::convert_input_sections_to_relaxed_sections and change
6918 interface to take a vector of pointers to relaxed sections.
6919 (Output_section::find_merge_section,
6920 Output_section::find_relaxed_input_section): New method definitions.
6921 (Output_section::is_input_address_mapped,
6922 Output_section::output_offset, Output_section::output_address):
6923 Use output section data maps to speed up searching.
6924 (Output_section::find_starting_output_address): Add comments.
6925 (Output_section::do_write,
6926 Output_section::write_to_postprocessing_buffer): Do code-fill
6927 generation as appropriate.
6928 (Output_section::get_input_sections): Invalidate relaxed input section
6930 (Output_section::restore_states): Adjust type of checkpoint .
6931 Invalidate relaxed input section map.
6932 * output.h (Output_merge_base): New class declaration.
6933 (Input_section_specifier): New class defintion.
6934 (class Output_relaxed_input_section) Change base class to
6935 Output_section_data_build.
6936 (Output_relaxed_input_section::Output_relaxed_input_section): Adjust
6937 base class initializer.
6938 (Output_section::add_relaxed_input_section): New method declaration.
6939 (Output_section::Input_section): Change visibility to protected.
6940 (Output_section::Input_section::relobj,
6941 Output_section::Input_section::shndx): Handle relaxed input sections.
6942 Output_section::input_sections) Change visibility to protected. Also
6943 define overload to return a non-const pointer.
6944 (Output_section::Merge_section_properties): New class defintion.
6945 (Output_section::Merge_section_by_properties_map,
6946 Output_section::Output_section_data_by_input_section_map,
6947 Output_section::Relaxation_map): New types.
6948 (Output_section::relax_input_section): Rename method to
6949 Output_section::convert_input_sections_to_relaxed_sections and change
6950 interface to take a vector of relaxed section pointers.
6951 (Output_section::find_merge_section,
6952 Output_section::find_relaxed_input_section,
6953 Output_section::build_relaxation_map,
6954 Output_section::convert_input_sections_in_list_to_relaxed_sections):
6955 New method declarations.
6956 (Output_section::merge_section_map_
6957 Output_section::merge_section_by_properties_map_,
6958 Output_section::relaxed_input_section_map_,
6959 Output_section::is_relaxed_input_section_map_valid_,
6960 Output_section::generate_code_fills_at_write_): New data members.
6961 * script-sections.cc
6962 (Output_section_element_input::set_section_addresses): Call
6963 current_data_size and addralign methods of relaxed input sections.
6964 (Orphan_output_section::set_section_addresses): Call current_data_size
6965 and addralign methods of relaxed input sections.
6966 * symtab.cc (Symbol_table::compute_final_value): Extract template
6967 from the body of Symbol_table::sized_finalize_symbol.
6968 (Symbol_table::sized_finalized_symbol): Call
6969 Symbol_table::compute_final_value.
6970 * symtab.h (Symbol_table::Compute_final_value_status): New enum type.
6971 (Symbol_table::compute_final_value): New templated method declaration.
6972 * target.cc (Target::do_make_output_section): New method defintion.
6973 * target.h (Target::make_output_section): New method declaration.
6974 (Target::relax): Add more parameters for input objects, symbol table
6975 and layout. Adjust call to do_relax.
6976 (Target::do_make_output_section): New method declaration.
6977 (Target::do_relax): Add parameters for input objects, symbol table
6982 * pread.c: Include stdio.h.
6986 * plugin.cc: Don't include dlfcn.h when ENABLE_PLUGINS is not
6991 * dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info):
6992 Change read_shndx type to unsigned int.
6993 (Sized_dwarf_line_info::read_lines): Change shndx type to unsigned
6995 (Sized_dwarf_line_info::read_line_mappings): Likewise.
6996 * dwarf_reader.h (Sized_dwarf_line_info::Sized_dwarf_line_info):
6997 Change read_shndx type to unsigned int.
6998 (Sized_dwarf_line_info::read_lines): Change shndx type to unsigned
7000 (Sized_dwarf_line_info::read_line_mappings): Likewise.
7001 * layout.cc (Layout::create_symtab_sections): Cast the result of
7002 local_symcount * symsize to off_t in the gold_assert.
7006 * arm.cc (Target_arm::relocate::reloc_is_non_pic): Return true for
7007 R_ARM_THM_ABS5, R_ARM_ABS8, R_ARM_ABS12, R_ARM_ABS16,
7009 (Arm_relocate_functions::abs8): Remove has_thumb_bit parameter.
7010 (Arm_relocate_functions::thm_abs5): New function.
7011 (Arm_relocate_functions::abs12): New function.
7012 (Arm_relocate_functions::abs16): New function.
7013 (Arm_relocate_functions::base_abs): New function.
7014 (Scan::check_non_pic): Handle R_ARM_ABS32_NOI.
7015 (Scan::local): Remove special handling of R_ARM_ABS8. Handle
7016 R_ARM_ABS32_NOI, R_ARM_THM_ABS5, R_ARM_ABS12, R_ARM_ABS16, and
7018 (Scan::global): Likewise.
7019 (Relocate::relocate): Handle R_ARM_ABS12, R_ARM_ABS16,
7020 R_ARM_ABS32_NOI, R_ARM_THM_ABS5, and R_ARM_BASE_ABS.
7021 (Relocatable_size_for_reloc::get_size_for_reloc): Handle
7022 R_ARM_ABS16, R_ARM_THM_ABS5, R_ARM_ABS32_NOI, R_ARM_ABS12, and
7027 * arm.cc (Arm_relocate_functions::movw_prel_nc): New function.
7028 (Arm_relocate_functions::movt_prel): New function.
7029 (Arm_relocate_functions::thm_movw_prel_nc): New function.
7030 (Arm_relocate_functions::thm_movt_prel): New function.
7031 (Scan::local): Handle R_ARM_MOVW_PREL_NC, R_ARM_MOVT_PREL,
7032 R_ARM_THM_MOVW_PREL_NC, and R_ARM_THM_MOVT_PREL.
7033 (Scan::global, Relocate::relocate): Likewise.
7034 (Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
7038 * gold.cc: (queue_initial_tasks): Pass incremental_inputs to
7039 Incremental_checker.
7040 * incremental.cc: (INCREMENTAL_LINK_VERSION): Change type to
7042 (class Incremental_inputs_header): New class.
7043 (Incremental_inputs_header_writer): Edit comment.
7044 (Incremental_inputs_entry): New class.
7045 (Incremental_inputs_entry_writer): Edit comment.
7046 (Sized_incremental_binary::do_find_incremental_inputs_section):
7047 Add *strtab_shndx parameter, fill it.
7048 (Sized_incremental_binary::do_check_inputs): New method.
7049 (Incremental_checker::can_incrementally_link_output_file): Use
7050 Sized_incremental_binary::check_inputs.
7051 (Incremental_inputs::report_command_line): Save command line in
7054 (Incremental_binary::find_incremental_inputs_section): New
7056 (Incremental_binary::do_find_incremental_inputs_section): Add
7057 strtab_shndx parameter.
7058 (Incremental_binary::do_check_inputs): New pure virtual method.
7059 (Sized_incremental_binary::do_check_inputs): Declare.
7060 (Incremental_checker::Incremental_checker): Add incremental_inputs
7061 parameter, use it to initialize incremental_inputs_.
7062 (Incremental_checker::incremental_inputs_): New field.
7063 (Incremental_checker::command_line): New method.
7064 (Incremental_checker::inputs): New method.
7065 (Incremental_checker::command_line_): New field.
7069 * incremental.cc: Include <cstdarg> and "target-select.h".
7070 (vexplain_no_incremental): New function.
7071 (explain_no_incremental): New function.
7072 (Incremental_binary::error): New method.
7073 (Sized_incremental_binary::do_find_incremental_inputs_section): New
7075 (make_sized_incremental_binary): New function.
7076 (open_incremental_binary): New function.
7077 (can_incrementally_link_file): Add checks if output is ELF and has
7079 * incremental.h: Include "elfcpp_file.h" and "output.h".
7080 (Incremental_binary): New class.
7081 (Sized_incremental_binary): New class.
7082 (open_incremental_binary): Declare.
7083 * object.cc (is_elf_object): Use
7084 elfcpp::Elf_recognizer::is_elf_file.
7085 (make_elf_object): Use elfcpp::Elf_recognizer::is_valid_header.
7086 * output.h (Output_file::filesize): New method.
7090 * arm.cc (Arm_relocate_functions::extract_arm_movw_movt_addend):
7092 (Arm_relocate_functions::insert_val_arm_movw_movt): New function.
7093 (Arm_relocate_functions::extract_thumb_movw_movt_addend): New
7095 (Arm_relocate_functions::insert_val_thumb_movw_movt): New
7097 (Arm_relocate_functions::movw_abs_nc): New function.
7098 (Arm_relocate_functions::movt_abs): New function.
7099 (Arm_relocate_functions::thm_movw_abs_nc): New function.
7100 (Arm_relocate_functions::thm_movt_abs): New function.
7101 (Scan::local): Handle R_ARM_MOVW_ABS_NC, R_ARM_MOVT_ABS,
7102 R_ARM_THM_MOVW_ABS_NC, R_ARM_THM_MOVT_ABS.
7103 (Scan::global): Likewise.
7104 (Relocate::relocate): Likewise.
7105 (Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
7109 * arm.cc (Arm_relocate_functions::got_prel) New function.
7110 (Scan::local, Scan::global): Handle R_ARM_GOT_PREL.
7111 (Relocate::relocate): Likewise.
7112 (Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
7116 * options.h (class General_options): Define
7117 split_stack_adjust_size parameter.
7118 * object.h (class Object): Add uses_split_stack_ and
7119 has_no_split_stack_ fields. Add uses_split_stack and
7120 has_no_split_stack accessor functions. Declare
7121 handle_split_stack_section.
7122 (class Reloc_symbol_changes): Define.
7123 (class Sized_relobj): Define Function_offsets. Declare
7124 split_stack_adjust, split_stack_adjust_reltype, and
7126 * object.cc (Object::handle_split_stack_section): New function.
7127 (Sized_relobj::do_layout): Call handle_split_stack_section.
7128 * dynobj.cc (Sized_dynobj::do_layout): Call
7129 handle_split_stack_section.
7130 * reloc.cc (Sized_relobj::relocate_sections): Call
7131 split_stack_adjust for executable sections in split_stack
7132 objects. Pass reloc_map to relocate_section.
7133 (Sized_relobj::split_stack_adjust): New function.
7134 (Sized_relobj::split_stack_adjust_reltype): New function.
7135 (Sized_relobj::find_functions): New function.
7136 * target-reloc.h: Include "object.h".
7137 (relocate_section): Add reloc_symbol_changes parameter. Change
7139 * target.h (class Target): Add calls_non_split method. Declare
7140 do_calls_non_split virtual method. Declare match_view and
7142 * target.cc: Include "elfcpp.h".
7143 (Target::do_calls_non_split): New function.
7144 (Target::match_view): New function.
7145 (Target::set_view_to_nop): New function.
7146 * gold.cc (queue_middle_tasks): Give an error if mixing
7147 split-stack and non-split-stack objects with -r.
7148 * i386.cc (Target_i386::relocate_section): Add
7149 reloc_symbol_changes parameter.
7150 (Target_i386::do_calls_non_split): New function.
7151 * x86_64.cc (Target_x86_64::relocate_section): Add
7152 reloc_symbol_changes parameter.
7153 (Target_x86_64::do_calls_non_split): New function.
7154 * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes
7156 * powerpc.cc (Target_powerpc::relocate_section): Add
7157 reloc_symbol_changes parameter.
7158 * sparc.cc (Target_sparc::relocate_section): Add
7159 reloc_symbol_changes parameter.
7160 * configure.ac: Call AM_CONDITIONAL for the default target.
7161 * configure: Rebuild.
7162 * testsuite/Makefile.am (TEST_AS): New variable.
7163 (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh.
7164 (check_DATA): Add split_i386 and split_x86_64 files.
7165 (SPLIT_DEFSYMS): Define.
7166 (split_i386_[1234n].o): New targets.
7167 (split_i386_[124]): New targets.
7168 (split_i386_[1234r].stdout): New targets.
7169 (split_x86_64_[1234n].o): New targets.
7170 (split_x86_64_[124]): New targets.
7171 (split_x86_64_[1234r].stdout): New targets.
7172 (MOSTLYCLEANFILES): Add new executables.
7173 * testsuite/split_i386.sh: New file.
7174 * testsuite/split_x86_64.sh: New file.
7175 * testsuite/split_i386_1.s: New file.
7176 * testsuite/split_i386_2.s: New file.
7177 * testsuite/split_i386_3.s: New file.
7178 * testsuite/split_i386_4.s: New file.
7179 * testsuite/split_i386_n.s: New file.
7180 * testsuite/split_x86_64_1.s: New file.
7181 * testsuite/split_x86_64_2.s: New file.
7182 * testsuite/split_x86_64_3.s: New file.
7183 * testsuite/split_x86_64_4.s: New file.
7184 * testsuite/split_x86_64_n.s: New file.
7185 * testsuite/testfile.cc (Target_test): Update relocation_section
7187 * testsuite/Makefile.in: Rebuild.
7191 * i386.cc (class Target_i386::Relocate): Add ldo_addrs_ field.
7192 (Target_i386::Relocate::relocate_tls): Call fix_up_ldo before
7193 changing local_dynamic_type_ from LOCAL_DYNAMIC_NONE. When
7194 handling R_386_TLS_LDO_32, if local_dynamic_type_ is NONE, push
7195 the address on ldo_addrs_.
7196 (Target_i386::Relocate::fix_up_ldo): New function.
7200 * plugin.cc (add_input_library): New.
7201 (Plugin::load): Add add_input_library to tv.
7202 (Plugin_manager::add_input_file): Add the is_lib argument.
7203 (add_input_file): Update call to Plugin_manager::add_input_file.
7204 (add_input_library): New.
7205 * plugin.h (Plugin_manager::add_input_file): Add the is_lib argument.
7209 * arm.cc (Target_arm::may_need_copy_reloc): Check for THUMB function
7210 symbol and call Symbol::may_need_copy_reloc to determine if
7211 a copy reloc is needed.
7212 * copy-relocs.cc (Copy_relocs::need_copy_reloc): Return false if -z
7213 nocopyreloc is given in command line.
7214 (Copy_relocs::emit_copy_reloc): Assert that -z nocopyreloc is not
7215 given in command line.
7216 * i386.cc (Target_i386::may_need_copy_reloc): Remove.
7217 (Target_i386::Scan::global): Use Symbol::may_need_copy_reloc instead
7218 of the removed Target_i386::may_need_copy_reloc.
7219 * options.h (copyreloc): New option with default value false.
7220 * powerpc.cc (Target_powerpc::may_need_copy_reloc): Remove.
7221 (Target_powerpc::Scan::global): Use Symbol::may_need_copy_reloc
7222 instead of the removed Target_powerpc::may_need_copy_reloc.
7223 * sparc.cc (Target_powerpc::may_need_copy_reloc): Remove.
7224 (Target_sparc::Scan::global): Use Symbol::may_need_copy_reloc
7225 instead of the removed Target_sparc::may_need_copy_reloc.
7226 * symtab.h (Symbol::may_need_copy_reloc): New method definition.
7227 * x86_64.cc (Target_powerpc::may_need_copy_reloc): Remove.
7228 (Target_x86_64::Scan::global): Use Symbol::may_need_copy_reloc
7229 instead of the removed Target_x86_64::may_need_copy_reloc.
7233 * object.h (class Object): Remove target_ field, and target,
7234 sized_target, and set_target methods.
7235 (Object::sized_target): Remove.
7236 (class Sized_relobj): Update declarations. Remove sized_target.
7237 * object.cc (Sized_relobj::setup): Remove target parameter.
7239 (Input_objects::add_object): Don't do anything with the target.
7240 (make_elf_sized_object): Add punconfigured parameter. Change all
7241 callers. Set or test parameter target.
7242 * dynobj.cc (Sized_dynobj::target): Remove target parameter.
7244 * parameters.cc (Parameters::set_target): Change parameter type to
7246 (Parameters::default_target): Remove.
7247 (set_parameters_target): Change parameter type to be non-const.
7248 (parameters_force_valid_target): New function.
7249 (parameters_clear_target): New function.
7250 * parameters.h (class Parameters): Update declarations. Remove
7251 default_target method. Add sized_target and clear_target
7252 methods. Change target_ to be non-const.
7253 (set_parameters_target): Update declaration.
7254 (parameters_force_valid_target): Declare.
7255 (parameters_clear_target): Declare.
7256 * readsyms.cc (Read_symbols::do_read_symbols): Pass punconfigured
7257 as NULL if we aren't searching.
7258 (Add_symbols::run): Don't check for compatible target.
7259 * fileread.cc (Input_file::open_binary): Call
7260 parameters_force_valid_target.
7261 * gold.cc (queue_middle_tasks): Likewise.
7262 * plugin.cc (make_sized_plugin_object): Likewise. Don't call
7263 set_target on object.
7264 * dynobj.h (class Sized_dynobj): Update declarations.
7265 * archive.cc (Archive::get_elf_object_for_member): Return NULL if
7266 make_elf_object returns NULL.
7267 (Archive::include_member): Don't check whether object target is
7269 * output.cc (Output_section::add_input_section): Get target from
7271 (Output_section::relax_input_section): Likewise.
7272 * reloc.cc (Sized_relobj::do_gc_process_relocs): Get target from
7274 (Sized_relobj::do_scan_relocs): Likewise.
7275 (Sized_relobj::relocate_sections): Likewise.
7276 * resolve.cc (Symbol_table::resolve): Likewise.
7277 * symtab.cc (Symbol_table::wrap_symbol): Likewise. Remove object
7278 parameter. Change all callers.
7279 (Symbol_table::add_from_object): Get target from parameters.
7280 (Symbol_table::add_from_relobj): Don't check object target.
7281 (Symbol_table::add_from_dynobj): Likewise.
7282 (Symbol_table::define_special_symbol): Get target from
7284 * symtab.h (class Symbol_table): Update declaration.
7285 * testsuite/binary_unittest.cc (gold_testsuite): Remove target
7286 parameter. Change all callers. Clear parameter target.
7287 (Binary_test): Test target here.
7288 * testsuite/object_unittest.cc (gold_testsuite): Remove
7289 target_test_pointer parameter. Change all callers.
7290 (Object_test): Test target here.
7294 * testsuite/initpri1.c: Don't try to use constructor priorities if
7295 compiling with gcc before 4.3.
7299 * testsuite/retain_symbols_file_test.sh (check_present): Change
7300 output file name to retain_symbols_file_test.stdout.
7301 (check_absent): Likewise.
7305 * object.cc (Sized_relobj::do_count): Test should_retain_symbol map.
7306 * options.cc: Include <cerrno> and <fstream>.
7307 (General_options::finalize): Parse -retain-symbols-file tag.
7308 * options.h: New flag.
7309 (General_options): New method should_retain_symbol, new
7310 variable symbols_to_retain.
7311 * symtab.cc (Symbol_table::sized_finalize_symbol): Test
7312 should_retain_symbol map.
7313 * testsuite/Makefile.am (retain_symbols_file_test): New test.
7314 * testsuite/Makefile.in: Regenerate.
7315 * testsuite/retain_symbols_file_test.sh: New file.
7319 * po/es.po: Updated Spanish translation.
7323 * debug.h (DEBUG_RELAXATION): New constant.
7324 (DEBUG_ALL): Add DEBUG_RELAXATION.
7325 (debug_string_to_enum): Add relaxation debug option.
7327 (Layout::Relaxation_debug_check::check_output_data_for_reset_values,
7328 Layout::Relaxation_debug_check::read_sections,
7329 Layout::Relaxation_debug_check::read_sections): New method definitions.
7330 (Layout::Layout): Initialize data members
7331 record_output_section_data_from_scrips_,
7332 script_output_section_data_list_ and relaxation_debug_check_.
7333 (Layout::save_segments, Layout::restore_segments,
7334 Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
7335 Layout::relaxation_loop_body): New method definitions.
7336 (Layout::finalize): Support relaxation. Move section layout code to
7337 Layout::relaxation_loop_body.
7338 (Layout::set_asection_address_from_script): Move code for orphan
7339 section placement out.
7340 (Layout::place_orphan_sections_in_script): New method definition.
7341 * layout.h (Output_segment_headers, Output_file_header):
7342 New forward class declarations.
7343 (Layout::~Layout): Define.
7344 (Layout::new_output_section_data_from_script): New method definition.
7345 (Layout::place_orphan_sections_in_script): New method declaration.
7346 (Layout::Segment_states): New type declaration.
7347 (Layout::save_segments, Layout::restore_segments,
7348 Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
7349 Layout::relaxation_loop_body): New method declarations.
7350 (Layout::Output_section_data_list): New type declaration.
7351 (Layout::Relaxation_debug_check): New class definition.
7352 (Layout::record_output_section_data_from_script_,
7353 Layout::script_output_section_data_list_, Layout::segment_states_,
7354 Layout::relaxation_debug_check_): New data members.
7355 * output.cc: (Output_section_headers::do_size): New method definition.
7356 (Output_section_headers::Output_section_headers): Move size
7357 computation to Output_section_headers::do_size.
7358 (Output_segment_headers::do_size): New method definition.
7359 (Output_file_header::Output_file_header): Move size computation to
7360 Output_file_header::do_size and call it.
7361 (Output_file_header::do_size): New method definition.
7362 (Output_data_group::Output_data_group): Adjust call to
7363 Output_section_data.
7364 (Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
7365 (Output_symtab_xindex::do_write): Add array bound check.
7366 (Output_section::Input_section::print_to_mapfile): Handle
7367 RELAXED_INPUT_SECTION_CODE.
7368 (Output_section::Output_section): Initialize data member checkpoint_.
7369 (Output_section::~Output_section): Delete checkpoint object pointed
7371 (Output_section::add_input_section): Always add an Input_section if
7373 (Output_section::add_merge_input_section): Add assert.
7374 (Output_section::relax_input_section): New method definition.
7375 (Output_section::set_final_data_size): Set load address to zero for
7376 an unallocated section.
7377 (Output_section::do_address_and_file_offset_have_reset_values):
7378 New method definition.
7379 (Output_section::Input_section_sort_enty::Input_section_sort_enty):
7380 Handle relaxed input section.
7381 (Output_section::sort_attached_input_sections): Checkpoint input
7382 section list lazily.
7383 (Output_section::get_input_sections): Change type of input_sections to
7384 list of Simple_input_section pointers. Checkpoint input section list
7385 lazily. Also handle relaxed input sections.
7386 (Output_section::add_input_section_for_script): Take a reference to
7387 a Simple_input_section object instead of Relobj pointer and section
7388 index as parameter. Handle relaxed input sections.
7389 (Output_section::save_states, Output_section::restore_states): New
7391 * output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
7392 (Output_data::is_data_size_fixed): New method definition.
7393 (Output_data::reset_addresss_and_file_offset): Do not reset data size
7395 (Output_data::address_and_file_offset_have_reset_values): New method
7397 (Output_data::do_address_and_file_offset_have_reset_values): New method
7399 (Output_data::set_data_size): Check that data size is not fixed.
7400 (Output_data::fix_data_size): New method definition.
7401 (Output_data::is_data_size_fixed_): New data member.
7402 (Output_section_headers::set_final_data_size): New method definition.
7403 (Output_section_headers::do_size): New method declaration.
7404 (Output_segment_headers::set_final_data_size): New method definition.
7405 (Output_segment_headers::do_size): New method declaration.
7406 (Output_file_header::set_final_data_size)::New method definition.
7407 (Output_file_header::do_size)::New method declaration.
7408 (Output_section_data::Output_section_data): Add new parameter
7409 is_data_size_fixed and use it to fix data size.
7410 (Output_data_const::Output_data_const): Adjust call to base class
7411 constructor and fix data size.
7412 (Output_data_const_buffer::Output_data_const_buffer): Adjust call to
7413 base class constructor and fix data size.
7414 (Output_data_fixed_space::Output_data_fixed_space): Adjust call to
7415 base class constructor and fix data size.
7416 (Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
7417 class constructor and fix data size.
7418 (Output_data_group::set_final_data_size): New method definition.
7419 (Output_data_dynamic::Dynamic_entry::tag): New method definition.
7420 (Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
7421 class constructor and fix data size.
7422 (Output_relaxed_input_section): New class definition.
7423 (Output_section::Simple_input_section): New class definition.
7424 (Output_section::get_input_sections): Adjust parameter list.
7425 (Output_section::add_input_section_for_script): Same.
7426 (Output_section::save_states, Output_section::restore_states,
7427 Output_section::do_address_and_file_offset_have_reset_values,
7428 (Output_section::Input_section::Input_section): Handle
7429 RELAXED_INPUT_SECTION_CODE. Add new overload for
7430 Output_relaxed_input_section.
7431 (Output_section::Input_section::is_input_section,
7432 Output_section::Input_section::set_output_section): Handle relaxed
7434 (Output_section::Input_section::is_relaxed_input_section,
7435 Output_section::Input_section::output_section_data,
7436 Output_section::Input_section::relaxed_input_section): New method
7438 (Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
7440 (Output_section::Input_section::u1_): Update comments.
7441 (Output_section::Input_section::u2_): Add new union member poris.
7442 (Output_section::Checkpoint_output_section): New classs definition.
7443 (Output_section::relax_input_section): New method declaration.
7444 (Output_section::checkpoint_): New data member.
7445 (Output_segment): Update comments.
7446 (Output_segment::Output_segment): Un-privatize copy constructor.
7447 (Output_segment::operator=): Un-privatize.
7448 * script-sections.cc (Output_section_element::Input_section_list):
7449 Change element type to Output_section::Simple_input_section.
7450 (Output_section_element_dot_assignment::set_section_addresses):
7451 Register output section data for relaxation clean up.
7452 (Output_data_exression::Output_data_expression): Adjust call to base
7453 constructor to fix data size.
7454 (Output_section_element_data::set_section_addresses): Register
7455 Output_data_expression object for relaxation clean up.
7456 (struct Input_section_info): Replace Relobj pointer and section index
7457 pair with Output_section::Simple_input_section and Convert struct to a
7459 (Input_section_sorter::operator()): Adjust access to
7460 Input_section_info data member to use accessors.
7461 (Output_section_element_input::set_section_addresses): Use layout
7462 parameter. Adjust code to use Output_section::Simple_input_section
7463 and Input_secction_info classes. Register filler for relaxation
7465 (Orphan_output_section::set_section_addresses): Replace Relobj pointer
7466 and section index pair with Output_section::Simple_input_section
7467 class. Adjust code accordingly.
7468 (Phdrs_element::release_segment): New method definition.
7469 (Script_sections::attach_sections_using_phdrs_clause): Do not modify
7471 (Script_sections::release_segments): New method definition.
7472 * gold/script-sections.h (Script_sections::release_segments): New
7474 * gold/target.h (Target::may_relax, Target::relax,
7475 Target::do_may_relax, Target::do_relax): New method definitions.
7479 * arm.cc (has_signed_unsigned_overflow): New function.
7480 (Arm_relocate_functions::abs8): New function.
7481 (Target_arm::Scan::local): Handle R_ARM_ABS8.
7482 (Target_arm::Scan::global): Likewise.
7483 (Target_arm::relocate::relocate): Likewise.
7484 (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
7489 * testsuite/Makefile.am (MOSTLYCLEANFILES): Add more generated files.
7490 * testsuite/Makefile.in: Regenerate.
7494 * po/gold.pot: Updated by the Translation project.
7498 * output.cc (Output_file::open): Add execute permission to empty file.
7499 * testsuite/Makefile.am (permission_test): New test.
7500 * testsuite/Makefile.in: Regenerate.
7504 * output.cc (Output_file::resize): Call map_no_anonymous rather
7509 * gold.cc: Include "incremental.h".
7510 (queue_initial_tasks): Call Incremental_checker methods.
7511 * incremental.cc: Include "output.h".
7512 (Incremental_checker::can_incrementally_link_output_file): New
7514 * incremental.h (Incremental_checker): New class.
7516 * output.cc (Output_file::open_for_modification): New method.
7517 (Output_file::map_anonymous): Changed return type to bool. Record
7519 (Output_file::map_no_anonymous): New method, broken out of map.
7520 (Output_file::map): Use map_no_anonymous and map_anonymous.
7521 * output.h (class Output_file): Update declarations.
7525 * options.h (Command_line::Pre_options): New class.
7526 (Command_line::pre_options): New member.
7527 * options.cc (gold::options::ready_to_register): New variable.
7528 (One_option::register_option): Do nothing if not registering options.
7529 Assert if same short option registered twice.
7530 (General_options::General_options): Turn off option registration when
7532 (Command_line::Pre_options::Pre_options): New constructor.
7536 * options.h (General_options::no_keep_memory): Remove incorrect
7541 * Makefile.am (am__skiplex, am__skipyacc): New.
7542 * Makefile.in: Regenerate.
7546 * Makefile.am (AM_CPPFLAGS): Renamed from ...
7547 (INCLUDES): ... this.
7548 * testsuite/Makefile.am (AUTOMAKE_OPTIONS): Add -Wno-portability.
7549 (AM_CPPFLAGS): Renamed from ...
7550 (INCLUDE): ... this.
7551 * Makefile.in, testsuite/Makefile.in: Regenerate.
7553 * Makefile.in: Regenerate.
7554 * aclocal.m4: Likewise.
7555 * config.in: Likewise.
7556 * configure: Likewise.
7557 * testsuite/Makefile.in: Likewise.
7559 * Makefile.am (AUTOMAKE_OPTIONS): Add foreign.
7560 * testsuite/Makefile.am (AUTOMAKE_OPTIONS): Add foreign.
7561 * Makefile.in: Regenerate.
7562 * testsuite/Makefile.in: Regenerate.
7566 * resolve.cc (Symbol_table::resolve): Don't complain about defined
7567 symbols in shared libraries overridden by hidden or internal symbols
7568 in the main program.
7572 * testsuite/debug_msg.sh: Match .* rather than ${srcdir} when
7573 checking source file names in error messages.
7577 * dynobj.cc (Sized_dynobj::setup): Take a Target object instead of
7578 an elcpp::Ehdr as parameter. Adjust call to set_target.
7579 * dynobj.h (Sized_dynobj::setup): Take a Target object instead of
7580 an elfcpp::Ehdr as parameter.
7581 * object.cc (Object::set_target): Remove the version that looks up
7582 a target and sets it.
7583 (Sized_relobj::setup): Take a Target object instead of
7584 an elfcpp::Ehdr as parameter. Adjust call to set_target.
7585 (make_elf_sized_object): Find target and ask target to
7587 * object.h: (Object::set_target): Remove the version that looks up
7588 a target and sets it.
7589 (Sized_relobj::setup): Take a Target object instead of
7590 an elfcpp:Ehdr as parameter.
7591 * target.cc: Include dynobj.h.
7592 (Target::do_make_elf_object_implementation): New.
7593 (Target::do_make_elf_object): New.
7594 * target.h (Target::make_elf_object): New template declaration.
7595 (Target::do_make_elf_object): New method declarations.
7596 (Target::do_make_elf_object_implementation): New template declaration.
7600 * gold.h (FUNCTION_NAME): Define.
7601 (gold_unreachable): Use FUNCTION_NAME.
7605 * icf.cc (Icf::find_identical_sections): Issue a warning when a
7606 symbol in the --keep-unique list is not found.
7610 * icf.cc (Icf::find_identical_sections): Unfold symbols that have
7611 been maked as --keep-unique.
7612 (Icf::unfold_section): New function.
7613 * icf.h (Icf::unfold_section): New function.
7614 * options.h (General_options::keep_unique): New option.
7615 * testsuite/Makefile.am: Add commands to build icf_keep_unique_test.
7616 * testsuite/Makefile.in: Regenerate.
7617 * testsuite/icf_keep_unique_test.sh: New file.
7618 * testsuite/icf_keep_unique_test.cc: New file.
7623 * resolve.cc (Symbol_table::resolve): Check for references from
7624 dynamic objects to hidden and internal symbols.
7625 * testsuite/Makefile.am (hidden_test.sh): New test.
7626 * testsuite/Makefile.in: Regenerate.
7627 * testsuite/hidden_test.sh: New script.
7628 * testsuite/hidden_test_1.c: New test source.
7629 * testsuite/hidden_test_main.c: New test source.
7633 * arm.cc: Update comments.
7634 (Target_arm::do_finalize_sections): Add a special PT_ARM_EXIDX
7635 segment to locate the .ARM.exidx section if present.
7639 * dynobj.h (Sized_dynobj::do_section_entsize): Revert the previous
7643 * dynobj.h (Sized_dynobj::do_section_entsize): Add return to avoid
7648 * x86_64.cc (Target_x86_64::Relocate::relocate_tls): Check for a
7649 valid tls_segment only for non-debug-section relocations.
7650 * testsuite/Makefile.am: Add gc_tls_test.
7651 * testsuite/Makefile.in: Regenerate.
7652 * testsuite/gc_tls_test.cc: New file.
7653 * testsuite/gc_tls_test.sh: New file.
7659 * Makefile.am (CCFILES): Add icf.cc.
7661 * Makefile.in: Regenerate.
7662 * dynobj.h (Sized_dynobj::do_section_entsize): New function.
7663 * gc.h (gc_process_relocs): Populate lists used by icf to contain
7664 section, symbol and addend information for the relocs.
7665 * gold.cc (queue_middle_tasks): Call identical code folding.
7666 * gold.h: Add defines for multimap.
7667 * layout.cc (Layout::create_symtab_sections): Add symtab as parameter
7668 to the call of finalize_local_symbols.
7669 * main.cc (main): Create object of class Icf.
7670 * object.cc (Sized_relobj::do_layout): Allow this function to be
7671 called twice during icf.
7672 (Sized_relobj::do_finalize_local_symbols): Fold symbols corresponding
7673 to sections marked as identical by icf.
7674 (Sized_relobj::do_section_flags): Get section_flags from Symbols_data
7676 (Sized_relobj::do_section_entsize): New function.
7677 * object.h (Object::section_entsize): New function.
7678 (Object::do_section_entsize): New pure virtual function.
7679 (Relobj::finalize_local_symbols): Add new parameter.
7680 (Relobj::do_section_entsize): New function.
7681 * options.h (General_options::icf): New option.
7682 (General_options::icf_iterations): New option.
7683 (General_options::print_icf_sections): New option.
7684 * plugin.cc (Sized_pluginobj::do_section_entsize): New function.
7685 * plugin.h (Sized_pluginobj::do_section_entsize): New function.
7686 * reloc.cc (Read_relocs::run): Delay scanning relocs when doing
7688 * symtab.cc (Symbol_table::is_section_folded): New function.
7689 (Symbol_table::sized_finalize_symbol): Fold symbols corresponding
7690 to sections marked as identical by icf.
7691 * symtab.h (Symbol_table::set_icf): New function.
7692 (Symbol_table::icf): New function.
7693 (Symbol_table::is_section_folded): New function.
7694 (Symbol_table::icf_): New data member.
7695 * target-reloc.h (relocate_section): Ignore sections folded by icf.
7696 * testsuite/Makefile.am: Add commands to build icf_test.
7697 * testsuite/Makefile.in: Regenerate.
7698 * testsuite/icf_test.sh: New file.
7699 * testsuite/icf_test.cc: New file.
7703 * layout.cc (is_compressible_debug_section): Fix incorrect
7704 comment about compressed section names.
7709 * x86_64.cc (Target_x86_64::do_code_fill): Correct nop sequences.
7714 * layout.h: #include <map>.
7715 (class Kept_section): Change from struct to class. Add accessors
7716 and setters. Add section size to Comdat_group mapping. Change
7717 Comdat_group to std::map. Add is_comdat_ field. Add
7718 linkonce_size field in union.
7719 (class Layout): Update declaration of find_or_add_kept_section.
7720 Don't declare find_kept_object.
7721 * layout.cc (Layout::find_or_add_kept_section): Remove candidate
7722 parameter. Add object, shndx, is_comdat, and is_group_name
7723 parameters. Change all callers. Adjust for new Kept_section.
7724 (Layout::find_kept_object): Remove.
7725 * object.cc (Sized_relobj::include_section_group): Update use of
7726 Kept_section. Rename secnum to shndx. Only record
7727 Kept_comdat_section if sections are the same size.
7728 (Sized_relobj::include_linkonce_section): Update use of
7729 Kept_section. Only record Kept_comdat_section if sections are the
7730 same size. Set size of linkonce section.
7731 (Sized_relobj::map_to_kept_section): Update call to
7732 get_kept_comdat_section.
7733 * object.h (class Sized_relobj): Rename fields in
7734 Kept_comdat_section to drop trailing underscores; change object
7735 field to Relobj*. Change Kept_comdat_section_table to store
7736 struct rather than pointer.
7737 (Sized_relobj::set_kept_comdat_section): Remove kept parameter.
7738 Add kept_object and kept_shndx parameters. Change all callers.
7739 (Sized_relobj::get_kept_comdat_section): Change return type to
7740 bool. Add kept_object and kept_shndx parameters. Change all
7742 * plugin.cc (Pluginobj::include_comdat_group): Update call to
7743 Layout::find_or_add_kept_section.
7747 * merge.cc (Object_merge_map::initialize_input_to_output_map):
7748 Reserve space in the hash table.
7752 * fileread.cc (File_read::get_mtime): New method.
7753 * fileread.h (Timespec): New structure.
7754 (File_read::get_mtime): New method.
7755 * incremental.cc (Incremental_inputs_entry_data::timestamp_usec):
7756 Renamed from timestamp_nsec.
7757 (Incremental_inputs_entry_write::timestamp_sec): Fix argument to
7759 (Incremental_inputs_entry_write::timestamp_usec): Renamed from
7761 (Incremental_inputs::report_archive): Save mtime; style fix.
7762 (Incremental_inputs::report_obejct): Save mtime; style fix.
7763 (Incremental_inputs::report_script): Save mtime; style fix.
7764 (Incremental_inputs::finalize_inputs): Style fix.
7765 (Incremental_inputs::finalize): Style fix.
7766 (Incremental_inputs::create_input_section_data): Store inputs
7768 * incremental.h (Incremental_inputs::report_script): Add mtime
7770 (Incremental_inputs::Input_info::Input_info): Intialize only one
7772 (Incremental_inputs::Input_info::archive): Move to nameless
7774 (Incremental_inputs::Input_info::obejct): Move to nameless union.
7775 (Incremental_inputs::Input_info::script): Move to nameless union.
7776 (Incremental_inputs::mtime): New field.
7777 * script.cc (read_input_script): Pass file mtime to
7779 * script.h (Script_info::inputs): Style fix.
7783 * freebsd.h (Target_freebsd::do_adjust_elf_header): Use size
7789 * layout.cc (Layout::choose_output_section): If we find an
7790 existing section, update the flags.
7791 (Layout::create_notes): New function, broken out of
7793 (Layout::finalize): Don't create note sections.
7794 (Layout::create_note): Don't crash if linker script discards
7796 (Layout::create_gold_note): Likewise.
7797 (Layout::create_build_id): Likewise. Don't set
7798 after_input_sections on the section.
7799 (Layout::create_executable_stack_info): Remove target parameter.
7801 * layout.h (class Layout): Declare create_notes. Update
7802 declaration of create_executable_stack_info.
7803 * gold.cc (queue_middle_tasks): Call create_notes.
7804 * output.cc (Output_section::update_flags_for_input_section): Move
7805 here from output.h. If SHF_ALLOC flag is newly set, mark address
7807 * output.h (Output_data::mark_address_invalid): New function.
7808 (class Output_section): Only declare, not define,
7809 update_flags_for_input_section. Remove set_flags.
7813 * script-sections.cc (Output_section_definition::
7814 set_section_addresses): Rename shadowing local load_address to
7820 * reloc.cc (relocate_sections): Skip empty relocation sections.
7825 * layout.cc (Layout::create_note): Use choose_output_section
7826 rather than make_output_section.
7831 * options.cc (General_options::parse_V): Set printed_version_.
7832 (General_options::General_options): Initialize printed_version_.
7833 * options.h (class General_options): Add printed_version_ field.
7834 * gold.cc (queue_initial_tasks): If there are no input files,
7835 don't give a fatal error if we printed the version information.
7836 (queue_middle_tasks): If using -r with a shared object, give a
7837 fatal error rather than an ordinary error.
7842 * layout.cc (Layout::Layout): Initialize have_stabstr_section_.
7843 (Layout::make_output_section): Set have_stabstr_section_ if we see
7844 a .stab*str section.
7845 (Layout::finalize): Call link_stabs_sections.
7846 (Layout::link_stabs_sections): New file.
7847 * layout.h (class Layout): Add have_stabstr_section_ field.
7848 Declare link_stabs_sections.
7852 * Makefile.am (libgold_a_LIBADD): New.
7853 (ld_new_DEPENDENCIES, ld_new_LDADD): Remove LIBOBJS
7854 * Makefile.in: Regenerate.
7855 * config.in (HAVE_DECL_MEMMEM, HAVE_DECL_STRNDUP): New.
7856 * configure: Regenerate.
7857 * configure.ac (AC_CHECK_DECLS): Add strndup and memmem.
7858 * fileread.cc: Include sys/state.h
7859 * gold.h: Declare memmem and strndup if found missing.
7860 * gold_reloc.h: Include byteswap.h if HAVE_BYTESWAP_H is defined.
7864 * configure.ac: Call AC_CHECK_DECLS using C, not C++.
7865 * configure: Rebuild.
7870 * object.cc (Object::section_contents): Don't try to get a view if
7871 the section has length zero.
7872 (Object::handle_gnu_warning_section): If the section is empty, use
7873 the name of the section as the warning.
7878 * stringpool.h (class Stringpool_template): Add optimize_ field.
7879 (Stringpool_template::set_optimize): New function.
7880 * stringpool.cc (Stringpool_template::Stringpool_template):
7881 Initialize optimize_ field.
7882 (Stringpool_template::set_string_offsets): Test local optimize
7883 fild rather than parameter.
7884 * layout.cc (Layout::Layout): Call set_optimize on the section
7890 * yyscript.y: Parse TARGET.
7891 * script.cc (script_set_target): New function.
7892 * script-c.h (script_set_target): Declare.
7893 * options.cc (General_options::string_to_object_format): Rename
7894 from string_to_object_format in anonymous namespace. Change
7896 * options.h (class General_options): Declare
7897 string_to_object_format.
7901 * script-sections.cc (Script_sections::create_segments): Don't put
7902 program headers in a PT_LOAD segment if -n or -N.
7907 * options.h (class General_options): Add -z lazy and -z now. Sort
7908 -z options into alphabetical order.
7909 * layout.cc (Layout::finish_dynamic_section): Handle -z now.
7913 * layout.cc (Layout::make_output_section): Call
7914 Target::new_output_section.
7915 (Layout::attach_allocated_section_to_segment): Put large section
7916 sections in a separate load segment with the large segment flag
7918 (Layout::segment_precedes): Sort large data segments after other
7920 (align_file_offset): New static function.
7921 (Layout::set_segment_offsets): Use align_file_offset.
7922 * output.h (class Output_section): Add is_small_section_ and
7923 is_large_section_ fields.
7924 (Output_section::is_small_section): New function.
7925 (Output_section::set_is_small_section): New function.
7926 (Output_section::is_large_section): New function.
7927 (Output_section::set_is_large_section): New function.
7928 (Output_section::is_large_data_section): New function.
7929 (class Output_segment): Add is_large_data_segment_ field.
7930 (Output_segment::is_large_data_segment): New function.
7931 (Output_segment::set_is_large_data_segment): New function.
7932 * output.cc (Output_section::Output_section): Initialize new
7934 (Output_segment::Output_segment): Likewise.
7935 (Output_segment::add_output_section): Add assertion that large
7936 data sections always go in large data segments. Force small data
7937 sections to the end of the list of data sections. Force small BSS
7938 sections to the start of the list of BSS sections. For large BSS
7939 sections to the end of the list of BSS sections.
7940 * symtab.h (class Symbol): Declare is_common_shndx.
7941 (Symbol::is_defined): Check Symbol::is_common_shndx.
7942 (Symbol::is_common): Likewise.
7943 (class Symbol_table): Define enum Commons_section_type. Update
7944 declarations. Add small_commons_ and large_commons_ fields.
7945 * symtab.cc (Symbol::is_common_shndx): New function.
7946 (Symbol_table::Symbol_table): Initialize new fields.
7947 (Symbol_table::add_from_object): Put small and large common
7948 symbols in the right list.
7949 (Symbol_table::sized_finalized_symbol): Check
7950 Symbol::is_common_shndx.
7951 (Symbol_table::sized_write_globals): Likewise.
7952 * common.cc (Symbol_table::do_allocate_commons): Allocate new
7953 common symbol lists. Don't call do_allocate_commons_list if the
7955 (Symbol_table::do_allocate_commons_list): Remove is_tls
7956 parameter. Add comons_section_type parameter. Change all
7957 callers. Handle small and large common symbols.
7958 * object.cc (Sized_relobj::do_finalize_local_symbols): Check
7959 Symbol::is_common_shndx.
7960 * resolve.cc (symbol_to_bits): Likewise.
7961 * target.h (Target::small_common_shndx): New function.
7962 (Target::small_common_section_flags): New function.
7963 (Target::large_common_shndx): New function.
7964 (Target::large_common_section_flags): New function.
7965 (Target::new_output_section): New function.
7966 (Target::Target_info): Add small_common_shndx, large_common_shndx,
7967 small_common_section_flags, and large_common_section_flags
7969 (Target::do_new_output_section): New virtual function.
7970 * arm.cc (Target_arm::arm_info): Initialize new fields.
7971 * i386.cc (Target_i386::i386_info): Likewise.
7972 * powerpc.cc (Target_powerpc::powerpc_info) [all versions]:
7974 * sparc.c (Target_sparc::sparc_info) [all versions]: Likewise.
7975 * x86_64.cc (Target_x86_64::x86_64_info): Likewise.
7976 (Target_x86_64::do_new_output_section): New function.
7977 * configure.ac: Define conditional MCMODEL_MEDIUM.
7978 * testsuite/Makefile.am (check_PROGRAMS): Add large.
7979 (large_SOURCES, large_CFLAGS, large_DEPENDENCIES): Define.
7980 (large_LDFLAGS): Define.
7981 * testsuite/large.c: New file.
7982 * testsuite/testfile.cc (Target_test::test_target_info):
7983 Initialize new fields.
7984 * configure, testsuite/Makefile.in: Rebuild.
7988 * Makefile.am (CCFILES): Add target.cc.
7989 * Makefile.in: Regenerate.
7990 * i386.cc (class Target_i386): Define new virtual method to
7991 override do_is_local_label_name in parent.
7992 * object.cc (Sized_relobj::do_count_local_symbols): Discard
7993 local symbols if --discard-locals or -X is given.
7994 * options.h (class General_options): Declare new options
7995 '--discard-locals' and '-X' for discarding locals.
7996 * target.h (class Target): Define new methods is_local_label_name.
7997 Declare new virtual method do_is_local_label_name.
7998 * target.cc: New file.
7999 * testsuite/Makefile.am (check_PROGRAMS): Add discard_locals_test.
8000 (check_SCRIPTS): Add discard_locals_test.sh.
8001 (check_DATA): Add discard_local_tests.syms.
8002 (discard_locals_test_SOURCES, discard_locals_test_LDFLAGS): Define.
8003 (discard_local_tests.syms, discard_locals_test.o): New make rules.
8004 * testsuite/Makefile.in: Regenerate.
8005 * testsuite/discard_locals_test.c: New file.
8006 * testsuite/discard_locals_test.sh: Same.
8010 * object.cc (Sized_relobj::Sized_relobj): Initialize
8011 discarded_eh_frame_shndx_ to -1U.
8012 (Sized_relobj::do_layout): Record index of a discard .eh_frame
8014 (Sized_relobj::do_count_local_symbols): Skip local symbols in
8015 a discarded .eh_frame section.
8016 (Sized_relobj::do_finalize_local_symbols): Ditto.
8017 * object.h (class Sized_relobj): Declare new member
8018 discarded_eh_frame_shndx_.
8019 * testsuite/Makefile.am (check_PROGRAMS): Add local_labels_test.
8020 (local_labels_test.o, local_labels_test): New rules.
8021 * testsuite/Makefile.in: Regenerate.
8025 * layout.cc (Layout::section_name_mapping): Add mapping for
8026 special ARM sections.
8030 * arm.cc (utils::sign_extend): Reverse test in gold_assert.
8031 (utils::has_overflow): Same.
8035 * layout.cc (Layout::section_name_mapping): New array, replacing
8036 Layout::linkonce_mapping.
8037 (Layout::section_name_mapping_count): New variable, replacing
8038 Layout::linkonce_mapping_count.
8039 (Layout::linkonce_output_name): Remove.
8040 (Layout::output_section_name): Rewrite.
8041 * layout.h (class Layout): Rename Linkonce_mapping to
8042 Section_name_mapping, linkonce_mapping to section_name_mapping,
8043 linkonce_mapping_count to section_name_mapping_count. Don't
8044 declare linkonce_output_name.
8048 * gold/arm.cc (namespace utils): New.
8049 (Target_arm::reloc_is_non_pic): Define new method.
8050 (class Arm_relocate_functions): New.
8051 (Target_arm::Relocate::relocate): Handle relocation types used by
8056 * arm.cc (Target_arm::scan::global): Use || instead of |.
8060 * gold/arm.cc (Target_arm::Scan::Scan): Initialize
8061 issued_non_pic_error_.
8062 (class Target_arm::Scan): Declare new method check_non_pic.
8063 Define new method symbol_needs_plt_entry.
8064 Declare new data member issued_non_pic_error_.
8065 (class Target_arm::Relocate): Declare new method
8066 should_apply_static_reloc.
8067 (Target_arm::may_need_copy_reloc): Handle STT_ARM_TFUNC.
8068 (Target_arm::Scan::check_non_pic): Define new method.
8069 (Target_arm::Scan::local): Handle a small subset of reloc types used
8071 (Target_arm::Scan::local): Same.
8072 (Target_arm::Relocate::should_apply_statci_reloc): Define new method.
8076 * incremental.cc (Incremental_inputs::report_command_line): Filter
8077 out --incremental-* options.
8081 * gold/arm.cc (Output_data_plt_arm): Forward declaration for new
8083 (class Target_arm): Update comment.
8084 (Target_arm::Target_arm): Initialize new data members GOT_,
8085 PLT_, GOT_PLT_, REL_DYN_, COPY_RELOCS_ and DYNBSS_.
8086 Declare new methods Target_arm::got_section, Target_arm::make_plt_entry
8087 and Target_arm::rel_dyn_section.
8088 Declare new_enum Target_arm::Got_type.
8089 Declare new data members GOT_, PLT_, GOT_PLT_, REL_DYN_, COPY_RELOCS_
8091 Update commments for member do_dynsym_value.
8092 (Target_arm::got_size, Target_arm::plt_section,
8093 Target_arm::may_need_copy_reloc and Target_arm::copy_reloc): Define
8094 new methods inside class defintion.
8095 (Target_arm::got_section): Define new method.
8096 (Target_arm::rel_dyn_section): Same.
8097 (Output_data_plt_arm): New template class.
8098 (Output_data_plt_arm::Output_data_plt_arm): Define constructor.
8099 (Output_data_plt_arm:do_adjust_output_section): Define new method.
8100 (Output_data_plt_arm::add_entry): Same.
8101 (Output_data_plt_arm::first_plt_entry): Define new
8102 static data member for PLT instruction template.
8103 (Output_data_plt_arm::plt_entry): Same.
8104 (Output_data_plt_arm::do_write): Define new method.
8105 (Target_arm::make_plt_entry): Same.
8106 (Target_arm::do_finalize_sections): Same.
8107 (Target_arm::do_dynsym_value): Same.
8111 * Makefile.am (TARGETSOURCES): Add arm.cc.
8112 (ALL_TARGETOBJECTS): Add arm.$(OBJEXT)
8113 * Makefile.in: Regenerate.
8115 * configure.tgt: Add armbe*-*-*, armeb*-*-* and arm*-*-* targets.
8119 * options.cc (General_options::parse_exclude_libs). Fix a comment.
8120 (General_options::check_excluded_libs): Strip off directories in
8121 archive name before matching like GNU ld does.
8122 * testsuite/Makefile.am (MOSTLYCLEANFILES,
8123 exclude_libs_test_DEPENDENCIES): Add alt/libexclude_libs_test_3.a
8124 (exclude_libs_test_LDFLAGS): Add linker option
8125 -Wl,--exclude-libs,libexclude_libs_test_3
8126 (exclude_libs_test_LADD): Add alt/libexclude_libs_test_3.a as
8127 an explicit archive without using -l.
8128 (alt/libexclude_libs_test_3.a): New make rule.
8129 * testsuite/Makefile.in: Regenerate.
8130 * testsuite/exclude_libs_test.c : Declare lib3_default().
8132 * exclude_libs_test.sh: Add tests for alt/exclude_libs_test_3.a.
8133 * exclude_libs_test_3.c: New file.
8137 * po/id.po: New Indonesian translation.
8138 * po/gold.pot: Updated template file.
8142 * testsuite/Makefile.am: Add -ffunction-sections to compile
8143 gc_comdat_test files. Add -Wl,--gc-sections to build
8145 * testsuite/Makefile.in: Regenerate.
8146 * testsuite/gc_comdat_test.sh: Fix the condition around grep.
8150 * object.cc (Sized_relobj::map_to_kept_section): Return NULL if the
8151 kept comdat section was garbage collected.
8152 * testsuite/Makefile.am: Add test gc_comdat_test.sh.
8153 * testsuite/Makefile.in: Regenerate.
8154 * testsuite/gc_comdat_test.sh: New file.
8155 * testsuite/gc_comdat_test_1.cc: New file.
8156 * testsuite/gc_comdat_test_2.cc: New file.
8160 * archive.cc (Archive::Archive): Move constructor from archive.h
8161 to here. Initialize no_export_.
8162 (Archive::get_elf_object_for_member): Set no_export flag of object.
8163 * archive.h (Archive::Archive): Move constructor body to
8165 (Archive::no_export): New method.
8166 (Archive::no_export_): New field.
8167 * object.h (Object::Object): Initialize no_export_ to false.
8168 (Object::no_export, Object::set_no_export): New methods.
8169 (Object::no_export_): New field.
8170 * options.cc (General_options::parse_exclude_libs): New method.
8171 (General_options::check_excluded_libs) Same.
8172 * options.h (exclude_libs): New option.
8173 (General_options::check_excluded_libs): New method declaration.
8174 (General_options::excluded_libs_): New field.
8175 * symtab.cc (Symbol_table::add_from_relobj): Hide symbols with
8176 default or protected visibility if an object has no-export flag set.
8177 testsuite/Makefile.am (check_PROGRAMS): Add exclude_libs_test.
8178 (check_SCRIPTS): Add exclude_libs_test.sh.
8179 (check_DATA): Add exclude_libs_test.syms.
8180 (MOSTLYCLEANFILES): Add exclude_libs_test.syms,
8181 libexclude_libs_test_1.a and libexclude_libs_test_2.a.
8182 (exclude_libs_test_SOURCES, exclude_libs_test_DEPENDENCIES,
8183 exclude_libs_test_LDFLAGS and exclude_libs_test_LDADD): Define.
8184 (exclude_libs_test.syms, libexclude_libs_test_1.a,
8185 libexclude_libs_test_2.a): New rules.
8186 * testsuite/Makefile.in: Regenerate.
8187 * testsuite/exclude_libs_test.c: New file.
8188 * testsuite/exclude_libs_test.sh: Ditto.
8189 * testsuite/exclude_libs_test_1.c: Ditto.
8190 * testsuite/exclude_libs_test_2.c: Ditto.
8194 * configure.ac: Check for declarations for cases where libiberty.h
8195 checks HAVE_DECL_xxx.
8196 * configure, config.in: Rebuild.
8200 * gold.h (Incremental_argument_list): Remove (invalid) forward
8202 * incremental.cc (Incremental_inputs::report_achive): New method.
8203 (Incremental_inputs::report_object): New method.
8204 (Incremental_inputs::report_script): New method.
8205 (Incremental_inputs::finalize_inputs): New method.
8206 (Incremental_inputs::finalize): Call finalize_inputs().
8207 (Incremental_inputs::sized_create_incremental_inputs_section_data):
8208 Create inputs entries.
8209 * incremental.h (Incremental_input_type): New enum.
8210 (Incremental_inputs::Incremental_input): Initialize new fields.
8211 (Incremental_inputs::report_inputs): New method.
8212 (Incremental_inputs::report_achive): New method.
8213 (Incremental_inputs::report_object): New method.
8214 (Incremental_inputs::report_script): New method.
8215 (Incremental_inputs::finalize_inputs): New method.
8216 (Incremental_inputs::Input_info): New struct.
8217 (Incremental_inputs::Input_info_map): New typedef.
8218 (Incremental_inputs::lock_): New field.
8219 (Incremental_inputs::Inputs_): New field.
8220 (Incremental_inputs::Inputs_map): New field.
8221 * main.cc (main): Call Incremental_input::report_inputs.
8222 * options.h (Input_argument_list): Typedef moved from
8224 (Input_file_group::Files): Remove, use ::Input_argument_list.
8225 (Input_file_group::Input_argument_list): Remove, use
8226 ::Input_argument_list.
8227 * plugin.cc (Plugin_manager::add_input_file): Add error in
8229 * read_syms.cc (do_read_syms): Call Incremental_input::report_*
8231 * script.cc (read_input_script): Call
8232 Incremental_input::report_script.
8233 * script.h (Script_info): New class.
8237 * x86_64.cc (do_adjust_output_section): Set entsize to
8242 * output.cc (Output_file::close): After short writes, continue
8243 writing from the correct offset in the buffer being written.
8247 * configure.ac (HAVE_TR1_UNORDERED_MAP_REHASH): New define.
8248 * configure: Regenerate.
8249 * config.in: Regenerate.
8250 * gold.h: Avoid std::tr1::unordered_map and std::tr1::unordered_set
8251 if HAVE_TR1_UNORDERED_MAP_REHASH is not defined.
8255 * incremental.cc (Incremental_inputs_header_data): Renamed from
8256 Incremental_input_header_data.
8257 (Incremental_inputs_header_data::data_size): New field.
8258 (Incremental_inputs_header_data::put_input_file_count): Renamed
8259 from input_file_count.
8260 (Incremental_inputs_header_data::put_command_line_offset): Renamed
8261 from command_line_offset.
8262 (Incremental_inputs_header_data::put_reserved): Renamed from
8264 (Incremental_inputs_entry_data): Renamed from
8265 Incremental_input_entry_data.
8266 (Incremental_inputs_entry_data::data_size): New field.
8267 (Incremental_inputs::report_command_line): New method.
8268 (Incremental_inputs::finalize): New method.
8269 (Incremental_inputs::create_incremental_inputs_data): New method.
8270 (Incremental_inputs::sized_create_incremental_inputs_data): New method.
8271 * incremental.h: New file.
8272 * layout.cc (Layout::Layout): Handle new incremental_inputs_.
8273 (Layout::finalize): Create incremental inputs section in
8275 (Layout::create_incremental_info_sections): New method.
8276 * layout.h (Layout::incremental_inputs): New method.
8277 (Layout::create_incremental_info_sections): New method.
8278 (Layout::incremental_inputs_): New field.
8279 * main.cc (main): Notify Incremental_input of the command line.
8284 * gold.h (reserve_unordered_map): Define, three versions, one for
8285 each version of Unordered_map.
8286 * layout.cc (Layout::Layout): Remove options parameter. Add
8287 number_of_input_files parameter. Don't initialize options_.
8288 Initialize number_of_input_files_ and resized_signatures_. Move
8289 sections_are_attached_.
8290 (Layout::layout_group): Reserve space for group_signatures_.
8291 (Layout::find_or_add_kept_section): Change name parameter to be a
8292 reference. Resize signatures_ map when it gets large enough.
8293 (Layout::layout_eh_frame): Use parameters->options() instead of
8295 (Layout::make_output_section): Likewise.
8296 (Layout::attach_allocated_section_to_segment): Likewise.
8297 (Layout::finalize, Layout::create_executable_stack): Likewise.
8298 (Layout::set_segment_offsets, Layout::create_interp): Likewise.
8299 (Layout::finish_dynamic_section, Layout::write_binary): Likewise.
8300 * layout.h (class Layout): Update declarations. Remove options_
8301 field. Add number_of_input_files_ and resized_signatures_
8302 fields. Move sections_are_attached_ field.
8303 * main.cc (main): Pass number of input files to Layout
8304 constructor. Don't pass options.
8308 * ffsll.c (ffsll): Correct implementation.
8312 * ffsll.c: New file.
8313 * configure.ac: Call AC_REPLACE_FUNCS on ffsll.
8314 * gold.h (ffsll): Declare if HAVE_FFSLL is not defined.
8315 * ftruncate.c (ftruncate): Declare before definition.
8316 * mremap.c (mremap): Likewise.
8317 * pread.c (pread): Likewise.
8318 * configure, Makefile.in, config.in: Rebuild.
8320 * mremap.c: New file.
8321 * configure.ac: Call AC_REPLACE_FUNCS on mremap.
8322 * gold.h (MREMAP_MAYMOVE): Define if HAVE_MREMAP is not defined.
8323 (mremap): Declare if HAVE_MREMAP is not defined.
8324 * configure, Makefile.in, config.in: Rebuild.
8328 * powerpc.cc (Target_powerpc::check_non_pic): Assert that output is
8329 position independent.
8330 * sparc.cc (Target_sparc::check_non_pic): Likewise.
8331 * x86_64.cc (Target_x86_64::check_non_pic): Likewise.
8335 * symtab.h (needs_plt_entry): Check for unsatisfied reference from
8337 (needs_dynamic_reloc): Likewise.
8341 * yyscript.y (file_cmd): Recognize EXTERN.
8342 (extern_name_list, extern_name_list_body): New nonterminals.
8343 * script.cc (script_add_extern): Define.
8344 * script-c.h (script_add_extern): Declare.
8348 * object.cc (is_elf_object): Define.
8349 * object.h (is_elf_object): Declare.
8350 * archive.cc (Archive::get_elf_object_for_member): Call
8352 * readsyms.cc (Read_symbols::do_read_symbols): Likewise.
8356 * output.cc (Output_file::map_anonymous): Define.
8357 (Output_file::map): Use map_anonymous. If the regular mmap fails,
8358 try an anonymous one. Report the size if the mmap fails.
8359 * output.h (class Output_file): Declare map_anonymous.
8363 * target-select.cc (instantiate_target): Don't acquire the lock if
8364 the instantiated_target_ field has already been set.
8368 * gold-threads.h (class Initialize_lock): Define.
8369 * gold-threads.cc (class Initialize_lock_once): Define.
8370 (initialize_lock_control): New static variable.
8371 (initialize_lock_pointer): New static variable.
8372 (initialize_lock_once): New static function.
8373 (Initialize_lock::Initialize_lock): Define.
8374 (Initialize_lock::initialize): Define.
8375 * target-select.h: Include "gold-threads.h".
8376 (class Target_selector): Add lock_ and initialize_lock_ fields.
8377 Don't define instantiate_target, just declare it.
8378 * target-select.cc (Target_selector::Target_selector): Initialize
8380 (Target_selector::instantiate_target): Define.
8381 * descriptors.h: Include "gold-threads.h".
8382 (class Descriptors): Add initialize_lock_ field.
8383 * descriptors.cc (Descriptors::Descriptors): Initialize new
8385 (Descriptors::open): Use initialize_lock_ field
8386 * errors.h (class Errors): Add initialize_lock_ field.
8387 * errors.cc (Errors::Errors): Initialize new field.
8388 (Errors::initialize_lock): Use initialize_lock_ field.
8389 * powerpc.cc (class Target_selector_powerpc): Remove
8390 instantiated_target_ field. In do_recognize call
8391 instantiate_target rather than do_instantiate_target. In
8392 do_instantiate_target just allocate a new target.
8393 * sparc.cc (class Target_selector_sparc): Likewise.
8395 * freebsd.h: New file.
8396 * i386.cc: Include "freebsd.h".
8397 (Target_i386): Derive from Target_freebsd rather than
8399 (Target_selector_i386): Derive from Target_selector_freebsd rather
8400 than Target_selector.
8401 * x86_64.cc: Include "freebsd.h".
8402 (Target_x86_64): Derive from Target_freebsd rather than
8404 (Target_selector_x86_64): Derive from Target_selector_freebsd
8405 rather than Target_selector.
8406 * target.h (class Target): Add adjust_elf_header and
8407 do_adjust_elf_header.
8408 * output.cc (Output_file_header:: do_sized_write): Call target
8409 adjust_elf_header routine.
8410 * configure.tgt: Set targ_osabi.
8411 * configure.ac: Define GOLD_DEFAULT_OSABI.
8412 * parameters.cc (Parameters::default_target): Pass
8413 GOLD_DEFAULT_OSABI to select_target.
8414 * target-select.h (class Target_selector): Make instantiate_target
8415 protected rather than private.
8416 * Makefile.am (HFILES): Add freebsd.h.
8417 * configure, Makefile.in, config.in: Rebuild.
8419 * merge.cc (do_add_input_section): Correct pend value. Change
8420 message about last entry not being null terminated from error to
8425 * incremental.cc: New file.
8426 * Makefile.am (CCFILES): Add incremental.cc.
8427 * Makefile.in: Rebuild.
8431 * layout.cc (Layout::output_section_name): Preserve names
8432 of '.note.' sections.
8436 * descriptors.cc (Descriptors::open): Check that the options are
8437 valid before using them.
8441 * script-sections.h: Include <list>.
8442 (class Script_sections): Change Sections_elements from std::vector
8443 to std::list. Typedef public Elements_iterator. Add
8444 orphan_section_placement_, data_segment_align_start_, and
8445 saw_data_segment_align_ fields. Remove data_segment_align_index_
8447 * script-sections.cc (class Orphan_section_placement): New class.
8448 (class Sections_element): Add virtual functions is_relro and
8449 orphan_section_init. Remove virtual function place_orphan_here.
8450 (class Output_section_definition): Add is_relro and
8451 orphan_section_init. Remove place_orphan_here.
8452 (class Orphan_output_section): Likewise.
8453 (Script_sections::Script_sections): Update for field changes.
8454 (Script_sections::data_segment_align): Set saw_data_segment_align_
8455 and data_segment_align_start_, not data_segment_align_index.
8456 (Script_sections::data_segment_relro_end): Check
8457 saw_data_segment_align_. Use data_segment_align_start_ rather
8458 than data_segment_align_index_.
8459 (Script_sections::place_orphan): Rewrite to use
8460 Orphan_section_placement.
8464 * archive.cc (Archive::add_symbols): Check for a version attached
8465 to the symbol name in the archive map.
8466 * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_11.
8467 (ver_test_11_SOURCES, ver_test_11_DEPENDENCIES): Define.
8468 (ver_test_11_LDFLAGS, ver_test_11_LDADD): Define.
8469 (ver_test_11.a): New target.
8470 * testsuite/Makefile.in: Rebuild.
8472 * configure.ac: Check for chsize and posix_fallocate. Replace
8474 * ftruncate.c: New file, from gnulib.
8475 * output.cc (posix_fallocate): Define dummy version if not
8476 HAVE_POSIX_FALLOCATE.
8477 (Output_file::map): Call posix_fallocate rather than lseek and
8479 * gold.h (ftruncate): Declare if not HAVE_FTRUNCATE.
8480 * configure, Makefile.in, config.in: Rebuild.
8484 * layout.h (Layout::create_note): Add section_name parameter.
8485 * layout.cc (Layout::create_note): Likewise.
8486 (Layout::create_build_id, Layout::create_gold_note): Fix callers.
8490 * descriptors.cc: Include "options.h".
8491 (FD_CLOEXEC, O_CLOEXEC): Define if not defined.
8492 (Descriptors::open): Always use O_CLOEXEC when opening a new
8493 descriptor. If we have a plugin, and O_CLOEXEC was not defined,
8494 then set FD_CLOEXEC.
8496 * sparc.cc (class Target_sparc): Add has_got_section.
8497 (Target_sparc::Scan::global): If we see _GLOBAL_OFFSET_TABLE_,
8498 make sure we have a GOT section.
8500 * sparc.cc (optimize_tls_reloc): Recognize R_SPARC_TLS_IE_ADD.
8501 (Target_sparc::Scan::local): Likewise.
8502 (Target_sparc::Scan::global): Likewise.
8503 (Target_sparc::Relocate::relocate): Likewise.
8504 (Target_sparc::Relocate::relocate_tls): Likewise.
8506 * symtab.cc (Symbol_table::define_default_version): New function,
8507 broken out of add_from_object.
8508 (Symbol_table::add_from_object): Call define_default_version.
8509 (Symbol_table::define_special_symbol): Add resolve_oldsym
8510 parameter. Change all callers. If the version for a symbol comes
8511 from a version script, resolve it with the symbol with the same
8512 name with no version. Also add the symbol without a version if
8514 (do_define_in_output_data): If resolving with oldsym, don't delete
8516 (do_define_in_output_segment): Likewise.
8517 (do_define_as_constant): Likewise.
8518 * symtab.h (class Symbol_table): Update declarations.
8522 * readsyms.cc (Read_symbols::incompatible_warning): New function.
8523 (Read_symbols::requeue): New function.
8524 (Read_symbols::do_read_symbols): If make_elf_object fails because
8525 the target type is not configured, and the file was searched for,
8526 issue a warning and retry with the next directory.
8527 (Add_symbols::run): If the file has an incompatible format, and
8528 it was searched for, requeue the Read_symbols task. On error,
8530 * readsyms.h (class Read_symbols): Add dirindex_ field. Add
8531 dirindex parameter to constructor. Change all callers. Declare
8532 incompatible_warning and requeue.
8533 (class Add_symbols): Add dirpath_, dirindex_, mapfile_,
8534 input_argument_ and input_group_ fields. Add them to
8535 constructor. Change all callers.
8536 (class Read_script): Add dirindex_ field. Add it to constructor.
8538 * archive.cc (Archive::setup): Remove input_objects parameter.
8540 (Archive::get_file_and_offset): Likewise.
8541 (Archive::read_all_symbols): Likewise.
8542 (Archive::read_symbols): Likewise.
8543 (Archive::get_elf_object_for_member): Remove input_objects
8544 parameter. Add punconfigured parameter. Change all callers.
8545 (Archive::add_symbols): Change return type to bool. Check return
8546 value of include_member.
8547 (Archive::include_all_members): Likewise.
8548 (Archive::include_member): Change return type to bool. Return
8549 false if first included object has incompatible target. Set
8550 included_member_ field.
8551 (Add_archive_symbols::run): If add_symbols returns false, requeue
8553 * archive.h (class Archive): Add included_member_ field.
8554 Initialize it in constructor. Add input_file and searched_for
8555 methods. Update declarations.
8556 (class Add_archive_symbols): Add dirpath_, dirindex_, and
8557 input_argument_ fields. Add them to constructor. Change all
8559 * script.cc: Include "target-select.h".
8560 (class Parser_closure): Add skip_on_incompatible_target_ and
8561 found_incompatible_target_ fields. Add
8562 skip_on_incompatible_target parameter to constructor. Change all
8563 callers. Add methods skip_on_incompatible_target,
8564 clear_skip_on_incompatible_target, found_incompatible_target, and
8565 set_found_incompatible_target.
8566 (read_input_script): Add dirindex parameter. Change all callers.
8567 If parser finds an incompatible target, requeue Read_symbols
8569 (script_set_symbol): Clear skip_on_incompatible_target in
8571 (script_add_assertion, script_parse_option): Likewise.
8572 (script_start_sections, script_add_phdr): Likewise.
8573 (script_check_output_format): New function.
8574 * script.h (read_input_script): Update declaration.
8575 * script-c.h (script_check_output_format): Declare.
8576 * yyscript.y (file_cmd): Handle OUTPUT_FORMAT.
8577 (ignore_cmd): Remove OUTPUT_FORMAT.
8578 * fileread.cc (Input_file::Input_file): Add explicit this.
8579 (Input_file::will_search_for): New function.
8580 (Input_file::open): Add pindex parameter. Change all callers.
8581 * fileread.h (class Input_file): Add input_file_argument method.
8582 Declare will_search_for. Update declarations.
8583 * object.cc (make_elf_object): Add punconfigured parameter.
8585 * object.h (class Object): Make input_file public. Add
8586 searched_for method.
8587 (make_elf_object): Update declaration.
8588 * dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to
8590 * dirsearch.h (class Dirsearch): Update declaration.
8591 * options.h (class General_options): Add --warn-search-mismatch.
8592 * parameters.cc (Parameters::is_compatible_target): New function.
8593 * parameters.h (class Parameters): Declare is_compatible_target.
8594 * workqueue.cc (Workqueue::add_blocker): New function.
8595 * workqueue.h (class Workqueue): Declare add_blocker.
8597 * fileread.cc (Input_file::open): Remove options parameter.
8599 (Input_file::open_binary): Likewise.
8600 * script.cc (read_input_script): Likewise.
8601 * readsyms.h (class Read_symbols): Remove options_ field. Remove
8602 options parameter from constructor. Change all callers.
8603 (class Read_script): Likewise.
8604 * fileread.h (class Input_file): Update declarations.
8605 * script.h (read_input_script): Update declaration.
8609 * po/es.po: New Spanish translation.
8613 * options.cc (parse_short_option): Keep dash_z from registering itself.
8618 * target-reloc.h (relocate_section): Pass output_section to
8620 * i386.cc (Target_i386::should_apply_static_reloc): Add
8621 output_section parameter. Change all callers.
8622 (Target_i386::Relocate::relocate): Add output_section parameter.
8623 * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
8624 * sparc.cc (Target_sparc::Relocate::relocate): Likewise.
8625 * powerpc.cc (Target_powerpc::Relocate::relocate): Likewise.
8626 * testsuite/two_file_shared.sh: New script.
8627 * testsuite/Makefile.am (check_SCRIPTS): Add two_file_shared.sh.
8628 (check_DATA): Add two_file_shared.dbg.
8629 (two_file_shared.dbg): New target.
8630 * testsuite/Makefile.in: Rebuild.
8634 * configure.ac: Check for byteswap.h.
8635 * configure: Rebuild.
8636 * config.in: Rebuild.
8640 * layout.cc (Layout::find_or_add_kept_section): New function.
8641 (Layout::add_comdat): Removed.
8642 * layout.h (struct Kept_section): Move out of class Layout.
8643 Remove trailing underscores from field names. Add group_sections
8644 field. Rename group_ field to is_group. Change all uses.
8645 (class Layout): Declare find_or_add_kept_section, not add_comdat.
8646 * object.cc (Sized_relobj::Sized_relobj): Don't initialize
8647 comdat_groups_ field.
8648 (Sized_relobj::include_section_group): Use
8649 find_or_add_kept_section and Kept_section::group_sections.
8650 (Sized_relobj::include_linkonce_section): Likewise.
8651 * object.cc (class Sized_relobj): Don't define Comdat_group or
8652 Comdat_group_table. Remove find_comdat_group and
8653 add_comdat_group. Remove comdat_groups_ field.
8654 * plugin.cc (include_comdat_group): Use
8655 Layout::find_or_add_kept_section.
8659 * README: --gc-sections and map files are now supported. Document
8660 some build requirements.
8663 * symtab.cc (Symbol_table::sized_write_section_symbol): In a
8664 relocatable link set the value of the section symbol to zero.
8665 * object.cc (Sized_relobj::do_finalize_local_symbols): In a
8666 relocatable link don't include the section address in the local
8672 * options.h (class Search_directory): Add is_system_directory.
8673 (class General_options): Declare is_in_system_directory.
8674 * options.cc (get_relative_sysroot): Make static.
8675 (get_default_sysroot): Make static.
8676 (General_optoins::is_in_system_directory): New function.
8677 * fileread.cc (Input_file::is_in_system_directory): New function.
8678 * fileread.h (class Input_file): Declare is_in_system_directory.
8679 * object.h (class Object): Add is_in_system_directory.
8680 (class Input_objects): Remove system_library_directory_ field.
8681 * object.cc (Input_objects::add_object): Don't set
8682 system_library_directory_.
8683 (input_objects::found_in_system_library_directory): Remove.
8684 * symtab.cc (Symbol_table::write_globals): Remove input_objects
8685 parameter. Change all callers.
8686 (Symbol_table::sized_write_globals): Likewise.
8687 (Symbol_table::warn_about_undefined_dynobj_symbol): Likewise.
8688 Call Object::is_in_system_directory.
8689 * symtab.h (class Symbol_table): Update declarations.
8692 * descriptors.h (Open_descriptor): Add is_on_stack field.
8693 * descriptors.cc (Descriptors::open): If the descriptor is on the
8694 top of the stack, remove it. Initialize is_on_stack field.
8695 (Descriptors::release): Only add pod to stack if it is not on the
8697 (Descriptors::close_some_descriptor): Clear stack_next and
8701 * output.cc (Output_section::find_starting_output_address): Rename
8702 from starting_output_address; add PADDR parameter; change return
8704 * output.h (class Output_section): Declare
8705 find_starting_output_address instead of starting_output_address.
8706 * object.cc (Sized_relobj::do_finalize_local_symbols): Handle a
8707 section symbol for which we can't find a merge section.
8710 * symtab.cc (Symbol_table::add_from_object): If the visibility is
8711 hidden or internal, force the symbol to be local.
8712 * resolve.cc (Symbol::override_visibility): Define.
8713 (Symbol::override_base): Use override_visibility.
8714 (Symbol_table::resolve): Likewise.
8715 (Symbol::override_base_with_special): Likewise.
8716 (Symbol_table::override_with_special): If the visibility is hidden
8717 or internal, force the symbol to be local.
8718 * symtab.h (class Symbol): Add set_visibility and
8719 override_visibility.
8720 * testsuite/ver_test_1.sh: New file.
8721 * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh.
8722 (check_DATA): Add ver_test_1.syms.
8723 (ver_test_1.syms): New target.
8724 * testsuite/Makefile.in: Rebuild.
8728 * layout.cc (Layout::choose_output_section): Don't rename sections
8729 when using a linker script that has a SECTIONS clause.
8730 * Makefile.in: Regenerate.
8732 * testsuite/Makefile.am (script_test_5.sh): New test case.
8733 * testsuite/Makefile.in: Regenerate.
8734 * testsuite/script_test_5.cc: New file.
8735 * testsuite/script_test_5.sh: New file.
8736 * testsuite/script_test_5.t: New file.
8740 * archive.cc (Archive::include_member): Update calls to add_symbols.
8741 * dynobj.cc (Sized_dynobj<size, big_endian>::make_version_map): Add
8742 the Layout argument.
8743 * dynobj.h (do_add_symbols): Add the Layout argument.
8744 * object.cc (Sized_relobj<size, big_endian>::do_add_symbols): Add the
8746 * object.h (Object::add_symbols): Add the Layout argument.
8747 (Object::do_add_symbols): Add the Layout argument.
8748 (Sized_relobj::do_add_symbols): Add the Layout argument.
8749 * plugin.cc (Sized_pluginobj<size, big_endian>::do_add_symbols):
8750 Unify the two versions.
8751 (Add_plugin_symbols): Remove.
8752 * plugin.h (Pluginobj::add_symbols, Pluginobj::do_add_symbols): Remove.
8753 (Sized_pluginobj::do_add_symbols): Unify the two versions.
8754 (Add_plugin_symbols): Remove.
8755 * readsyms.cc (Read_symbols::do_read_symbols): Update call to
8756 Add_symbols. Use Add_symbols instead of Add_plugin_symbols.
8757 (Add_symbols::run): Make it work with Pulginobj.
8761 * object.cc (Sized_relobj::do_layout): Make info message start
8762 with lower case letter.
8766 * binary.cc: Fix file comment.
8768 * options.h (enum Incremental_disposition): Define.
8769 (class General_options): Add new options: --incremental,
8770 --incremental_changed, --incremental_unchanged,
8771 --incremental_unknown. Add incremental_disposition_ and
8772 implicit_incremental_ fields.
8773 (General_options::incremental_disposition): New function.
8774 (class Position_dependent_options): Add incremental_disposition
8776 (Position_dependent_options::copy_from_options): Set incremental
8778 * options.cc (General_options::parse_incremental_changed): New
8780 (General_options::parse_incremental_unchanged): New function.
8781 (General_options::parse_incremental_unknown): New function.
8782 (General_options::General_options): Initialize new fields
8783 incremental_disposition_ and implicit_incremental_.
8784 (General_options::finalize): Check for uasge of --incremental-*
8785 without --incremental.
8789 * gold.h (gold_undefined_symbol): Change to take only a Symbol
8790 pointer and to report location as the file name associated with
8792 (gold_undefined_symbol_at_location): New function to replace the
8793 old gold_undefined_symbol functionality.
8794 * target-reloc.h (relocate_section): Update to use
8795 gold_undefined_symbol_at_location.
8796 * symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
8797 Call gold_undefined_symbol function rather than gold_error.
8798 * errors.h (Errors::undefined_symbol): Take location as a
8799 string, rather than calculating it from a relocation.
8800 * errors.cc (Errors::fatal): Print "fatal error:" before the
8802 (Errors::error, Errors::error_at_location): Print "error: "
8803 before the formatted message.
8804 (Errors::undefined_symbol): Take location as a string, rather
8805 than calculating it from a relocation.
8806 (gold_undefined_symbol_at_location): New function akin to
8807 old gold_undefined_symbol, calculates location from relocation.
8808 (gold_undefined_symbol): Change to take only a Symbol pointer
8809 and to report location as the file name associated with the symbol.
8810 * testsuite/debug_msg.sh: Update for changed error messages.
8811 * testsuite/undef_symbol.sh: Likewise.
8816 * reduced_debug_output.h
8817 (Output_reduced_debug_abbrev_section::failed): Use format for
8819 (Output_reduced_debug_info_section::faild): Likewise.
8823 * script.cc (Lazy_demangler): New class.
8824 (Version_script_info::get_symbol_version_helper): Demangle a
8829 * i386.cc (Target_i386::Relocate::relocate): Recognize non-PIC calls
8831 * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
8835 * version.cc (version_string): Bump to 1.9.
8837 * gold.h: Include <cstring> and <stdint.h>.
8838 * version.cc: Include <cstdio>.
8839 * object.cc (Sized_relobj::do_layout): Initialize gc_sd to avoid a
8841 * reduced_debug_output.cc (insert_into_vector): Rename from
8842 Insert_into_vector; change all callers. Use Swap_unaligned to
8843 avoid aliasing issue; remove union since it is unnecessary.
8847 * Makefile.am (CCFILES): Add gc.cc.
8849 * Makefile.in: Regenerate.
8850 * gold.cc (Gc_runner): New class.
8851 (queue_initial_tasks): Call garbage collection related tasks
8852 when corresponding options are invoked.
8853 (queue_middle_gc_tasks): New function.
8854 (queue_middle_tasks): Reorder tasks to allow relocs to be read and
8855 processed early before laying out sections during garbage collection.
8856 * gold.h (queue_middle_gc_tasks): New function.
8857 (is_prefix_of): Move from "layout.cc".
8858 * i386.cc (Target_i386::gc_process_relocs): New function.
8859 * layout.cc (is_prefix_of): Remove. Move to "gold.h"
8860 * main.cc (main): Create object of class "Garbage_collection".
8861 * object.cc (Relobj::copy_symbols_data): New function.
8862 (Relobj::is_section_name_included): New function.
8863 (Sized_relobj::do_layout): Allow this function to be called twice
8864 during garbage collection and defer layout of section during the
8866 * object.h (Relobj::get_symbols_data): New function.
8867 (Relobj::is_section_name_included): New function.
8868 (Relobj::copy_symbols_data): New function.
8869 (Relobj::set_symbols_data): New function.
8870 (Relobj::get_relocs_data): New function.
8871 (Relobj::set_relocs_data): New function.
8872 (Relobj::is_output_section_offset_invalid): New pure virtual function.
8873 (Relobj::gc_process_relocs): New function.
8874 (Relobj::do_gc_process_relocs): New pure virtual function.
8875 (Relobj::sd_): New data member.
8876 (Sized_relobj::is_output_section_offset_invalid): New function.
8877 (Sized_relobj::do_gc_process_relocs): New function.
8878 * options.h (General_options::gc_sections): Modify to not be a no-op.
8879 (General_options::print_gc_sections): New option.
8880 * plugin.cc (Plugin_finish::run): Remove function call to
8881 Plugin_manager::layout_deferred_objects. Move it to "gold.cc".
8882 * powerpc.cc (Target_powerpc::gc_process_relocs): New function.
8883 * reloc.cc (Read_relocs::run): Add task to process relocs and
8884 determine unreferenced sections when doing garbage collection.
8885 (Gc_process_relocs): New class.
8886 (Sized_relobj::do_gc_process_relocs): New function.
8887 (Sized_relobj::do_scan_relocs): Don't try to scan the relocs for
8888 sections that are garbage collected.
8889 * reloc.h (Gc_process_relocs): New class.
8890 * sparc.cc (Target_sparc::gc_process_relocs): New function.
8891 * symtab.cc (Symbol::should_add_dynsym_entry): Do not add entries for
8892 symbols whose corresponding sections are garbage collected.
8893 (Symbol_table::Symbol_table): Add new parameter for the garbage
8895 (Symbol_table::gc_mark_undef_symbols): New function.
8896 (Symbol_table::gc_mark_symbol_for_shlib): New function.
8897 (Symbol_table::gc_mark_dyn_syms): New function.
8898 (Symbol_table::resolve): Do not treat symbols seen in dynamic objects
8900 (Symbol_table::add_from_object): Likewise.
8901 (Symbol_table::add_from_relobj): When building shared objects, do not
8902 treat externally visible symbols as garbage.
8903 (Symbol_table::sized_finalize_symbol): Do not check dynamic symbol
8904 table information for static and relocatable links.
8905 * symtab.h (Symbol_table::set_gc): New function.
8906 (Symbol_table::gc): New function.
8907 (Symbol_table::gc_mark_undef_symbols): New function.
8908 (Symbol_table::gc_mark_symbol_for_shlib): New function.
8909 (Symbol_table::gc_mark_dyn_syms): New function.
8910 (Symbol_table::gc_): New data member.
8911 * target.h (Sized_target::gc_process_relocs): New pure virtual
8913 * x86_64.cc (Target_x86_64::gc_process_relocs): New function.
8914 * testsuite/testfile.cc (Target_test::gc_process_relocs): New function.
8918 * options.h (General_options::gc_sections): Define as a no-op for now.
8919 (General_options::no_keep_memory): Ditto.
8920 (General_options::Bshareable): Define.
8921 * options.cc (General_options::finalize): Honor -Bshareable.
8925 * powerpc.cc (Powerpc_relocate_functions::rel16_ha): Don't try to
8926 read the value in the contents, since we don't use it. Use the
8927 template endianness when writing.
8928 (Relocate::relocate): Use it for R_PPC_REL16_HA.
8932 * configure.tgt (powerpc64-*): Fix targ_obj.
8936 * object.cc (Sized_relobj::write_local_symbols): Don't write out
8937 local symbols when stripping all symbols.
8941 * output.cc (Output_reloc): Add explicit instantiations.
8945 * archive.cc (Archive::get_elf_object_for_member): Remove call
8946 to File_read::claim_for_plugin.
8947 * descriptors.cc (Descriptors::open): Remove reference to
8949 (Descriptors::claim_for_plugin): Remove.
8950 * descriptors.h (Descriptors::claim_for_plugin): Remove.
8951 (Descriptors::is_claimed): Remove.
8952 (claim_descriptor_for_plugin): Remove.
8953 * fileread.cc (File_read::claim_for_plugin): Remove.
8954 * fileread.h (File_read::claim_for_plugin): Remove.
8955 (File_read::descriptor): Reopen descriptor if necessary.
8956 * plugin.cc (Plugin::load): Add two new APIs to transfer vector.
8957 (Plugin_manager::all_symbols_read): Add task parameter. Change
8959 (Plugin_manager::get_input_file): New function.
8960 (Plugin_manager::release_input_file): New function.
8961 (Pluginobj::Pluginobj): Add filesize parameter and initialize
8962 corresponding data member.
8963 (Sized_pluginobj::Sized_pluginobj): Add filesize parameter
8964 and pass to base constructor. Change all callers.
8965 (get_input_file, release_input_file): New functions.
8966 (make_sized_plugin_object): Add filesize parameter. Change all callers.
8967 * plugin.h (Plugin_manager::Plugin_manager): Initialize task_ member.
8968 (Plugin_manager::all_symbols_read): Add task parameter.
8969 (Plugin_manager::get_input_file): New function.
8970 (Plugin_manager::release_input_file): New function.
8971 (Plugin_manager::task_): New data member.
8972 (Pluginobj::Pluginobj): Add filesize parameter.
8973 (Pluginobj::filename): New function.
8974 (Pluginobj::descriptor): New function.
8975 (Pluginobj::filesize): New function.
8976 (Pluginobj::filesize_): New data member.
8977 (Sized_pluginobj::Sized_pluginobj): Add filesize parameter.
8978 * readsyms.cc (Read_symbols::do_read_symbols): Remove call to
8979 File_read::claim_for_plugin; use Object::unlock to unlock the file.
8981 * testsuite/Makefile.am (plugin_test_4): New test case for plugins
8982 with archive libraries.
8983 * testsuite/Makefile.in: Regenerate.
8984 * testsuite/plugin_test.c (struct sym_info): New type.
8985 (get_input_file, release_input_file): New static variables.
8986 (onload): Capture new transfer vector entries.
8987 (claim_file_hook): Stop reading at end of file according to filesize.
8988 Factor out parsing of readelf output into separate function.
8989 (all_symbols_read_hook): Exercise get_input_file and release_input_file
8990 APIs and get the source file name from the symbol table. Convert
8991 source file name to corresponding object file name. Print info
8992 message when adding new input files.
8993 (parse_readelf_line): New function.
8994 * testsuite/plugin_test_1.sh: Add checks for new info messages.
8995 * testsuite/plugin_test_2.sh: Likewise.
8996 * testsuite/plugin_test_3.sh: Likewise.
8997 * testsuite/plugin_test_4.sh: New test case.
9001 * version.cc (version_string): Bump to 1.8.
9005 * gold.cc (gold_exit): Call plugin cleanup handlers on exit.
9006 * plugin.cc (Plugin_manager::finish): Rename as
9007 layout_deferred_objects. Move cleanup to separate function.
9008 (Plugin_manager::cleanup): New function.
9009 (Plugin_finish::run): Call layout_deferred_objects and cleanup
9011 * plugin.h (Plugin_manager::finish): Rename as
9012 layout_deferred_objects.
9013 (Plugin_manager::cleanup): New function.
9014 (Plugin_manager::cleanup_done): New field.
9018 * plugin.cc (is_visible_from_outside): New function.
9019 (Pluginobj::get_symbol_resolution_info): Call is_visible_from_outside
9020 so we don't return "IR only" status for exported symbols or -r links.
9022 * testsuite/Makefile.am (plugin_test_3): New test case.
9023 * testsuite/Makefile.in: Regenerate.
9024 * testsuite/plugin_test_3.sh: New file.
9028 * object.cc (Sized_relobj::layout_section): New function.
9029 (Sized_relobj::do_layout): Defer layout of input sections until after
9030 plugin has provided replacement files.
9031 (Sized_relobj::do_layout_deferred_sections): New function.
9032 * object.h (Relobj::set_section_offset): Remove virtual keyword.
9033 (Relobj::layout_deferred_sections): New function.
9034 (Relobj::do_layout_deferred_sections): New function.
9035 (Sized_relobj::do_layout_deferred_sections): New function.
9036 (Sized_relobj::layout_section): New function.
9037 (Sized_relobj::Deferred_layout): New structure.
9038 (Sized_relobj::deferred_layout_): New field.
9039 * plugin.cc (Plugin_manager::finish): Renamed, was cleanup.
9040 Change all callers. Layout deferred sections.
9041 (class Plugin_finish): Renamed, was Plugin_cleanup. Change all
9043 (Plugin_hook::run): Move code from do_plugin_hook inline.
9044 (Plugin_hook::do_plugin_hook): Remove.
9045 * plugin.h (Plugin_manager::Plugin_manager): Add missing initializers.
9046 (Plugin_manager::finish): Renamed, was cleanup.
9047 (Plugin_manager::should_defer_layout): New function.
9048 (Plugin_manager::add_deferred_layout_object): New function.
9049 (Plugin_manager::Deferred_layout_list): New type.
9050 (Plugin_manager::deferred_layout_objects_): New field.
9051 (Plugin_hook::do_plugin_hook): Remove.
9055 * options.h (class General_options): Add --no case for
9060 * plugin.cc (Plugin::load): Move LDPT_MESSAGE to front of transfer
9062 (Plugin_manager::claim_file): Create plugin object even if
9063 plugin did not call the add_symbols callback.
9064 (Plugin_obj::get_symbol_resolution_info): Guard against plugin
9065 asking for more symbols than were added.
9066 * testsuite/Makefile.am (plugin_test_1): Add test case with
9068 (empty.syms): New target.
9069 * testsuite/Makefile.in: Regenerate.
9070 * testsuite/plugin_test.c (claim_file_hook): Add new debug
9071 message. Don't call add_symbols if no globals.
9072 (all_symbols_read_hook): Don't provide replacement for empty
9077 * target-reloc.h (Default_scan_relocatable_relocs): Only discard
9078 r_type == 0 for a local symbol with r_sym == 0.
9079 (scan_relocatable_relocs): Pass r_sym to
9080 local_non_section_strategy.
9081 * reloc.cc (Emit_relocs_strategy::local_non_section_strategy): Add
9084 * configure.ac: Update test for TLS descriptors: they are
9085 supported as of glibc 2.9.
9086 * configure: Rebuild.
9091 * target-reloc.h (Default_scan_relocatable_relocs): For each
9092 function, map r_type == 0 to RELOC_DISCARD.
9096 * layout.cc (Layout::add_comdat): Allow COMDAT group from a replacement
9097 object to override a kept COMDAT group from a plugin object.
9102 * yyscript.y (file_cmd): Handle INPUT.
9104 * testsuite/initpri1.c: Change all declarations to be full
9105 prototypes by adding void, to avoid compiler warnings.
9109 * options.cc (General_options::parse_plugin_opt): New.
9110 (General_options::add_plugin): The argument now is just the filename.
9111 (General_options::add_plugin_option): New.
9112 * options.h (plugin_opt): New.
9113 (add_plugin): Change argument name.
9114 (add_plugin_option): New.
9115 * plugin.cc (Plugin::load): Don't parse the plugin option.
9116 * plugin.h (Plugin::Plugin): Rename argument. Init filename_.
9117 (Plugin::add_option): New.
9118 (Plugin::args_): Change type.
9119 (Plugin::filename_): New.
9120 (Plugin_manager::add_plugin_option): New.
9121 * testsuite/Makefile.am (plugin_test_1): Use new syntax.
9122 * testsuite/Makefile.in: Regenerate.
9126 * layout.cc (Layout::include_section): Check for SHF_EXCLUDE.
9127 Handle --strip-lto-sections option.
9128 * options.h (strip_lto_sections): New option.
9132 * plugin.cc (ld_plugin_message): Change format parameter to const.
9133 Fix mismatch between new[] and delete.
9137 * reloc.cc (Sized_relobj::do_read_relocs): Use constant invalid_address
9142 * options.cc (General_options::parse_dynamic_list): New function.
9143 * options.h (General_options): New flags dynamic_list,
9144 dynamic_list_data, dynamic_list_cpp_new, and
9145 dynamic_list_cpp_typeinfo. New variable dynamic_list_.
9146 (General_options::in_dynamic_list): New function.
9147 * script.cc (Lex::Mode): New enum DYNAMIC_LIST.
9148 (Lex::can_start_name): Add support for DYNAMIC_LIST mode.
9149 (Lex::can_continue_name): Likewise.
9151 (read_script_file): New parameter script_options.
9152 (read_dynamic_list): New function.
9153 (Script_options::define_dynamic_list): New function.
9154 (dynamic_list_keyword_parsecodes): New variable.
9155 (dynamic_list_keywords): New variable.
9156 * script.h (Script_options::define_dynamic_list): New function
9158 (read_dynamic_list): New function prototype.
9159 * symtab.cc (strprefix): New macro.
9160 (Symbol::should_add_dynsym_entry): Support dynamic_list,
9161 dynamic_list_data, dynamic_list_cpp_new, and
9162 dynamic_list_cpp_typeinfo.
9163 * yyscript.y (PARSING_DYNAMIC_LIST): New token.
9164 (dynamic_list_expr): New rule.
9165 (dynamic_list_nodes): Likewise.
9166 (dynamic_list_node): Likewise.
9167 * testsuite/Makefile.am (dynamic_list): New test.
9168 * testsuite/Makefile.in: Regenerated.
9169 * testsuite/dynamic_list.t: New file.
9170 * testsuite/dynamic_list.sh: New file.
9174 * testsuite/tls_test_c.c: Add prototype for t11 and t11_last.
9175 * testsuite/tls_test_c.c (t11): Add explicit "void" to prototype.
9176 (t11_last): Likewise.
9177 * testsuite/ver_test_6.c (main): Likewise.
9181 * options.c (General_options::finalize): Add check for -static and
9183 * gold.cc (queue_middle_tasks): Assert that list of dynamic objects
9188 * plugin.cc (make_sized_plugin_object): Fix conditional
9189 compilation to work when not all targets are enabled.
9193 * archive.cc (Archive::get_file_and_offset): Use filename instead
9194 of name to get library path.
9195 (Archive::include_member): Unlock external member of a thin archive.
9197 * testsuite/Makefile.am (TEST_AR): New variable.
9198 (thin_archive_test_1): New test.
9199 (thin_archive_test_2): New test.
9200 * testsuite/Makefile.in: Regenerate.
9201 * testsuite/thin_archive_main.cc: New file.
9202 * testsuite/thin_archive_test_1.cc: New file.
9203 * testsuite/thin_archive_test_2.cc: New file.
9204 * testsuite/thin_archive_test_3.cc: New file.
9205 * testsuite/thin_archive_test_4.cc: New file.
9209 * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.
9210 * object.cc (Sized_relobj::do_layout): Use constant invalid_address
9212 (Sized_relobj::do_finalize_local_symbols): Likewise.
9213 (Sized_relobj::map_to_kept_section): Likewise.
9214 * object.h (Sized_relobj::invalid_address): New constant.
9215 (Sized_relobj::do_output_section_offset): Check for invalid_address
9217 * output.cc (Output_reloc::local_section_offset): Use constant
9218 invalid_address instead of -1U.
9219 (Output_reloc::get_address): Likewise.
9220 (Output_section::output_address): Change -1U to -1ULL.
9221 * output.h (Output_reloc::invalid_address): New constant.
9222 * reloc.cc (Sized_relobj::write_sections): Use constant
9223 invalid_address instead of -1U.
9224 (Sized_relobj::relocate_sections): Likewise.
9225 * symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
9226 values for merge sections.
9227 * target-reloc.h (relocate_for_relocatable): Use constant
9228 invalid_address instead of -1U.
9232 Add plugin functionality for link-time optimization (LTO).
9233 * configure.ac (plugins): Add --enable-plugins option.
9234 * configure: Regenerate.
9235 * config.in: Regenerate.
9236 * Makefile.am (LIBDL): New variable.
9237 (CCFILES): Add plugin.cc.
9238 (HFILES): Add plugin.h.
9239 (ldadd_var): Add LIBDL.
9240 * Makefile.in: Regenerate.
9242 * archive.cc: Include "plugin.h".
9243 (Archive::setup): Don't preread archive symbols when using a plugin.
9244 (Archive::get_file_and_offset): Add memsize parameter. Change callers.
9245 (Archive::get_elf_object_for_member): Call plugin hooks for claiming
9247 (Archive::include_member): Add symbols from plugin objects.
9248 * archive.h (Archive::get_file_and_offset): Add memsize parameter.
9249 * descriptors.cc (Descriptors::open): Check for file descriptors
9250 abandoned by plugins.
9251 (Descriptors::claim_for_plugin): New function.
9252 * descriptors.h (Descriptors::claim_for_plugin): New function.
9253 (Open_descriptor::is_claimed): New field.
9254 (claim_descriptor_for_plugin): New function.
9255 * fileread.cc (File_read::claim_for_plugin): New function.
9256 * fileread.h (File_read::claim_for_plugin): New function.
9257 (File_read::descriptor): New function.
9258 * gold.cc: Include "plugin.h".
9259 (queue_initial_tasks): Add task to call plugin hooks for generating
9261 * main.cc: Include "plugin.h".
9262 (main): Load plugin libraries.
9263 * object.h (Pluginobj): Declare.
9264 (Object::pluginobj): New function.
9265 (Object::do_pluginobj): New function.
9266 (Object::set_target): New function.
9267 * options.cc: Include "plugin.h".
9268 (General_options::parse_plugin): New function.
9269 (General_options::General_options): Initialize plugins_ field.
9270 (General_options::add_plugin): New function.
9271 * options.h (Plugin_manager): Declare.
9272 (General_options): Add --plugin option.
9273 (General_options::has_plugins): New function.
9274 (General_options::plugins): New function.
9275 (General_options::add_plugin): New function.
9276 (General_options::plugins_): New field.
9277 * plugin.cc: New file.
9278 * plugin.h: New file.
9279 * readsyms.cc: Include "plugin.h".
9280 (Read_symbols::do_read_symbols): Check for archive before checking
9281 for ELF file. Call plugin hooks to claim files.
9282 * resolve.cc (Symbol_table::resolve): Record when symbol is referenced
9283 from a real object file; force override when processing replacement
9285 * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field.
9286 (Symbol::init_base_object): Likewise.
9287 (Symbol::init_base_output_data): Likewise.
9288 (Symbol::init_base_output_segment): Likewise.
9289 (Symbol::init_base_constant): Likewise.
9290 (Symbol::init_base_undefined): Likewise.
9291 (Symbol::output_section): Assert that object is not a plugin.
9292 (Symbol_table::add_from_pluginobj): New function.
9293 (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as
9295 (Symbol_table::sized_write_globals): Likewise.
9296 (Symbol_table::add_from_pluginobj): Instantiate template.
9297 * symtab.h (Sized_pluginobj): Declare.
9298 (Symbol::in_real_elf): New function.
9299 (Symbol::set_in_real_elf): New function.
9300 (Symbol::in_real_elf_): New field.
9301 (Symbol_table::add_from_pluginobj): New function.
9303 * testsuite/Makefile.am (AM_CFLAGS): New variable.
9304 (LIBDL): New variable.
9306 (check_PROGRAMS): Add plugin_test_1 and plugin_test_2.
9307 (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh.
9308 (check_DATA): Add plugin_test_1.err and plugin_test_2.err.
9309 (MOSTLYCLEANFILES): Likewise.
9310 * testsuite/Makefile.in: Regenerate.
9311 * testsuite/plugin_test.c: New file.
9312 * testsuite/plugin_test_1.sh: New file.
9313 * testsuite/plugin_test_2.sh: New file.
9317 * target-reloc.h (relocate_section): Check whether a symbol is
9318 defined by the ABI before reporting an undefined symbol error.
9319 * target.h (Target::is_defined_by_abi): Make parameter const.
9320 (Target::do_is_defined_by_abi): Likewise.
9321 * i386.cc (Target_i386::do_is_defined_by_abi): Likewise.
9322 * powerpc.cc (Target_powerpc::do_is_defined_by_abi): Likewise.
9323 * sparc.cc (Target_sparc::do_is_defined_by_abi): Likewise.
9324 * x86_64.cc (Target_x86_64::do_is_defined_by_abi): Likewise.
9325 * testsuite/Makefile.am (tls_test_shared.so): Add -Wl,-z,defs.
9326 * testsuite/Makefile.in: Rebuild.
9328 * fileread.cc (make_view): Add casts to avoid warning.
9332 * i386.cc (Target_i386::define_tls_base_symbol): Update comments.
9333 * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
9337 * options.h (General_options::output_is_executable): New.
9338 (General_options::output_is_pie): New.
9339 * i386.cc (Target_i386::define_tls_base_symbol): Use SEGMENT_START
9340 for shared libraries.
9341 * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
9345 * options.h (origin): New -z option.
9346 * layout.cc (Layout:finish_dynamic_section): If "-z origin"
9347 is specified, set DF_ORIGIN in DT_FLAGS and set DF_1_ORIGIN
9352 * fileread.cc (File_read::make_view): Add check for attempt to map
9357 * symtab.cc (Symbol_table::add_from_dynobj): Fix typos in
9358 explicit instantiations.
9363 * options.cc (General_options::finalize): Allow undefined symbols
9364 in shlibs if linking -shared.
9367 * symtab.cc (Symbol::init_base_undefined): Mark explicitly undefined
9368 symbols as not needing a dynsym entry.
9372 * fileread.cc (File_read::open): Do not lock the file unless it
9373 was successfully opened.
9377 * x86_64.cc (Target_x86_64::Relocate::relocat_tls):
9378 Use addend for DTPOFF32, DTPOFF64, and TPOFF32 relocs.
9379 * testsuite/tls_test.cc (struct int128): 128-bit struct
9380 for testing TLS relocs with non-zero addend.
9381 (v12): New TLS variable.
9383 (t_last): Add check for v12.
9384 * testsuite/tls_test.h (t12): New function.
9385 * testsuite/tls_test_main.cc (thread_routine): Call new test.
9389 * layout.cc (Layout::attach_allocated_section_to_segment): Don't
9390 set tls_segment_ or relro_segment_.
9391 (Layout::make_output_segment): Set tls_segment_ and relro_segment_
9393 * output.h (Output_section::clear_is_relro): New function.
9394 * output.cc (Output_segment::add_output_section): Handle SHF_TLS
9395 sections specially even when output_data_ is empty.
9396 (Output_segment::maximum_alignment): When first section is relro,
9397 only force alignment for PT_LOAD segments.
9398 * script.cc (script_data_segment_align): New function.
9399 (script_data_segment_relro_end): New function.
9400 * script-c.h (script_data_segment_align): Declare.
9401 (script_data_segment_relro_end): Declare.
9402 * script-sections.h (class Script_sections): Declare
9403 data_segment_align and data_segment_relro_end. Add fields
9404 segment_align_index_ and saw_relro_end_.
9405 * script-sections.cc (class Sections_element): Add set_is_relro
9406 virtual function. Add new bool* parameter to place_orphan_here.
9407 Add get_output_section virtual function.
9408 (class Output_section_definition): Add set_is_relro. Add new
9409 bool* parameter to place_orphan_here. Add get_output_section.
9410 Add is_relro_ field.
9411 (Output_section_definition::Output_section_definition): Initialize
9412 evaluated_address_, evaluated_load_address, evaluated_addralign_,
9413 and is_relro_ fields.
9414 (Output_section_definition::place_orphan_here): Add is_relro
9416 (Output_section_definition::set_section_addresses): Set relro for
9418 (Output_section_definition::alternate_constraint): Likewise.
9419 (class Orphan_output_section): Add new bool* parameter to
9420 place_orphan_here. Add get_output_section.
9421 (Orphan_output_section::place_orphan_here): Add is_relro
9423 (Script_sections::Script_sections): Initialize
9424 data_segment_align_index_ and saw_relro_end_.
9425 (Script_sections::data_segment_align): New function.
9426 (Script_sections::data_segment_relro_end): New function.
9427 (Script_sections::place_orphan): Set or clear is_relro.
9428 (Script_sections::set_section_addresses): Force alignment of first
9430 * yyscript.y (exp): Call script_data_segment_align and
9431 script_data_segment_relro_end.
9432 * testsuite/relro_script_test.t: New file.
9433 * testsuite/relro_test.cc (using_script): Declare.
9434 (t1, t2): Test using_script.
9435 * testsuite/Makefile.am (check_PROGRAMS): Add relro_script_test.
9436 (relro_script_test_SOURCES): Define.
9437 (relro_script_test_DEPENDENCIES): Define.
9438 (relro_script_test_LDFLAGS): Define.
9439 (relro_script_test_LDADD): Define.
9440 (relro_script_test.so): New target.
9441 * testsuite/Makefile.in: Rebuild.
9445 * archive.cc (Archive::total_archives, Archive::total_members)
9446 (Archive::total_members_loaded): New variables.
9447 (Archive::setup): Add parameter. Add option to preread
9449 (Archive::read_armap): Add counter.
9450 (Archive::get_file_and_offset): New function.
9451 (Archive::get_elf_object_for_member): New function.
9452 (Archive::read_all_symbols): New function.
9453 (Archive::read_symbols): New function.
9454 (Archive::add_symbols): Add counters.
9455 (Archive::include_all_members): Use armap to find members if it's
9457 (Archive::include_member): Skip reading symbols if already read.
9458 Factored code into Archive::get_file_and_offset and
9459 Archive::get_elf_object_for_member. Changed call to
9460 Mapfile::report_include_archive_member.
9461 (Archive::print_stats): New function.
9462 * archive.h: Declare Object and Read_symbols_data classes.
9463 (Archive::Archive): Add initializers for new members.
9464 (Archive::setup): Add parameter.
9465 (Archive::print_stats): New function.
9466 (Archive::total_archives, Archive::total_members)
9467 (Archive::total_members_loaded): New variables.
9468 (Archive::get_file_and_offset): New function.
9469 (Archive::get_elf_object_for_member): New function.
9470 (Archive::read_all_symbols): New function.
9471 (Archive::read_symbols): New function.
9472 (Archive::Archive_member): New class.
9473 (Archive::members_): New member.
9474 (Archive::num_members_): New member.
9475 * main.cc: Include archive.h.
9476 (main): Call Archive::print_stats.
9477 * mapfile.cc (Mapfile::report_include_archive_member): Delete
9478 archive parameter; member_name is now the fully-decorated name.
9479 * mapfile.h (Mapfile::report_include_archive_member): Likewise.
9480 * options.h: (General_options): Add --preread-archive-symbols option.
9481 * readsyms.cc (Read_symbols::do_read_symbols): Change call to
9486 * symtab.h (Symbol::use_plt_offset): New function.
9487 * i386.cc (Relocate::relocate): Call Symbol::use_plt_offset.
9488 * powerpc.cc (Relocate::relocate): Likewise.
9489 * sparc.cc (Relocate::relocate): Likewise.
9490 * x86_64.cc (Relocate::relocate): Likewise.
9491 * testsuite/weak_plt.sh: New test.
9492 * testsuite/weak_plt_main.cc: New test.
9493 * testsuite/weak_plt_shared.cc: New test.
9494 * testsuite/Makefile.am (check_SCRIPTS): Add weak_plt.sh.
9495 (check_PROGRAMS): Add weak_plt.
9496 (check_DATA): Add weak_plt_shared.so.
9497 (weak_plt_main_pic.o, weak_plt): New targets.
9498 (weak_plt_shared_pic.o, weak_plt_shared.so): New targets.
9499 * testsuite/Makefile.in: Rebuild.
9501 * testsuite/Makefile.am (weak_alias_test_1.so): Depend upon
9503 (weak_alias_test_2.so, weak_alias_test_4.so): Likewise.
9504 * testsuite/Makefile.in: Rebuild.
9508 * Makefile.am (POTFILES.in): Set LC_ALL=C.
9509 * Makefile.in: Regenerate.
9510 * po/POTFILES.in: Regenerate.
9514 * script.cc (Script_options::finalize_symbols): Finalize SECTIONS
9515 symbols before other symbols.
9516 * testsuite/script_test_2.cc (test_addr): Declare.
9517 (test_addr_alias): Declare.
9518 (main): Check that test_addr and test_addr_alias have the right
9520 * testsuite/script_test_2.t: Define test_addr_alias and
9526 * descriptors.cc: New file.
9527 * descriptors.h: New file.
9528 * gold-threads.h (class Hold_optional_lock): New class.
9529 * fileread.cc: Include "descriptors.h".
9530 (File_read::~File_read): Release descriptor rather than closing
9532 (File_read::open) [file]: Call open_descriptor rather than open.
9533 Set is_descriptor_opened_.
9534 (File_read::open) [memory]: Assert that descriptor is not open.
9535 (File_read::reopen_descriptor): New function.
9536 (File_read::release): Release descriptor.
9537 (File_read::do_read): Make non-const. Reopen descriptor.
9538 (File_read::read): Make non-const.
9539 (File_read::make_view): Reopen descriptor.
9540 (File_read::do_readv): Likewise.
9541 * fileread.h (class File_read): Add is_descriptor_opened_ field.
9542 Update declarations.
9543 * layout.cc: Include "descriptors.h".
9544 (Layout::create_build_id): Use open_descriptor rather than open.
9545 * output.cc: Include "descriptors.h".
9546 (Output_file::open): Use open_descriptor rather than open.
9547 * archive.cc (Archive::const_iterator): Change Archive to be
9549 (Archive::begin, Archive::end): Make non-const.
9550 (Archive::count_members): Likewise.
9551 * archive.h (class Archive): Update declarations.
9552 * object.h (Object::read): Make non-const.
9553 * Makefile.am (CCFILES): Add descriptors.cc.
9554 (HFILES): Add descriptors.h.
9555 * Makefile.in: Rebuild.
9558 * gold.h: Always include <clocale>. Add Solaris workarounds
9559 following code in binutils/sysdep.h.
9562 * ehframe.cc (Eh_frame::add_ehframe_input_section): Check whether
9563 this->eh_frame_hdr_ is NULL before using it.
9565 * dynobj.cc (Versions::Versions): Update comment.
9567 * dynobj.cc (Versions::Versions): If there is an soname, use it as
9568 the base version name.
9570 * stringpool.cc (Stringpool_template::add_with_length): Set key to
9571 array size plus one.
9572 (Stringpool_template::set_string_offsets): Subtract one from key
9573 before using it as an array index.
9574 (Stringpool_template::get_offset_with_length): Likewise.
9575 (Stringpool_template::write_to_buffer): Likewise.
9576 * stringpool.h (Stringpool_template::get_offset_from_key):
9582 * object.h (Merged_symbol_value::value): Do our best to handle a
9586 * script.cc (Version_script_info::get_versions): Don't add empty
9587 version tag to return value.
9588 (Version_script_info::get_symbol_version_helper): Change return
9589 type to bool. Add pversion parameter. Change all callers.
9590 (script_register_vers_node): Don't require a non-NULL tag.
9591 * script.h (class Version_script_info): Update declarations.
9592 (Version_script_info::get_symbol_version): Change return type to
9593 bool. Add version parameter. Change all callers.
9594 * symtab.cc (Sized_symbol::add_from_relobj): Rework version
9595 handling. Handle an empty version from a version script.
9596 (Symbol_table::define_special_symbol): Likewise.
9597 * testsuite/ver_test_10.script: New file.
9598 * testsuite/ver_test_10.sh: New file.
9599 * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_10.sh.
9600 (check_DATA): Add ver_test_10.syms.
9601 (ver_test_10.syms, ver_test_10.so): New target.
9602 * testsuite/Makefile.in: Rebuild.
9606 * symtab.cc (Symbol_table::sized_write_symbol): Only set st_size
9607 to zero for undefined symbols from dynamic libraries.
9611 * symtab.cc (Symbol_table::resolve): Remove version parameter.
9613 * symtab.h (class Symbol_table): Update declaration.
9614 * testsuite/ver_test_9.cc: New file.
9615 * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_9.
9616 (ver_test_9_SOURCES, ver_test_9_DEPENDENCIES): Define.
9617 (ver_test_9_LDFLAGS, ver_test_9_LDADD): Define.
9618 (ver_test_9.so, ver_test_9.o): New targets.
9619 * testsuite/Makefile.in: Rebuild.
9623 * options.h (class General_options): Define --check-sections.
9624 * layout.cc (Layout::set_segment_offsets): Handle
9627 * options.h (class General_options): Define -n/--nmagic and
9629 * options.cc (General_options::finalize): For -n/--nmagic or
9630 -N/--omagic, set -static.
9631 * layout.cc (Layout::attach_allocated_section_to_segment): If
9632 -N/--omagic, don't put read-only and read-write sections in
9634 (Layout::find_first_load_seg): If -N/--omagic, don't insist on
9635 finding a read-only segment.
9636 (Layout::set_segment_offsets): If -N/--omagic or -n/--nmagic,
9637 don't set the minimum segment alignment to the common page size,
9638 and don't set the file offset to the address modulo the page size.
9639 * script-sections.cc (Script_sections::create_segments): If
9640 -n/--omagic, don't put read-only and read-write sections in
9643 * cref.cc: New file.
9645 * options.h (class General_options): Add --print-symbol-counts.
9646 * main.cc (main): Issue defined symbol report if requested.
9647 * archive.cc (Archive::interpret_header): Make into a const member
9649 (Archive::add_symbols): Call Input_objects::archive_start and
9651 (Archive::const_iterator): Define new class.
9652 (Archive::begin, Archive::end): New functions.
9653 (Archive::include_all_members): Rewrite to use iterator.
9654 (Archive::count_members): New function.
9655 * archive.h (class Archive): Update declarations.
9656 (Archive::filename): New function.
9657 * object.cc: Include "cref.h".
9658 (Sized_relobj::Sized_relobj): Initialize defined_count_.
9659 (Sized_relobj::do_get_global_symbol_counts): New function.
9660 (Input_objects::add_object): Add object to cross-referencer.
9661 (Input_objects::archive_start): New function.
9662 (Input_objects::archive_stop): New function.
9663 (Input_objects::print_symbol_counts): New function.
9664 * object.h: Declare Cref and Archive.
9665 (Object::get_global_symbol_counts): New function.
9666 (Object::do_get_global_symbol_counts): New pure virtual function.
9667 (class Sized_relobj): Add defined_count_ field. Update
9669 (class Input_objects): Add cref_ field. Update constructor.
9670 Update declarations.
9671 * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and
9673 (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing
9675 (Sized_dynobj::do_get_global_symbol_counts): New function.
9676 * dynobj.h (class Sized_dynobj): Add fields symbols_ and
9677 defined_count_. Update declarations. Define Symbols typedef.
9678 * symtab.cc (Symbol_table::add_from_relobj): Add defined
9679 parameter. Change all callers.
9680 (Symbol_table::add_from_dynobj): Add sympointers and defined
9681 parameters. Change all callers.
9682 * symtab.h (class Symbol_table): Update declarations.
9683 * Makefile.am (CCFILES): Add cref.cc.
9684 (HFILES): Add cref.h.
9685 * Makefile.in: Rebuild.
9689 * symtab.cc (Symbol_table::sized_write_symbol): Set symbol size
9690 to zero when writing undefined symbols.
9694 * output.cc (Output_section::add_input_section): Don't try to
9695 merge empty merge sections.
9699 * symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
9700 Include symbol version in error message.
9704 * configure.ac (gold_cv_c_random_seed): New configured variable.
9705 (RANDOM_SEED_CFLAGS): New substituted variable.
9706 * Makefile.am (AM_CFLAGS, AM_CXXFLAGS): Add $(RANDOM_SEED_CFLAGS).
9707 * configure: Rebuild.
9708 * Makefile.in: Likewise.
9709 * testsuite/Makefile.in: Likewise.
9713 * symtab.cc (Symbol_table::add_from_object): Rewrite the case
9714 where we see NAME/NULL and NAME/VERSION as separate symbols.
9715 * testsuite/ver_test_main.cc (main): Call t4.
9716 (t4, t4_2a): Define.
9717 * testsuite/ver_test_2.cc (t4_2): Define.
9718 * testsuite/ver_test_2.script: Put t4_2a in VER2.
9719 * testsuite/ver_test_4.cc (t4_2a): Define.
9720 * testsuite/ver_test_4.script: Put t4_2a in VER2.
9721 * testsuite/ver_test.h (t4, t4_2, t4_2a): Declare.
9725 * dynobj.cc (Versions::add_def): If we give an error about a
9726 missing version, go ahead and create the version anyhow.
9730 Handle output sections with more than 0x7fffffff bytes.
9731 * object.h (class Relobj): Change map_to_output_ to
9732 output_sections_, and just keep a section pointer. Change all
9733 uses. Move comdat group support to Sized_relobj.
9734 (Relobj::is_section_specially_mapped): Remove.
9735 (Relobj::output_section): Remove poff parameter. Change all
9737 (Relobj::output_section_offset): New function.
9738 (Relobj::set_section_offset): Rewrite.
9739 (Relobj::map_to_output): Remove.
9740 (Relobj::output_sections): New function.
9741 (Relobj::do_output_section_offset): New pure virtual function.
9742 (Relobj::do_set_section_offset): Likewise.
9743 (class Sized_relobj): Add section_offsets_ field. Add comdat
9744 group support from Relobj. Update declarations.
9745 (Sized_relobj::get_output_section_offset): New function.
9746 (Sized_relobj::do_output_section_offset): New function.
9747 (Sized_relobj::do_set_section_offset): New function.
9748 * object.cc (Relobj::output_section_address): Remove.
9749 (Sized_relobj::Sized_relobj): Initialize new fields.
9750 (Sized_relobj::include_section_group): Cast find_kept_object to
9752 (Sized_relobj::include_linkonce_section): Likewise.
9753 (Sized_relobj::do_layout): Use separate arrays for output section
9755 (Sized_relobj::do_count_local_symbols): Change map_to_output to
9757 (Sized_relobj::do_finalize_local_symbols): Change map_to_output to
9758 output_sections and section_offsets.
9759 (Sized_relobj::write_local_symbols): Likewise.
9760 (map_to_kept_section): Compute output address directly.
9761 * reloc.cc (Sized_relobj::do_read_relocs): Change map_to_output to
9762 output_sections and section_offsets.
9763 (Sized_relobj::write_sections): Likewise.
9764 (Sized_relobj::relocate_sections): Likewise.
9765 * symtab.cc (sized_finalize_symbol): Use output_section_offset.
9766 * output.h (class Output_reloc): Update declarations. Change
9767 u2_.relobj to Sized_relobj*.
9768 (class Output_data_reloc): Change add functions to use
9770 * output.cc (Output_reloc::Output_reloc): Change relobj to
9772 (Output_reloc::local_section_offset): Change return type to
9773 Elf_Addr. Use get_output_section_offset.
9774 (Output_reloc::get_address): Likewise.
9775 (Output_section::is_input_address_mapped): Don't call
9776 is_section_specially_mapped.
9777 (Output_section::output_offset): Likewise.
9778 (Output_section::output_address): Likewise.
9779 (Output_section::starting_output_address): Likewise.
9780 * copy-relocs.cc (Copy_relocs::copy_reloc): Change object
9781 parameter to Sized_relobj*.
9782 (Copy_relocs::need_copy_reloc): Likewise.
9783 (Copy_relocs::save): Likewise.
9784 * copy-relocs.h (class Copy_relocs): Update declarations.
9785 (class Copy_relocs::Copy_reloc_entry): Change constructor to use
9786 Sized_relobj*. Change relobj_ field to Sized_relobj*.
9787 * target-reloc.h (relocate_for_relocatable): Change
9788 offset_in_output_section type to Elf_Addr. Change code that uses
9790 * layout.cc (Layout::layout): Always set *off.
9791 * mapfile.cc (Mapfile::print_input_section): Use
9792 output_section_offset.
9793 * i386.cc (Target_i386::copy_reloc): Change object parameter to
9795 * powerpc.cc (Target_powerpc::copy_reloc): Likewise.
9796 * sparc.cc (Target_sparc::copy_reloc): Likewise.
9797 * x86_64.cc (Target_x86_64::copy_reloc): Likewise.
9801 * layout.cc (Layout::include_section): Do not discard unrecognized
9802 SHT_STRTAB sections.
9806 * script.cc (Lex::can_continue_name): Make '?' allowable in
9807 version-script names.
9808 * testsuite/version_script.map: Change glob pattern to use '?'
9813 * symtab.cc (Symbol_table::add_undefined_symbols_from_command_line):
9820 * powerpc.cc (Powerpc_relocate_functions::addr16_ha) [both
9821 versions]: Don't try to read the value in the contents, since we
9822 don't use it. Use the template endianness when writing.
9826 * fileread.cc (File_read::make_view): Assert on zero-length view.
9827 * object.cc (Sized_relobj::do_read_symbols): Don't try to read
9828 symbol table when there are no symbols to read.
9832 * version.cc (version_string): Bump to 1.7
9836 * powerpc.cc (Powerpc_relocate_functions::addr16_ha): cast
9837 constant 0xFFFF to type Valtype.
9838 (Powerpc_relocate_functions::rel16_ha): Likewise.
9842 * output.h (Output_section::Input_section): Initialize p2align_ to
9843 zero for Output_section_data constructors.
9844 (Output_section::Input_section::addralign): If not an input
9845 section, return the alignment of the Output_section_data.
9846 * testsuite/copy_test.cc: New file.
9847 * testsuite/copy_test_1.cc: New file.
9848 * testsuite/copy_test_2.cc: New file.
9849 * testsuite/Makefile.am (check_PROGRAMS): Add copy_test.
9850 (copy_test_SOURCES, copy_test_DEPENDENCIES): New variables.
9851 (copy_test_LDFLAGS, copy_test_LDADD): New variables.
9852 (copy_test_1_pic.o, copy_test_1.so): New targets.
9853 (copy_test_2_pic.o, copy_test_2.so): New targets.
9854 * testsuite/Makefile.in: Rebuild.
9856 * script-sections.cc (Script_sections::place_orphan): Initialize
9857 local variable exact.
9861 * powerpc.cc (Output_data_plt_powerpc::do_write): 8 + 4 = 0xC.
9866 * powerpc.cc: New file.
9867 * Makefile.am (TARGETSOURCES): Add powerpc.cc
9868 (ALL_TARGETOBJS): Add powerpc.$(OBJEXT)
9869 * configure.tgt: Add entries for powerpc-* and powerpc64-*.
9870 * Makefile.in: Rebuild.
9874 * testsuite/relro_test.cc: Include <cstdio>, <cstdlib>, and
9876 (throwing, orig_terminate): New static variables.
9877 (terminate_handler): New static function.
9878 (t2): Set terminate handler.
9883 * binary.cc (Binary_to_elf::sized_convert): Fix .data
9888 * archive.cc (Archive::include_all_members) Correct to step
9889 over symbol table and extended name table in thin archives.
9894 * target-reloc.h (relocate_for_relocatable): Fix new_offset
9899 * reduced_debug_output.cc: New file.
9900 * reduced_debug_output.h: New file.
9901 * options.h (class General_options): Add --strip-debug-non-line.
9902 * options.cc (General_options::finalize): Add strip_debug_non_line
9903 to the strip heirarchy.
9904 * layout.h (class Layout): Add debug_abbrev_ and debug_info_
9906 * layout.cc: Include "reduced_debug_output.h".
9907 (Layout::Layout): Initialize new fields.
9908 (line_only_debug_sections): New static array.
9909 (is_lines_only_debug_sections): New static inline function.
9910 (Layout::include_section): Handle --strip-debug-non-line.
9911 (Layout::make_output_section): If --strip-debug-non-line, build
9912 new output sections for .debug_abbrev and .debug_info.
9913 * dwarf_reader.cc (read_unsigned_LEB_128): Move to namespace
9914 gold. Warn about possible overflow.
9915 (read_signed_LEB_128): Likewise.
9916 * dwarf_reader.h: (read_unsigned_LEB_128): Declare.
9917 (read_signed_LEB_128): Declare.
9918 * Makefile.am (CCFILES): Add reduced_debug_output.cc.
9919 (HFILES): Add reduced_debug_output.h.
9920 * Makefile.in: Rebuild.
9924 * mapfile.cc: New file.
9925 * mapfile.h: New file.
9926 * options.h (class General_options): Add -M/--print-map and -Map.
9927 * options.cc (General_options::finalize): Make -M equivalent to
9929 * main.cc: Include <cstdio> and "mapfile.h".
9930 (main): Open mapfile if requested.
9931 * gold.cc (class Middle_runner): Add mapfile_ field. Update
9932 constructor. Change caller.
9933 (queue_initial_tasks): Add mapfile parameter. Change caller.
9934 (queue_middle_tasks): Likewise.
9935 * gold.h (queue_initial_tasks, queue_middle_tasks): Update
9937 * archive.cc: Include "mapfile.h".
9938 (Archive::add_symbols): Add mapfile parameter. Change all
9939 callers. Pass mapfile, symbol, and reason to include_member.
9940 (Archive::include_all_members): Add mapfile parameter. Change all
9942 (Archive::include_member): Add mapfile, sym, and why parameters.
9943 Change all callers. Report inclusion to map file.
9944 * archive.h: Include "fileread.h".
9945 (class Archive): Update declarations.
9946 (Archive::file): New const method.
9947 (class Add_archive_symbols): Add mapfile_ field. Update
9948 constructor. Change all callers.
9949 * readsyms.h (class Read_symbols): Likewise.
9950 (class Finish_group): Likewise.
9951 (class Read_script): Likewise.
9952 * common.cc: Include "mapfile.h".
9953 (Symbol_table::allocate_commons): Add mapfile parameter. Change
9955 (Symbol_table::do_allocate_commons): Likewise.
9956 (Symbol_table::do_allocate_commons_list): Likewise. Report common
9957 symbol allocation to mapfile.
9958 * common.h (class Allocate_commons_task): Add mapfile_ field.
9959 Update constructor. Change all callers.
9960 * symtab.h (class Symbol_table): Update declarations.
9961 * layout.cc: Include "mapfile.h".
9962 (Layout_task_runner::run): Print information to mapfile.
9963 (Layout::create_gold_note): Change Output_data_fixed_space to
9964 Output_data_zero_fill.
9965 (Layout::create_build_id): Likewise.
9966 (Layout::print_to_mapfile): New function.
9967 * layout.h (class Layout_task_runner): Add mapfile_ field. Update
9968 constructor. Change caller.
9969 (class Layout): Declare print_to_mapfile.
9970 * output.cc (Output_section::Input_section::print_to_mapfile): New
9972 (Output_section::add_input_section): If producing a map, always
9973 add to input_sections_ list.
9974 (Output_section::do_print_to_mapfile): New function.
9975 (Output_segment::print_sections_to_mapfile): New function.
9976 (Output_segment::print_section_list_to_mapfile): New function.
9977 * output.h: Include "mapfile.h".
9978 (Output_data::print_to_mapfile): New function.
9979 (Output_data::do_print_to_mapfile): New virtual function.
9980 (Output_segment_headers::do_print_to_mapfile): New function.
9981 (Output_file_header::do_print_to_mapfile): New function.
9982 (Output_data_const::do_print_to_mapfile): New function.
9983 (class Output_data_const_buffer): Add map_name_ field. Update
9984 constructor. Change all callers. Add do_print_to_mapfile
9986 (class Output_data_fixed_space): Likewise.
9987 (class Output_data_space): Likewise.
9988 (class Output_data_zero_fill): New class.
9989 (Output_data_strtab::do_print_to_mapfile): New function.
9990 (Output_data_reloc_base::do_print_to_mapfile): New function.
9991 (Output_relocatable_relocs::do_print_to_mapfile): New function.
9992 (Output_data_group::do_print_to_mapfile): New function.
9993 (Output_data_got::do_print_to_mapfile): New function.
9994 (Output_data_dynamic::do_print_to_mapfile): New function.
9995 (Output_symtab_xindex::do_print_to_mapfile): New function.
9996 (class Output_section): Declare do_print_to_mapflie. Declare
9997 print_to_mapfile in Input_section.
9998 (class Output_segment): Declare new functions.
9999 * object.h (Sized_relobj::symbol_count): New function.
10000 * script-sections.cc
10001 (Output_section_element_dot_assignment::set_section_addresses):
10002 Change Output_data_fixed_space to Output_data_zero_fill.
10003 (Output_data_expression::do_print_to_mapfile): New function.
10004 * script.cc (read_input_script): Add mapfile parameter. Change
10006 * script.h (read_input_script): Update declaration.
10007 * ehframe.h (Eh_frame_hdr::do_print_to_mapfile): New function.
10008 (Eh_frame::do_print_to_mapfile): New function.
10009 * merge.h (Output_merge_data::do_print_to_mapfile): New function.
10010 (Output_merge_string::do_print_to_mapfile): New function.
10011 * i386.cc (Output_data_plt_i386::do_print_to_mapfile): New
10013 * sparc.cc (Output_data_plt_sparc::do_print_to_mapfile): New
10015 * x86_64.cc (Output_data_plt_x86_64::do_print_to_mapfile): New
10017 * Makefile.am (CCFILES): Add mapfile.cc.
10018 (HFILES): Add mapfile.h.
10019 * Makefile.in: Rebuild.
10023 * options.h (class General_options): Add -z relro.
10024 * layout.cc (Layout::Layout): Initialize relro_segment_.
10025 (Layout::add_output_section_data): Return the output section.
10026 (Layout::make_output_section): Rcognize relro sections and mark
10027 them appropriately.
10028 (Layout::attach_allocated_section_to_segment): Put relro sections
10029 in a PT_GNU_RELRO segment.
10030 (Layout::create_initial_dynamic_sections): Mark the .dynamic
10032 (Layout::segment_precedes): Sort PT_GNU_RELRO segments after
10034 (Layout::linkonce_mapping): Map d.rel.ro.local to
10035 .data.rel.ro.local.
10036 (Layout::output_section_name): Us .data.rel.ro.local for any
10037 section which begins with that.
10038 * layout.h (class Layout): Update add_output_section_data
10039 declaration. Add relro_segment_ field.
10040 * output.cc (Output_section::Output_section): Initialize is_relro_
10041 and is_relro_local_ fields.
10042 (Output_segment::add_output_section): Group relro sections.
10043 (Output_segment::is_first_section_relro): New function.
10044 (Output_segment::maximum_alignment): If there is a relro section,
10045 align the segment to the common page size.
10046 (Output_segment::set_section_addresses): Track whether we are
10047 looking at relro sections. If the last section is a relro
10048 section, align to the common page size.
10049 (Output_segment::set_section_list_addresses): Add in_relro
10050 parameter. Change all callers. Align to the page size when
10051 moving from relro to non-relro section.
10052 (Output_segment::set_offset): Align memsz of a PT_GNU_RELRO
10054 * output.h (class Output_section): Add is_relro_ and
10055 is_relro_local_ fields.
10056 (Output_section::is_relro): New function.
10057 (Output_section::set_is_relro): New function.
10058 (Output_section::is_relro_local): New function.
10059 (Output_section::set_is_relro_local): New function.
10060 (class Output_segment): Update declarations.
10061 * i386.cc (Target_i386::got_section): Mark .got section as relro.
10062 * sparc.cc (Target_sparc::got_section): Likewise.
10063 * x86_64.cc (Target_x86_64::got_section): Likewise.
10064 * testsuite/relro_test_main.cc: New file.
10065 * testsuite/relro_test.cc: New file.
10066 * testsuite/Makefile.am (check_PROGRAMS): Add relro_test.
10067 (relro_test_SOURCES, relro_test_DEPENDENCIES): New variables.
10068 (relro_test_LDFLAGS, relro_test_LDADD): New variables.
10069 (relro_test.so, relro_test_pic.o): New targets.
10070 * testsuite/Makefile.in: Rebuild.
10074 * output.cc (Output_segment::add_output_section): Remove front
10076 * output.h (class Output_segment): Remove
10077 add_initial_output_section and overloaded add_output_section.
10078 Update declaration of remaining add_output_section.
10079 * layout.cc (Layout::create_interp): Call add_output_section
10080 rather than add_initial_output_section.
10081 (Layout::finish_dynamic_section): Likewise.
10083 * i386.cc (Target_i386::Relocate::relocate_tls): Set dynamic type
10084 for TLS_GOTDESC and TLS_DESC_CALL. Only optimize TLS_LDO_32 if we
10085 know the dynamic type.
10086 * x86_64.cc (Target_x86_64::Relocate): Add saw_tls_block_reloc_
10087 field. Initialize it in constructor.
10088 (Target_x86_64::Relocate::relocate_tls): Record that we saw a TLS
10089 block reloc for TLSGD, GOTPC32_TLSDESC, TLSDESC_CALL, and TLSLD.
10090 Only optimize DTPOFF32 and DTPOFF64 if we have seen a TLS block
10093 * output.cc (Output_reloc::get_address): Change return type to
10095 * output.h (class Output_reloc): Update get_address declaration.
10096 * x86_64.cc (Output_data_plt_x86_64::do_write): Use 64-bit types
10097 for section addresses.
10102 * gold.cc (gold_nomem): Use return value of write.
10106 * symtab.c (Symbol::init_base_output_data): Add version
10107 parameter. Change all callers.
10108 (Symbol::init_base_output_segment): Likewise.
10109 (Symbol::init_base_constant): Likewise.
10110 (Symbol::init_base_undefined): Likewise.
10111 (Sized_symbol::init_output_data): Likewise.
10112 (Sized_symbol::init_output_segment): Likewise.
10113 (Sized_symbol::init_constant): Likewise.
10114 (Sized_symbol::init_undefined): Likewise.
10115 (Symbol_table::do_define_in_output_data): If the new symbol has a
10116 version, mark it as the default.
10117 (Symbol_table::do_define_in_output_segment): Likewise.
10118 (Symbol_table::do_define_as_constant): Likewise.
10119 * symtab.h (class Symbol): Update declarations.
10120 (class Sized_symbol): Likewise.
10121 * resolve.cc (Symbol::override_version): New function.
10122 (Symbol::override_base): Call override_version.
10123 (Symbol::override_base_with_special): Likewise.
10124 * testsuite/ver_script_8.script: New file.
10125 * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_8.
10126 (ver_test_8_SOURCES, ver_test_8_DEPENDENCIES): Define.
10127 (ver_test_8_LDFLAGS, ver_test_8_LDADD): Define.
10128 (ver_test_8_1.so, ver_test_8_2.so): New targets.
10133 * options.h (DEFINE_set): Add VARNAME_begin and VARNAME_end
10135 (class General_options): Remove existing --undefined, and add
10136 --no-undefined instead. Add new --undefined as synonym for -u.
10137 * archive.cc (Archive::add_symbols): Check whether symbol was
10139 * gold.cc (queue_middle_tasks): Add -u symbols to symbol table.
10140 * symtab.h (class Symbol): Rename CONSTANT to IS_CONSTANT; change
10141 all uses. Add IS_UNDEFINED. Update declarations to split
10142 different versions of init_base. Declare init_base_undefined.
10143 (Symbol::is_defined): Handle IS_UNDEFINED.
10144 (Symbol::is_undefined): Likewise.
10145 (Symbol::is_weak_undefined): Call is_undefined.
10146 (Symbol::is_absolute): Handle IS_CONSTANT.
10147 (class Sized_symbol): Update declarations to split different
10148 versions of init. Declare init_undefined.
10149 (class Symbol_table): Declare new functions.
10150 * symtab.cc (Symbol::init_base_object): Rename from init_base.
10151 Change all callers.
10152 (Symbol::init_base_output_data): Likewise.
10153 (Symbol::init_base_output_segment): Likewise.
10154 (Symbol::init_base_constant): Likewise.
10155 (Symbol::init_base_undefined): New function.
10156 (Sized_symbol::init_object): Rename from init. Change all
10158 (Sized_symbol::init_output_data): Likewise.
10159 (Sized_symbol::init_output_segment): Likewise.
10160 (Sized_symbol::init_constant): Likewise.
10161 (Sized_symbol::init_undefined): New function.
10162 (Symbol_table::add_undefined_symbols_from_command_line): New
10164 (Symbol_table::do_add_undefined_symbols_from_command_line): New
10166 (Symbol::final_value_is_known): Handle IS_UNDEFINED.
10167 (Symbol::output_section): Likewise.
10168 (Symbol::set_output_section): Likewise.
10169 (Symbol_table::sized_finalize_symbol): Likewise.
10170 (Symbol_table::sized_write_globals): Likewise.
10171 * resolve.cc (Symbol_table::should_override): Likewise.
10172 (Symbol::override_base_with_special): Likewise.
10174 * symtab.cc (Symbol_table::add_from_dynobj): If we see a protected
10175 symbol, change it to have default visibility.
10176 * testsuite/protected_1.cc: New file.
10177 * testsuite/protected_2.cc: New file.
10178 * testsuite/protected_3.cc: New file.
10179 * testsuite/protected_main_1.cc: New file.
10180 * testsuite/protected_main_2.cc: New file.
10181 * testsuite/protected_main_3.cc: New file.
10182 * testsuite/Makefile.am (check_PROGRAMS): Add protected_1.
10183 (protected_1_SOURCES, protected_1_DEPENDENCIES): Define.
10184 (protected_1_LDFLAGS, protected_1_LDADD): Define.
10185 (protected_1.so): New target.
10186 (protected_1_pic.o, protected_2_pic.o): New targets.
10187 (protected_3_pic.o): New target.
10188 (check_PROGRAMS): Add protected_2.
10189 (protected_2_SOURCES, protected_2_DEPENDENCIES): Define.
10190 (protected_2_LDFLAGS, protected_2_LDADD): Define.
10191 * testsuite/Makefile.in: Rebuild.
10193 * options.h (DEFINE_var): Add set_user_set_##varname__.
10194 (DEFINE_bool_alias): New macro.
10195 (class General_options): Define -Bstatic using DEFINE_bool_alias
10196 rather than DEFINE_special. Add --undefined as an alias for -z
10198 * options.cc (General_options::parse_Bstatic): Remove.
10200 * options.h (class General_options): Add --fatal-warnings.
10201 * main.cc (main): Implement --fatal-warnings.
10202 * errors.h (Errors::warning_count): New function.
10204 * options.h (class General_options): Add -Bsymbolic-functions.
10205 * symtab.h (Symbol::is_preemptible): Check for
10206 -Bsymbolic-functions.
10210 * options.h (DEFINE_bool): For DASH_Z, create the negative option
10211 as noVARNAME rather than no-VARNAME.
10212 (class General_options): Add option -z combreloc.
10213 * output.h (class Output_reloc) [SHT_REL]: Declare compare and
10215 (Output_reloc::sort_before) [SHT_REL]: New function.
10216 (Output_reloc::sort_before) [SHT_RELA]: New function.
10217 (class Output_data_reloc_base): Add sort_relocs_ field. Define
10218 Sort_relocs_comparison.
10219 (Output_data_reloc_base::Output_data_reloc_base): Add sort_relocs
10220 parameter. Change all callers.
10221 (Output_data_reloc::Output_data_reloc) [both versions]: Add
10222 sort_relocs parameter. Change all callers.
10223 * output.cc (Output_reloc::get_address): New function, broken out
10225 (Output_reloc::write_rel): Call it.
10226 (Output_reloc::compare): New function.
10227 (Output_data_reloc_base::do_write): Optionally sort relocs.
10229 * configure.ac: If targ_extra_obj is set, link it in.
10230 * configure.tgt: Initialize all variables.
10231 (x86_64*): Set targ_extra_obj and targ_extra_size.
10232 * configure: Rebuild.
10234 * object.cc (Sized_relobj::include_section_group): Adjust section
10235 indexes read from group data. Build vector to pass to
10237 * layout.cc (Layout::layout_group): Add flags and shndxes
10238 parameters. Remove contents parameter. Change caller. Update
10239 explicit instantiations.
10240 * layout.h (class Layout): Update layout_group declaration.
10241 * output.cc (Output_data_group::Output_data_group): Add flags and
10242 input_shndxes parameters. Remove contents parameter. Change
10244 (Output_data_group::do_write): Change input_sections_ to
10246 * output.h (class Output_data_group): Update constructor
10247 declaration. Rename input_sections_ to input_shndxes_.
10248 * testsuite/many_sections_test.cc: Add template.
10252 * target-reloc.h (relocate_section): Fix dead-pointer bug.
10254 * layout.cc (Layout::include_section): Refactored check for debug
10256 (Layout::add_comdat): Add new parameters. Change type
10257 of signature parameter. Add object and shndx to signatures table.
10258 (Layout::find_kept_object): New function.
10259 * layout.h: Include <cstring>.
10260 (Layout::is_debug_info_section): New function.
10261 (Layout::add_comdat): Add new parameters.
10262 (Layout::find_kept_object): New function.
10263 (Layout::Kept_section): New struct.
10264 (Layout::Signatures): Change type of map range.
10265 * object.cc (Relobj::output_section_address): New function.
10266 (Sized_relobj::include_section_group): Add new parameters. Change
10267 calls to Layout::add_comdat. Change to build table of kept comdat
10268 groups and table mapping discarded sections to kept sections.
10269 (Sized_relobj::include_linkonce_section): Likewise. Add new parameter.
10270 (Sized_relobj::do_layout): Change calls to include_section_group and
10271 include_linkonce_section.
10272 (Sized_relobj::do_finalize_local_symbols): Do not set local symbol
10273 value to zero when section is discarded.
10274 (Sized_relobj::map_to_kept_section): New function.
10275 * object.h (Relobj::output_section_address): New function.
10276 (Relobj::Comdat_group): New type.
10277 (Relobj::find_comdat_group): New function.
10278 (Relobj::Comdat_group_table): New type.
10279 (Relobj::Kept_comdat_section): New type.
10280 (Relobj::Kept_comdat_section_table): New type.
10281 (Relobj::add_comdat_group): New function.
10282 (Relobj::set_kept_comdat_section): New function.
10283 (Relobj::get_kept_comdat_section): New function.
10284 (Relobj::comdat_groups_): New field.
10285 (Relobj::kept_comdat_sections_): New field.
10286 (Symbol_value::input_value): Update comment.
10287 (Sized_relobj::map_to_kept_section) New function.
10288 (Sized_relobj::include_linkonce_section): Add new parameter.
10289 * target-reloc.h (Comdat_behavior): New type.
10290 (get_comdat_behavior): New function.
10291 (relocate_section): Add code to map a discarded section to the
10292 corresponding kept section when applying a relocation.
10296 * dwarf_reader.cc (next_generation_count): New static var.
10297 (Addr2line_cache_entry): New struct.
10298 (addr2line_cache): New static var.
10299 (Dwarf_line_info::one_addr2line): Added caching.
10300 (Dwarf_line_info::clear_addr2line_cache): New function.
10301 * dwarf_reader.h (Dwarf_line_info::one_addr2line): Add
10302 cache-size parameter.
10303 (Dwarf_line_info::one_addr2line_cache): New function.
10304 * symtab.cc (Symbol_table::detect_odr_violations): Pass
10305 new cache-size argument to one_addr2line(), and clear cache.
10309 * i386.cc (Relocate::relocate): Fix typos for R_386_PC16 and
10310 R_386_PC8 relocations.
10314 * object.cc (Sized_relobj::include_section_group): Check for
10315 invalid section group.
10317 * object.cc (make_elf_object): Correct test for 64-bit ELF file
10320 * readsyms.cc (Read_symbols::do_read_symbols): Use get_view rather
10321 than read for file header.
10322 * archive.cc (Archive::include_member): Likewise.
10326 * aclocal.m4: Regenerate.
10327 * configure: Regenerate.
10331 * version.cc (version_string): Bump to 1.6.
10333 * testsuite/Makefile.am (many_sections_r_test): New target.
10334 (many_sections_r_test_SOURCES): Remove.
10335 (many_sections_r_test_DEPENDENCIES): Remove.
10336 (many_sections_r_test_LDFLAGS): Remove.
10337 (many_sections_r_test_LDADD): Remove.
10339 * object.cc (Sized_relobj::do_add_symbols): Always pass
10340 local_symbol_count_ to add_from_relobj.
10342 * testsuite/Makefile.am (many_sections_check.h): Only check one in
10343 every thousand variables.
10344 * testsuite/Makefile.in: Rebuild.
10346 * object.cc (Xindex::initialize_symtab_xindex): New function.
10347 (Xindex::read_symtab_xindex): New function.
10348 (Xindex::sym_xindex_to_shndx): New function.
10349 (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if
10351 (Sized_relobj::do_initialize_xindex): New function.
10352 (Sized_relobj::do_read_symbols): Adjust section links.
10353 (Sized_relobj::symbol_section_and_value): Add is_ordinary
10354 parameter. Change all callers.
10355 (Sized_relobj::include_section_group): Adjust section links and
10356 symbol section indexes.
10357 (Sized_relobj::do_layout): Adjust section links.
10358 (Sized_relobj::do_count_local_symbols): Adjust section links and
10359 symbol section indexes.
10360 (Sized_relobj::do_finalize_local_symbols): Distinguish between
10361 ordinary and special symbols.
10362 (Sized_relobj::write_local_symbols): Add symtab_xindex and
10363 dynsym_xindex parameters. Change all callers. Adjust section
10364 links. Use SHN_XINDEX when needed.
10365 (Sized_relobj::get_symbol_location_info): Adjust section links.
10366 Don't get fooled by special symbols.
10367 * object.h (class Xindex): Define.
10368 (class Object): Add xindex_ parameter. Declare virtual functoin
10369 do_initialize_xindex.
10370 (Object::adjust_sym_shndx): New function.
10371 (Object::set_xindex): New protected function.
10372 (class Symbol_value): Add is_ordinary_shndx_ field.
10373 (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_.
10374 (Symbol_value::value): Assert ordinary section.
10375 (Symbol_value::initialize_input_to_output_map): Likewise.
10376 (Symbol_value::set_input_shndx): Add is_ordinary parameter.
10377 Change all callers.
10378 (Symbol_value::input_shndx): Add is_ordinary parameter. Change
10380 (class Sized_relobj): Update declarations.
10381 (Sized_relobj::local_symbol_input_shndx): Add is_ordinary
10382 parameter. Change all callers.
10383 (Sized_relobj::adjust_shndx): New function.
10384 * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_
10386 (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx
10387 parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section
10388 for SHT_DYNSYM section if available. Set dynsym_shndx_ field.
10389 (Sized_dynobj::read_dynsym_section): Adjust section links.
10390 (Sized_dynobj::read_dynamic): Likewise.
10391 (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust
10393 (Sized_dynobj::do_initialize_xindex): New function.
10394 * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare
10395 do_initialize_xindex.
10396 (Sized_dynobj::adjust_shndx): New function.
10397 * layout.cc (Layout::Layout): Initialize symtab_xindex_ and
10398 dynsym_xindex_ fields.
10399 (Layout::finalize): Add a call to set_section_indexes before
10400 creating the symtab sections.
10401 (Layout::set_section_indexes): Don't do anything if the section
10402 already has a section index.
10403 (Layout::create_symtab_sections): Add shnum parameter. Change
10404 caller. Create .symtab_shndx section if needed.
10405 (Layout::create_shdrs): Add shstrtab_section parameter. Change
10407 (Layout::allocated_output_section_count): New function.
10408 (Layout::create_dynamic_symtab): Create .dynsym_shndx section if
10410 * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_
10411 fields. Update declarations.
10412 (Layout::symtab_xindex): New function.
10413 (Layout::dynsym_xindex): New function.
10414 (class Write_symbols_task): Add layout_ field.
10415 (Write_symbols_task::Write_symbols_task): Add layout parameter.
10417 * output.cc (Output_section_headers::Output_section_headers): Add
10418 shstrtab_section parameter. Change all callers.
10419 (Output_section_headers::do_sized_write): Store overflow values
10420 for section count and section string table section index in
10421 section header zero.
10422 (Output_file_header::do_sized_write): Check for overflow of
10423 section count and section string table section index.
10424 (Output_symtab_xindex::do_write): New function.
10425 (Output_symtab_xindex::endian_do_write): New function.
10426 * output.h (class Output_section_headers): Add shstrtab_section_.
10427 Update declarations.
10428 (class Output_symtab_xindex): Define.
10429 (Output_section::has_out_shndx): New function.
10430 * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_
10432 (Symbol::init_base): Add st_shndx and is_ordinary parameters.
10433 Change all callers.
10434 (Sized_symbol::init): Likewise.
10435 (Symbol::output_section): Check for ordinary symbol.
10436 (Symbol_table::add_from_object): Remove orig_sym parameter. Add
10437 st_shndx, is_ordinary, and orig_st_shndx parameters. Change all
10439 (Symbol_table::add_from_relobj): Add symndx_offset parameter.
10440 Change all callers. Simplify handling of symbols from sections
10441 not included in the link.
10442 (Symbol_table::add_from_dynobj): Handle ordinary symbol
10444 (Weak_alias_sorter::operator()): Assert that symbols are
10446 (Symbol_table::sized_finalize_symbol): Handle ordinary symbol
10448 (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex
10449 parameters. Change all callers.
10450 (Symbol_table::sized_write_globals): Likewise. Handle ordinary
10451 symbol distinction. Use SHN_XINDEX when needed.
10452 (Symbol_table::write_section_symbol): Add symtab_xindex
10453 parameter. Change all callers.
10454 (Symbol_table::sized_write_section_symbol): Likewise. Use
10455 SHN_XINDEX when needed.
10456 * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update
10458 (Symbol::shndx): Add is_ordinary parameter. Change all callers.
10459 (Symbol::is_defined): Check is_ordinary.
10460 (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise.
10461 (Symbol::is_absolute, Symbol::is_common): Likewise.
10462 (class Sized_symbol): Update declarations.
10463 (class Symbol_table): Update declarations.
10464 * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary
10465 parameters. Change all callers.
10466 (Sized_symbol::override): Likewise.
10467 (Symbol_table::override): Likewise.
10468 (symbol_to_bits): Add is_ordinary parameter. Change all callers.
10469 (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx,
10470 is_ordinary, and orig_st_shndx parameters. Change all callers.
10471 * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol
10472 to be in an ordinary section.
10473 * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add
10474 object and is_ordinary parameters. Change all callers.
10475 (Sized_dwarf_line_info::read_relocs): Add object parameter.
10476 Change all callers. Don't add undefined or non-ordinary symbols
10478 (Sized_dwarf_line_info::read_line_mappings): Add object parameter.
10479 Change all callers.
10480 * dwarf_reader.h (class Sized_dwarf_line_info): Update
10482 * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol.
10483 * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links.
10484 (Sized_relobj::relocate_sections): Likewise.
10485 * target-reloc.h (scan_relocs): Adjust section symbol index.
10486 (scan_relocatable_relocs): Likewise.
10487 * i386.cc (Scan::local): Check for ordinary symbols.
10488 * sparc.cc (Scan::local): Likewise.
10489 * x86_64.cc (Scan::local): Likewise.
10490 * testsuite/binary_unittest.cc (Sized_binary_test): Update calls
10491 to symbol_section_and_value.
10492 * testsuite/many_sections_test.cc: New file.
10493 * testsuite/Makefile.am (BUILT_SOURCES): Define.
10494 (check_PROGRAMS): Add many_sections_test.
10495 (many_sections_test_SOURCES): Define.
10496 (many_sections_test_DEPENDENCIES): Define.
10497 (many_sections_test_LDFLAGS): Define.
10498 (BUILT_SOURCES): Add many_sections_define.h.
10499 (many_sections_define.h): New target.
10500 (BUILT_SOURCES): Add many_sections_check.h.
10501 (many_sections_check.h): New target.
10502 (check_PROGRAMS): Add many_sections_r_test.
10503 (many_sections_r_test_SOURCES): Define.
10504 (many_sections_r_test_DEPENDENCIES): Define.
10505 (many_sections_r_test_LDFLAGS): Define.
10506 (many_sections_r_test_LDADD): Define.
10507 (many_sections_r_test.o): New target.
10508 * testsuite/Makefile.in: Rebuild.
10512 * errors.cc (Errors::info): New function.
10513 (gold_info): New function.
10514 * errors.h (Errors::info): New function.
10515 * gold.h (gold_info): New function.
10516 * object.cc (Input_objects::add_object): Print trace output.
10517 * options.cc (options::parse_set): New function.
10518 (General_options::parse_wrap): Deleted.
10519 (General_options::General_options): Deleted initializer.
10520 * options.h (options::String_set): New typedef.
10521 (options::parse_set): New function.
10522 (DEFINE_set): New macro.
10523 (General_options::wrap): Changed to use DEFINE_set. Changed
10524 callers of any_wrap_symbols and is_wrap_symbol.
10525 (General_options::trace, General_options::trace_symbol):
10527 (General_options::any_wrap_symbols, General_options::is_wrap_symbol)
10528 (General_options::wrap_symbols_): Deleted.
10529 * symtab.cc (Symbol_table::add_from_object): Print trace output.
10533 * options.cc (General_options::parse_V): New function.
10534 * options.h: Add entries for -V and -Qy.
10538 * common.cc (Symbol_table::allocate_commons): Remove options
10539 parameter. Change caller.
10540 (Symbol_table::do_allocate_commons): Remove options parameter.
10541 Change caller. Just call do_allocate_commons_list twice.
10542 (Symbol_table::do_allocate_commons_list): New function, broken out
10543 of do_allocate_commons.
10544 * common.h (class Allocate_commons_task): Remove options_ field.
10545 Update constructor.
10546 * symtab.cc (Symbol_table::Symbol_table): Initialize
10548 (Symbol_table::add_from_object): Put TLS common symbols on
10550 (Symbol_table::sized_finalize_symbol): Handle STT_TLS symbols
10551 which are IN_OUTPUT_DATA.
10552 * symtab.h (class Symbol_table): Add tls_commons_ field. Update
10553 allocate_commons and do_allocate_commons declarations. Declare
10554 do_allocate_commons_list.
10555 * gold.cc (queue_middle_tasks): Update creation of
10556 Allocate_commons_task to not pass options.
10557 * testsuite/Makefile.am (INCLUDES): Add -I.. .
10558 (TLS_TEST_C_FLAGS): New variable.
10559 (tls_test_c_pic.o): New target.
10560 (tls_test_shared.so): Link in tls_test_c_pic.o.
10561 (tls_test_c_pic_ie.o): New target.
10562 (tls_test_ie_shared.so): Link in tls_test_c_pic_ie.o.
10563 (tls_test_DEPENDENCIES, tls_test_LDADD): Add tls_test_c.o.
10564 (tls_test_c.o): New target.
10565 (tls_pic_test_DEPENDENCIES): Add tls_test_c_pic.o.
10566 (tls_pic_test_LDADD): Likewise.
10567 (tls_shared_gd_to_ie_test_DEPENDENCIES): Add tls_test_c_pic.o.
10568 (tls_shared_gd_to_ie_test_LDADD): Likewise.
10569 (tls_test_c_gnu2.o): New target.
10570 (tls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): Add
10572 (tls_shared_gnu2_gd_to_ie_test_LDADD): Likewise.
10573 (tls_test_gnu2_shared.so): Link in tls_test_c_gnu2.o.
10574 (tls_test_shared_nonpic.so): Link in tls_test_c.o.
10575 * testsuite/tls_test.cc: Include "config.h".
10576 (t_last): Call t11_last.
10577 * testsuite/tls_test.h (t11, t11_last): Declare.
10578 * testsuite/tls_test_c.c: New file.
10579 * testsuite/tls_test_main.cc (thread_routine): Call t11.
10580 * configure.ac: Check for OpenMP support.
10581 * configure, config.in, Makefile.in: Rebuild.
10582 * testsuite/Makefile.in: Rebuild.
10586 * i386.cc (Target_i386::define_tls_base_symbol): New function.
10587 (Target_i386::tls_base_symbol_defined_): New field.
10588 (Target_i386::Scan::local): Define _TLS_MODULE_BASE_ symbol.
10589 (Target_i386::Scan::global): Likewise.
10590 * symtab.cc (sized_finalize_symbol): Add check for TLS symbol.
10591 * x86_64.cc (Target_x86_64::define_tls_base_symbol): New function.
10592 (Target_x86_64::tls_base_symbol_defined_): New field.
10593 (Target_x86_64::Scan::local): Define _TLS_MODULE_BASE_ symbol.
10594 (Target_x86_64::Scan::global): Likewise.
10598 * symtab.h (Symbol::is_strong_undefined): Removed unused function.
10599 (Symbol::needs_plt_entry): Allow weak undefined symbols.
10600 (Symbol::needs_dynamic_reloc): Allow weak undefined symbols when
10601 building shared libraries.
10602 * testsuite/Makefile.am (weak_undef_nonpic_test): New target.
10603 (weak_undef_file1_nonpic.o, weak_undef_file2_nonpic.o)
10604 (weak_undef_lib_nonpic.so, alt/weak_undef_lib_nonpic.so): New targets.
10605 * testsuite/Makefile.in: Rebuild.
10606 * testsuite/weak_undef.h: New file.
10607 * testsuite/weak_undef_file1.cc: Add extra test cases.
10608 * testsuite/weak_undef_file2.cc: Likewise.
10609 * testsuite/weak_undef_test.cc: Likewise.
10613 * sparc.cc (Target_sparc::Scan): Change from struct to class.
10614 Add issued_non_pic_error_ field. Declare check_non_pic.
10615 (Target_sparc::Scan::check_non_pic): New function.
10616 (Target_sparc::Scan::local): Call check_non_pic as appropriate.
10617 (Target_sparc::Scan::global): Likewise.
10619 * configure.ac (FN_PTRS_IN_SO_WITHOUT_PIC): Add sparc64.
10620 * configure: Rebuild.
10622 * options.h (DEFINE_enable): New macro.
10623 (new_dtags): New enable option.
10624 (initfirst, interpose, loadfltr, nodefaultlib,
10625 nodelete, nodlopen, nodump): New -z options.
10626 * layout.cc (Layout:finish_dynamic_section): If new
10627 dtags enabled, emit DT_RUNPATH. Also, emit a
10628 DT_FLAGS_1 containing any specified -z flags.
10632 * copy-relocs.cc: New file.
10633 * copy-relocs.h: New file.
10634 * reloc.cc: Remove Copy_relocs code.
10635 * reloc.h: Likewise.
10636 * reloc-types.h (struct Reloc_types) [both versions]: Add
10637 get_reloc_addend_noerror.
10638 * output.h (class Output_data_reloc<elfcpp::SHT_REL>): Add
10639 variants of add_global which take an addend which must be zero.
10640 * i386.cc: Include "copy-relocs.h".
10641 (class Target_i386): Change type of copy_relocs_ to variable,
10642 update initializer.
10643 (Target_i386::copy_reloc): Rewrite to pass to Copy_relocs class.
10644 Change all callers.
10645 (Target_i386::do_finalize_sections): Change handling of
10647 * sparc.cc: Include "copy-relocs.h".
10648 (class Target_sparc): Change type of copy_relocs_ to variable,
10649 update initializer.
10650 (Target_sparc::copy_reloc): Rewrite to pass to Copy_relocs class.
10651 Change all callers.
10652 (Target_sparc::do_finalize_sections): Change handling of
10654 * x86_64.cc: Include "copy-relocs.h".
10655 (class Target_x86_64): Change type of copy_relocs_ to variable,
10656 update initializer.
10657 (Target_x86_64::copy_reloc): Rewrite to pass to Copy_relocs
10658 class. Change all callers.
10659 (Target_x86_64::do_finalize_sections): Change handling of
10661 * Makefile.am (CCFILES): Add copy-relocs.cc.
10662 (HFILES): Add copy-relocs.h.
10664 * Makefile.in, aclocal.m4, testsuite/Makefile.in: Rebuild.
10666 * testsuite/script_test_4.sh: Permit leading zeroes.
10670 * script-sections.cc (Script_sections::create_segments): Use
10671 header_size_adjustment even when there is enough room for the
10673 * testsuite/script_test_4.sh: New file.
10674 * testsuite/script_test_4.t: New file.
10675 * testsuite/Makefile.am (check_SCRIPTS): Add script_test_4.sh.
10676 (check_DATA): Add script_test_4.stdout.
10677 (MOSTLYCLEANFILES): Likewise.
10678 (script_test_4): New target.
10679 (script_test_4.stdout): New target.
10680 * testsuite/Makefile.in: Rebuild.
10682 * sparc.cc: Add definitions for Output_data_plt_sparc class
10687 * sparc.cc: New file.
10688 * Makefile.am (TARGETSOURCES): Add sparc.cc
10689 (ALL_TARGETOBJS): Add sparc.$(OBJEXT)
10690 * configure.tgt: Document targ_extra_size and
10691 targ_extra_big_endian. Add entries for sparc-* and
10693 * configure.ac: Handle targ_extra_size and
10694 targ_extra_big_endian.
10695 * Makefile.in: Rebuild.
10696 * configure: Likewise.
10697 * po/POTFILES.in: Likewise.
10698 * po/gold.pot: Likewise.
10702 * layout.cc (Layout::Layout): Initialize sections_are_attached_.
10703 (Layout::get_output_section): Ignore SHF_WRITE and SHF_EXECINSTR
10704 in the name/type/flags to section mapping. Don't call
10705 allocate_output_section.
10706 (Layout::choose_output_section): Change parameter from adjust_name
10707 to is_input_section. Don't permit input sections after sections
10708 are attached to segments. Don't call allocate_output_section.
10709 (Layout::layout_eh_frame): Call update_flags_for_input_section,
10710 not write_enable_output_section.
10711 (Layout::make_output_section): Don't push to
10712 unattached_section_list_ nor call attach_to_segment. Call
10713 attach_section_to_segment if sections are attached.
10714 (Layout::attach_sections_to_segments): New function.
10715 (Layout::attach_section_to_segment): New function.
10716 (Layout::attach_allocated_section_to_segment): Rename from
10717 attach_to_segment. Remove flags parameter.
10718 (Layout::allocate_output_section): Remove function.
10719 (Layout::write_enable_output_section): Remove function.
10720 * layout.h (class Layout): Update for above changes. Add new
10721 field sections_are_attached_.
10722 * output.h (Output_section::update_flags_for_input_section): New
10724 * output.cc (Output_section::add_input_section): Call
10725 update_flags_for_input_section.
10726 * gold.cc (queue_middle_tasks): Call attach_sections_to_segments.
10730 * i386.cc (Target_i386::got_mod_index_entry): Restore code previously
10731 thought unnecessary.
10732 * x86_64.cc (Target_x86_64::got_mod_index_entry): Likewise.
10736 * output.h (class Output_section_data): Remove inline definition
10738 * output.cc (Output_section_data::set_addralign): New function.
10742 Add support for TLS descriptors for i386 and x86_64.
10743 * i386.cc (Target_i386::Relocate::tls_desc_gd_to_ie): New function.
10744 (Target_i386::Relocate::tls_desc_gd_to_le): New function.
10745 (Target_i386::Got_type): Add GOT_TYPE_TLS_NOFFSET and
10747 (Target_i386::got_mod_index_entry): Remove unnecessary code.
10748 (Target_i386::Scan::local): Implement R_386_TLS_GOTDESC and
10749 R_386_TLS_DESC_CALL relocations. Fix problem with initial-exec
10751 (Target_i386::Scan::global): Fix problem with GD-to-IE relaxation.
10752 Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations;
10753 Fix problem with initial-exec relocations.
10754 (Target_i386::Relocate::relocate_tls): Likewise.
10755 (Target_i386::Relocate::tls_gd_to_ie): Fix problem with GD-to-IE
10757 * output.cc (Output_data_dynamic::Dynamic_entry::write): Add
10758 support for section-plus-offset dynamic table entries.
10759 * output.h (Output_data_dynamic::add_section_plus_offset): New function.
10760 (Output_data_dynamic::Dynamic_entry): Add support for
10761 section-plus-offset dynamic table entries.
10762 (Output_data_dynamic::Classification): Likewise.
10763 (Output_data_dynamic::classification_): Renamed offset_.
10764 * x86_64.cc (Target_x86_64::Relocate::tls_desc_gd_to_ie): New function.
10765 (Target_x86_64::Relocate::tls_desc_gd_to_le): New function.
10766 (Target_x86_64::make_plt_section): New function.
10767 (Target_x86_64::reserve_tlsdesc_entries): New function.
10768 (Output_data_plt_x86_64::Output_data_plt_x86_64): Add new parameter.
10769 (Output_data_plt_x86_64::reserve_tlsdesc_entry): New function.
10770 (Output_data_plt_x86_64::has_tlsdesc_entry): New function.
10771 (Output_data_plt_x86_64::get_tlsdesc_got_offset): New function.
10772 (Output_data_plt_x86_64::get_tlsdesc_plt_offset): New function.
10773 (Output_data_plt_x86_64::tlsdesc_plt_entry): New field.
10774 (Output_data_plt_x86_64::set_final_data_size): Move out of line;
10775 add extra PLT entry for TLS descriptors.
10776 (Output_data_plt_x86_64::got_): New field.
10777 (Output_data_plt_x86_64::tlsdesc_got_offset_): New field.
10778 (Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize new
10780 (Output_data_plt_x86_64::do_write): Write extra PLT entry for TLS
10782 (Target_x86_64::make_plt_entry): Factor out make_plt_section.
10783 (Target_x86_64::got_mod_index_entry): Remove unnecessary code.
10784 (Target_x86_64::Scan::local): Implement R_386_TLS_GOTDESC and
10785 R_386_TLS_DESC_CALL relocations.
10786 (Target_x86_64::Scan::global): Likewise.
10787 (Target_x86_64::do_finalize_sections): Add dynamic table entries
10788 for TLS descriptors.
10789 (Relocate::relocate_tls): Fix problem with GD-to-IE relaxation.
10790 Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations.
10791 (Target_x86_64::Relocate::tls_gd_to_ie): Fix problem with
10792 GD-to-IE relaxation.
10793 * configure.ac: Export new conditional variables TLS_GNU2_DIALECT
10794 and TLS_DESCRIPTORS.
10795 * Makefile.in: Rebuild.
10796 * configure: Rebuild.
10797 * testsuite/Makefile.am (tls_shared_gd_to_ie_test): New target.
10798 (tls_test_shared2.so): New target.
10799 (tls_shared_gd_to_ie_test_SOURCES): New variable.
10800 (tls_shared_gd_to_ie_test_DEPENDENCIES): New variable.
10801 (tls_shared_gd_to_ie_test_LDFLAGS): New variable.
10802 (tls_shared_gd_to_ie_test_LDADD): New variable.
10803 (tls_shared_gnu2_gd_to_ie_test): New target.
10804 (tls_test_gnu2.o, tls_test_file2_gnu2.o, tls_test_gnu2_shared2.so):
10806 (tls_shared_gnu2_gd_to_ie_test_SOURCES): New variable.
10807 (ls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): New variable.
10808 (tls_shared_gnu2_gd_to_ie_test_LDFLAGS): New variable.
10809 (tls_shared_gnu2_gd_to_ie_test_LDADD): New variable.
10810 (tls_shared_gnu2_test): New target.
10811 (tls_test_gnu2_shared.so): New target.
10812 (tls_shared_gnu2_test_SOURCES): New variable.
10813 (tls_shared_gnu2_test_DEPENDENCIES): New variable.
10814 (tls_shared_gnu2_test_LDFLAGS): New variable.
10815 (tls_shared_gnu2_test_LDADD): New variable.
10816 * testsuite/Makefile.in: Rebuild.
10817 * testsuite/Makefile.
10821 * testsuite/Makefile.am (justsyms_2r.o): Add dependency on
10823 * testsuite/Makefile.in: Rebuild.
10825 * testsuite/script_test_2a.cc (script_test_string_a): Make 8 bytes
10827 * testsuite/script_test_2.cc (main): Adjust test.
10832 * options.h (General_options): Add entries for '-Y' and
10834 * options.cc (General_options:finalize): If -Y was used, add those
10835 entries to the library path instead of the default "/lib" and
10840 * testsuite/justsyms.t: Start at 0x100.
10841 * testsuite/justsyms_1.cc: Adjust justsyms_string assertion.
10842 * testsuite/script_test_2b.cc (script_test_string_b): Make 8 bytes
10844 * testsuite/script_test_2.cc: Adjust string and section length
10850 * script-sections.cc (Sections_element::allocate_to_segment): Add
10852 (Output_section_definition::allocate_to_segment): Likewise.
10853 (Orphan_output_section::allocate_to_segment): Likewise.
10854 (Script_sections::attach_sections_using_phdrs_clause): Don't
10855 propagate non-PT_LOAD segments to orphan sections.
10856 * testsuite/Makefile.am (script_test_3.stdout): Generate using
10857 readelf rather than objdump.
10858 * testsuite/script_test_3.sh: Adjust accordingly. Test that
10859 .interp section and PT_INTERP segment are the same size.
10860 * testsuite/Makefile.in: Rebuild.
10862 * symtab.cc (Symbol_table::add_from_dynobj): Only look for weak
10863 aliases for symbols defined in the same object.
10864 * testsuite/Makefile.am (check_PROGRAMS): Add weak_alias_test.
10865 (weak_alias_test_SOURCES): New variable.
10866 (weak_alias_test_DEPENDENCIES): New variable.
10867 (weak_alias_test_LDFLAGS): New variable.
10868 (weak_alias_test_LDADD): New variable.
10869 (weak_alias_test_1_pic.o, weak_alias_test_1.so): New targets.
10870 (weak_alias_test_2_pic.o, weak_alias_test_2.so): New targets.
10871 (weak_alias_test_3.o): New target.
10872 (weak_alias_test_4_pic.o, weak_alias_test_4.so): New targets.
10873 * testsuite/weak_alias_test_main.cc: New file.
10874 * testsuite/weak_alias_test_1.cc: New file.
10875 * testsuite/weak_alias_test_2.cc: New file.
10876 * testsuite/weak_alias_test_3.cc: New file.
10880 * options.h (class General_options): Add --noinhibit-exec option.
10881 * main.cc (main): Check --noinhibit-exec.
10883 * options.h (class General_options): Define --wrap as a special
10884 option. Add wrap_symbols_ field.
10885 (General_options::any_wrap_symbols): New function.
10886 (General_options::is_wrap_symbol): New function.
10887 * options.cc (General_options::parse_wrap): New function.
10888 (General_options::General_options): Initialize wrap_symbols_.
10889 * symtab.cc (Symbol_table::wrap_symbol): New function.
10890 (Symbol_table::add_from_object): Handle --wrap.
10891 * symtab.h (class Symbol_table): Declare wrap_symbol.
10892 * target.h (Target::wrap_char): New function.
10893 (Target::Target_info): Add wrap_char field.
10894 * i386.cc (Target_i386::i386_info): Initialize wrap_char.
10895 * x86_64.cc (Target_x86_64::x86_64_info): Likewise.
10896 * testsuite/testfile.cc (Target_test::test_target_info):
10899 * errors.cc (Errors::undefined_symbol): Mention symbol version if
10902 * layout.h (class Layout): Add added_eh_frame_data_ field.
10903 * layout.cc (Layout::Layout): Initialize new field.
10904 (Layout::layout_eh_frame): Don't add eh_frame_data_ to .eh_frame
10905 output section until we find a section we merged successfully.
10906 * object.cc (Sized_relobj::check_eh_frame_flags): Don't require
10907 that the size be non-zero.
10909 * merge.cc (Object_merge_map::get_output_offset): Remove inline
10914 * configure.ac: Export new conditional variable HAVE_ZLIB.
10915 * testsuite/Makefile.am (flagstest_o_specialfile): Condition
10917 (flagstest_o_specialfile_and_compress_debug_sections): Likewise.
10918 * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
10922 * version.cc (version_string): Set to "1.5".
10924 * x86_64.cc (Target_x86_64::Scan): Change from struct to class.
10925 Add issued_non_pic_error_ field. Declare check_non_pic.
10926 (Target_x86_64::Scan::check_non_pic): New function.
10927 (Target_x86_64::Scan::local): Call check_non_pic as appropriate.
10928 (Target_x86_64::Scan::global): Likewise.
10930 * output.cc (Output_reloc<SHT_REL>::local_section_offset): Add
10931 addend parameter. Change caller. Handle merge sections.
10932 (Output_reloc<SHT_REL>::symbol_value): Change parameter type from
10933 Address to Addend. Don't add in the result of
10934 local_section_offset, pass down the addend and use the returned
10936 * output.h (class Output_reloc<SHT_REL>): Add Addend typedef.
10937 Update declarations of local_section_offset and symbol_value.
10938 * testsuite/two_file_test_1.cc (t18): New function.
10939 * testsuite/two_file_test_2.cc (f18): New function.
10940 * testsuite/two_file_test_main.cc (main): Call t18.
10941 * testsuite/two_file_test.h (t18, f18): Declare.
10943 * configure.ac: Don't test for objdump, c++filt, or readelf.
10944 * testsuite/Makefile.am: Remove READELF and OBJDUMP_AND_CPPFILT
10946 (TEST_READELF): New variable.
10947 (TEST_OBJDUMP, TEST_CXXFILT, TEST_STRIP): New variables.
10948 (check_PROGRAMS): Add two_file_strip_test.
10949 (two_file_strip_test): New target.
10950 (check_PROGRAMS): Add two_file_same_shared_strip_test.
10951 (two_file_same_shared_strip_test_SOURCES): New variable.
10952 (two_file_same_shared_strip_test_DEPENDENCIES): New variable.
10953 (two_file_same_shared_strip_test_LDFLAGS): New variable.
10954 (two_file_same_shared_strip_test_LDADD): New variable.
10955 (two_file_shared_strip.so): New target.
10956 (ver_test_2.syms, ver_test_4.syms): Use TEST_READELF.
10957 (ver_test_5.syms, ver_test_7.syms): Likewise.
10958 (ver_matching_test.stdout): Use TEST_OBJDUMP and TEST_CXXFILT.
10959 (strip_test_3.stdout): Use TEST_OBJDUMP.
10960 * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
10964 * symtab.h (Symbol::is_weak_undefined): New function.
10965 (Symbol::is_strong_undefined): New function.
10966 (Symbol::is_absolute): New function.
10967 (Symbol::needs_plt_entry): Exclude weak undefined symbols.
10968 (Symbol::needs_dynamic_reloc): Exclude weak undefined and
10970 * testsuite/Makefile.am (check_PROGRAMS): Add weak_undef_test.
10971 (weak_undef_test): New target.
10972 * testsuite/Makefile.in: Rebuild.
10973 * testsuite/weak_undef_file1.cc: New file.
10974 * testsuite/weak_undef_file2.cc: New file.
10975 * testsuite/weak_undef_test.cc: New file.
10979 * compressed_output.h (class Output_compressed_section): Use
10981 * compressed_output.cc (zlib_compress): Use unsigned buffers,
10983 (zlib_compressed_suffix): Removed.
10984 (Output_compressed_section::set_final_data_size): Use unsigned
10986 * testsuite/Makefile.am (flagstest_compress_debug_sections):
10987 Fix linker invocation.
10988 (flagstest_o_specialfile_and_compress_debug_sections):
10990 * testsuite/Makefile.in: Regenerated.
10994 * dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog,
10995 Sized_dwarf_line_info::process_one_opcode): Use Swap_unaligned.
11003 * fileread.cc (File_read::find_view): Add byteshift and vshifted
11004 parameters. Update for new key type to views_. Change all
11006 (File_read::read): Adjust for byteshift in returned view.
11007 (File_read::add_view): New function, broken out of
11008 find_and_make_view.
11009 (File_read::make_view): New function, broken out of
11010 find_and_make_view.
11011 (File_read::find_or_make_view): Add offset and aligned
11012 parameters. Rewrite accordingly. Change all callers.
11013 (File_read::get_view): Add offset and aligned parameters. Adjust
11014 for byteshift in return value.
11015 (File_read::get_lasting_view): Likewise.
11016 * fileread.h (class File_read): Update declarations.
11017 (class File_read::View): Add byteshift_ field. Add byteshift to
11018 constructor. Add byteshift method.
11019 * archive.h (Archive::clear_uncached_views): New function.
11020 (Archive::get_view): Add aligned parameter. Change all callers.
11021 * object.h (Object::get_view): Add aligned parameter. Change all
11023 (Object::get_lasting_view): Likewise.
11025 * fileread.cc (File_read::release): Don't call clear_views if
11026 there are multiple objects.
11027 * fileread.h (File_read::clear_uncached_views): New function.
11028 * archive.cc (Add_archive_symbols::run): Call clear_uncached_views
11033 Add thin archive support.
11034 * archive.cc (Archive::armagt): New const.
11035 (Archive::setup): Remove task parameter and calls to unlock.
11036 (Archive::unlock_nested_archives): New function.
11037 (Archive::read_header): Add nested_off parameter. Change
11039 (Archive::interpret_header): Likewise.
11040 (Archive::include_all_members): Change to handle thin
11042 (Archive::include_member): Likewise.
11043 * archive.h (Archive::Archive): Add new parameters and
11045 (Archive::armagt): New const.
11046 (Archive::setup): Remove task parameter.
11047 (Archive::unlock_nested_archives): New function.
11048 (Archive::read_header): Add nested_off parameter.
11049 (Archive::interpret_header): Likewise.
11050 (Archive::Nested_archive_table): New typedef.
11051 (Archive::is_thin_archive_): New field.
11052 (Archive::nested_archives_): New field.
11053 (Archive::options_): New field.
11054 (Archive::dirpath_): New field.
11055 (Archive::task_): New field.
11056 * readsyms.cc (Read_symbols::do_read_symbols): Add check
11057 for thin archives. Pass additional parameters to
11058 Archive::Archive. Unlock the archive file after calling
11063 * symtab.cc (Symbol_table::do_define_as_constant): Don't force a
11064 version symbol to be local.
11065 * testsuite/ver_test_4.sh: New file.
11066 * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_4.sh.
11067 (check_DATA): Add ver_test_4.syms.
11068 (ver_test_4.syms): New target.
11069 * testsuite/Makefile.in: Rebuild.
11072 (Output_section::Input_section_sort_entry::has_priority): New
11074 (Output_section::Input_section_sort_entry::match_file_name): New
11076 (Output_section::Input_section_sort_entry::match_section_name):
11078 (Output_section::Input_section_sort_entry::match_section_name_prefix):
11080 (Output_section::Input_section_sort_entry::match_section_file):
11082 (Output_section::Input_section_sort_compare::operator()): Rewrite
11083 using new Input_section_sort_entry functions. Sort crtbegin and
11084 crtend first. Sort sections with no priority before sections with
11086 * testsuite/initpri1.c (d3): Check j != 4.
11087 (cd5): New constructor/destructor function.
11088 (main): Check j != 2.
11090 * symtab.cc (Symbol_table::add_from_object): If we don't use the
11091 new symbol when resolving, don't call set_is_default.
11092 * testsuite/ver_test_7.cc: New file.
11093 * testsuite/ver_test_7.sh: New file.
11094 * testsuite/Makefile.am (ver_test_7.so): New target.
11095 (ver_test_7.o): New target.
11096 (check_SCRIPTS): Add ver_test_7.sh.
11097 (check_DATA): Add ver_test_7.syms.
11098 (ver_test_7.syms): New target.
11102 * layout.cc (Layout::layout): If we see an input section with a
11103 name that needs sorting, set the must_sort flag for the output
11105 (Layout::make_output_section): If the name of the output section
11106 indicates that it might require sorting, set the may_sort flag.
11107 * output.h (Output_section::may_sort_attached_input_sections): New
11109 (Output_section::set_may_sort_attached_input_sections): New
11111 (Output_section::must_sort_attached_input_sections): New
11113 (Output_section::set_must_sort_attached_input_sections): New
11115 (class Output_section): Declare Input_section_sort_entry. Define
11116 Input_section_sort_compare. Declare
11117 sort_attached_input_sections. Add new fields:
11118 may_sort_attached_input_sections_,
11119 must_sort_attached_input_sections_,
11120 attached_input_sections_are_sorted_.
11121 * output.cc (Output_section::Output_section): Initialize new
11123 (Output_section::add_input_section): Add an entry to
11124 input_sections_ if may_sort or must_sort are true.
11125 (Output_section::set_final_data_size): Call
11126 sort_attached_input_sections if necessary.
11127 (Output_section::Input_section_sort_entry): Define new class.
11128 (Output_section::Input_section_sort_compare::operator()): New
11130 (Output_section::sort_attached_input_sections): New function.
11131 * configure.ac: Check whether the compiler supports constructor
11132 priorities. Define a CONSTRUCTOR_PRIORITY automake conditional.
11133 * testsuite/initpri1.c: New file.
11134 * testsuite/Makefile.am (check_PROGRAMS): Add initpri1 if
11135 CONSTRUCTOR_PRIORITY.
11136 (initpri1_SOURCES, initpri1_DEPENDENCIES): New variables.
11137 (initpri1_LDFLAGS): New variable.
11138 * configure, Makefile.in, testsuite/Makefile.in: Rebuild.
11142 * common.cc (Sort_commons::operator): Correct sorting algorithm.
11143 * testsuite/common_test_1.c: New file.
11144 * testsuite/Makefile.am (check_PROGRAMS): Add common_test_1.
11145 (common_test_1_SOURCES): New variable.
11146 (common_test_1_DEPENDENCIES): New variable.
11147 (common_test_1_LDFLAGS): New variable.
11149 * symtab.cc (Symbol_table::add_from_object): Handle saw_undefined_
11150 and commons_ correctly when NAME/VERSION does not override
11152 * testsuite/ver_test_6.c: New file.
11153 * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_6
11154 (ver_test_6_SOURCES, ver_test_6_DEPENDENCIES): New variables.
11155 (ver_test_6_LDFLAGS, ver_test_6_LDADD): New variables.
11159 * symtab.cc (Symbol_table::add_from_relobj): Don't set the version
11160 of an undefined symbol from a version script.
11161 * testsuite/Makefile.am (ver_test_5.so): New target.
11162 (ver_test_5.o): New target.
11163 (check_SCRIPTS): Add ver_test_5.sh.
11164 (check_DATA): Add ver_test_5.syms.
11165 (ver_test_5.syms): New target.
11166 * testsuite/ver_test_5.cc: New file.
11167 * testsuite/ver_test_5.script: New file.
11168 * testsuite/ver_test_5.sh: New file.
11169 * Makefile.in, testsuite/Makefile.in: Rebuild.
11172 Fix problems building gold with gcc 4.3.0.
11173 * gold.h (TEMPLATE_ATTRIBUTE_PRINTF_4): Define.
11174 (gold_error_at_location, gold_warning_at_location): Use it.
11175 * configure.ac: Check whether we can compile and use a template
11176 function with a printf attribute.
11177 * x86_64.cc (Target_x86_64::do_code_fill): Swap out a 32-bit value
11178 when jumping over bytes.
11179 * object.cc: Instantiate Object::read_section_data.
11180 * debug.h: Include <cstring>
11181 * dwarf_reader.cc: Include <algorithm>
11182 * main.cc: Include <cstring>.
11183 * options.cc: Include <cstring>.
11184 * output.cc: Include <cstring>.
11185 * script.cc: Include <cstring>.
11186 * script.h: Include <string>.
11187 * symtab.cc: Include <cstring> and <algorithm>.
11188 * target-select.cc: Include <cstring>.
11189 * version.cc: Include <string>.
11190 * testsuite/testmain.cc: Include <cstdlib>.
11191 * configure, config.in: Rebuild.
11195 * options.cc: Include "../bfd/bfdver.h".
11196 (options::help): Print bug reporting address.
11198 * version.cc (print_version): Adjust output for current value of
11199 BFD_VERSION_STRING.
11203 * options.cc (options::help): Print list of supported targets.
11204 * target-select.h: Include <vector>.
11205 (class Target_selector): Make machine_, size_, and is_big_endian_
11206 fields const. Add bfd_name_ and instantiated_target_ fields.
11207 (Target_selector::Target_selector): Add bfd_name parameter.
11208 (Target_selector::recognize): Make non-virtual, call
11210 (Target_selector::recognize_by_name): Make non-virtual, call
11211 do_recognize_by_name.
11212 (Target_selector::supported_names): New function.
11213 (Target_selector::bfd_name): New function.
11214 (Target_selector::do_instantiate_target): New pure virtual
11216 (Target_selector::do_recognize): New virtual function.
11217 (Target_selector::do_recognize_by_name): New virtual function.
11218 (Target_selector::instantiate_target): New private function.
11219 (supported_target_names): Declare.
11220 * target-select.cc (Target_selector::Target_selector): Update for
11221 new parameter and fields.
11222 (select_target_by_name): Check that the name matches before
11223 calling recognize_by_name.
11224 (supported_target_names): New function.
11225 * i386.cc (class Target_selector_i386): Update Target_selector
11226 constructor call. Remove recognize and recognize_by_name. Add
11227 do_instantiate_target.
11228 * x86_64.cc (class Target_selector_x86_64): Likewise.
11229 * testsuite/testfile.cc (class Target_selector_test): Update for
11230 changes to Target_selector.
11232 * README: Rewrite, with some notes on unsupported features.
11236 * i386.cc (Target_i386::Got_type): New enum declaration.
11237 (Target_i386::Scan::local): Updated callers of Output_data_got
11239 (Target_i386::Scan::global): Likewise.
11240 (Target_i386::Relocate::relocate): Likewise.
11241 (Target_i386::Relocate::relocate_tls): Likewise.
11242 * object.h (Got_offset_list): New class.
11243 (Sized_relobj::local_has_got_offset): Added got_type parameter.
11244 (Sized_relobj::local_got_offset): Likewise.
11245 (Sized_relobj::set_local_got_offset): Likewise.
11246 (Sized_relobj::local_has_tls_got_offset): Removed.
11247 (Sized_relobj::local_tls_got_offset): Removed.
11248 (Sized_relobj::set_local_tls_got_offset): Removed.
11249 (Sized_relobj::Local_got_offsets): Changed to store a list of offsets.
11250 * output.cc (Output_data_got::add_global): Added got_type parameter.
11251 (Output_data_got::add_global_with_rel): Likewise.
11252 (Output_data_got::add_global_with_rela): Likewise.
11253 (Output_data_got::add_global_pair_with_rel): New function.
11254 (Output_data_got::add_global_pair_with_rela): New function.
11255 (Output_data_got::add_local): Added got_type parameter.
11256 (Output_data_got::add_local_with_rel): Likewise.
11257 (Output_data_got::add_local_with_rela): Likewise.
11258 (Output_data_got::add_local_pair_with_rel): New function.
11259 (Output_data_got::add_local_pair_with_rela): New function.
11260 (Output_data_got::add_global_tls): Removed.
11261 (Output_data_got::add_global_tls_with_rel): Removed.
11262 (Output_data_got::add_global_tls_with_rela): Removed.
11263 (Output_data_got::add_local_tls): Removed.
11264 (Output_data_got::add_local_tls_with_rel): Removed.
11265 (Output_data_got::add_local_tls_with_rela): Removed.
11266 * output.h (Output_data_got::add_global): Added got_type parameter.
11267 (Output_data_got::add_global_with_rel): Likewise.
11268 (Output_data_got::add_global_with_rela): Likewise.
11269 (Output_data_got::add_global_pair_with_rel): New function.
11270 (Output_data_got::add_global_pair_with_rela): New function.
11271 (Output_data_got::add_local): Added got_type parameter.
11272 (Output_data_got::add_local_with_rel): Likewise.
11273 (Output_data_got::add_local_with_rela): Likewise.
11274 (Output_data_got::add_local_pair_with_rel): New function.
11275 (Output_data_got::add_local_pair_with_rela): New function.
11276 (Output_data_got::add_global_tls): Removed.
11277 (Output_data_got::add_global_tls_with_rel): Removed.
11278 (Output_data_got::add_global_tls_with_rela): Removed.
11279 (Output_data_got::add_local_tls): Removed.
11280 (Output_data_got::add_local_tls_with_rel): Removed.
11281 (Output_data_got::add_local_tls_with_rela): Removed.
11282 * resolve.cc (Symbol::override_base_with_special): Removed
11283 reference to has_got_offset_ field.
11284 * symtab.cc (Symbol::init_fields): Replaced initialization
11285 of got_offset_ with got_offsets_. Removed initialization
11287 * symtab.h (Symbol::has_got_offset): Aded got_type parameter.
11288 (Symbol::got_offset): Likewise.
11289 (Symbol::set_got_offset): Likewise.
11290 (Symbol::has_tls_got_offset): Removed.
11291 (Symbol::tls_got_offset): Removed.
11292 (Symbol::set_tls_got_offset): Removed.
11293 (Symbol::got_offset_): Removed.
11294 (Symbol::tls_mod_got_offset_): Removed.
11295 (Symbol::tls_pair_got_offset_): Removed.
11296 (Symbol::got_offsets_): New field.
11297 (Symbol::has_got_offset): Removed.
11298 (Symbol::has_tls_mod_got_offset): Removed.
11299 (Symbol::has_tls_pair_got_offset): Removed.
11300 * x86_64.cc (Target_x86_64::Got_type): New enum declaration.
11301 (Target_x86_64::Scan::local): Updated callers of Output_data_got
11303 (Target_x86_64::Scan::global): Likewise.
11304 (Target_x86_64::Relocate::relocate): Likewise.
11305 (Target_x86_64::Relocate::relocate_tls): Likewise.
11309 * yyscript.y: Fix spelling error in comment.
11313 * options.h (class General_options): Define build_id option.
11314 * layout.h (class Layout): Declare write_build_id, create_note,
11315 create_build_id. Add build_id_note_ member.
11316 * layout.cc: Include <cerrno>, <fcntl.h>, <unistd.h>,
11317 "libiberty.h", "md5.h", "sha1.h".
11318 (Layout::Layout): Initialize eh_frame_data_,
11319 eh_frame_hdr_section_, and build_id_note_.
11320 (Layout::finalize): Call create_build_id.
11321 (Layout::create_note): New function, broken out of
11322 Layout::create_gold_note.
11323 (Layout::create_gold_note): Call create_note.
11324 (Layout::create_build_id): New function.
11325 (Layout::write_build_id): New function.
11326 (Close_task_runner::run): Call write_build_id.
11328 * x86_64.cc: Correct license to GPLv3.
11332 * options.cc: Include "demangle.h".
11333 (parse_optional_string): New function.
11334 (parse_long_option): Handle takes_optional_argument.
11335 (parse_short_option): Update dash_z initializer. Handle
11336 takes_optional_argument.
11337 (General_options::General_options): Initialize do_demangle_.
11338 (General_options::finalize): Set do_demangle_. Handle demangling
11340 * options.h (parse_optional_string): Declare.
11341 (struct One_option): Add optional_arg field. Update constructor.
11342 Update call constructor calls. Add takes_optional_argument
11344 (DEFINE_var): Add optional_arg__ parameter. Change all callers.
11345 (DEFINE_optional_string): Define.
11346 (General_options::demangle): Change from DEFINE_bool to
11347 DEFINE_optional_string.
11348 (General_options::no_demangle): New function.
11349 (General_options::do_demangle): New function.
11350 (General_options::set_do_demangle): New function.
11351 (General_options::execstack_status_): Move definition to end of
11353 (General_options::static_): Likewise.
11354 (General_options::do_demangle_): New field.
11355 * object.cc (big_endian>::get_symbol_location_info): Call
11356 Options::do_demangle, not Options::demangle.
11357 * symtab.cc (demangle): Likewise.
11361 * gold.h: Include <cstddef> and <sys/types.h>
11362 * options.h: Include <cstring>.
11366 * Added source code to GNU binutils.