diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-12-09 17:57:18 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2014-12-09 19:50:14 +0800 |
commit | 5e8c1cf25beccac1d22d10dc866912394f42771b (patch) | |
tree | ee16b70f804484dc8e434e647e699ab50da2620f /binutils-2.25/gold | |
parent | 8eebd7953384e6662ca926b003f2cdda8ccd3ee5 (diff) | |
download | toolchain_binutils-5e8c1cf25beccac1d22d10dc866912394f42771b.zip toolchain_binutils-5e8c1cf25beccac1d22d10dc866912394f42771b.tar.gz toolchain_binutils-5e8c1cf25beccac1d22d10dc866912394f42771b.tar.bz2 |
[2.25] sync to a30720e3e633f275250e26f85ccae5dbdddfb6c6
local patches will be re-applied later
commit a30720e3e633f275250e26f85ccae5dbdddfb6c6
Author: Alan Modra <amodra@gmail.com>
Date: Wed Nov 19 10:30:16 2014 +1030
daily update
Change-Id: Ieb2a3f4dd2ecb289ac5305ff08d428b2847494ab
Diffstat (limited to 'binutils-2.25/gold')
401 files changed, 22389 insertions, 2407 deletions
diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog index 2d16bbc..88dd58f 100644 --- a/binutils-2.25/gold/ChangeLog +++ b/binutils-2.25/gold/ChangeLog @@ -1,3 +1,957 @@ +2014-10-28 Alan Modra <amodra@gmail.com> + + Apply trunk patches + 2014-10-22 Alan Modra <amodra@gmail.com> + * powerpc.cc (do_relax): Add gcc-4.9 libgomp functions to + thread_starter. + +2014-09-30 Cary Coutant <ccoutant@google.com> + + PR gold/17432 + * resolve.cc (Symbol_table::resolve): Fix local shadowing error. + +2014-09-30 Kito Cheng <kito@0xlab.org> + + PR gold/13597 + * layout.cc (Layout::create_dynamic_symtab): Build gnu-style + hash table before sysv-style hash table. + +2014-09-29 Sriraman Tallam <tmsriram@google.com> + + * options.h (--pic-executable): Add negative to alias to -no-pie. + +2014-09-26 Cary Coutant <ccoutant@google.com> + + PR gold/16773 + * object.cc (Sized_relobj_file): Compute value of section symbols + for TLS sections the same as TLS symbols. + +2014-09-25 Cary Coutant <ccoutant@google.com> + + PR gold/17432 + * resolve.cc (Symbol_table::resolve): Override common placeholder + symbols, but adjust sizes. + * symtab.cc (Symbol_table::add_from_object): Don't add placeholder + symbols to common lists. + +2014-09-24 Alan Modra <amodra@gmail.com> + + * po/POTFILES.in: Regenerate. + +2014-09-23 Taiju Tsuiki <tzik@google.com> + Cary Coutant <ccoutant@google.com> + + PR gold/14860 + * gold.cc (queue_final_tasks): Add Write_sections_task as a blocker + on input_sections_blocker. + * layout.cc (Write_sections_task::locks): Unblock + input_sections_blocker_. + * layout.h (Write_sections_task::Write_sections_task): Add + input_sections_blocker. + * testsuite/Makefile.am (exception_x86_64_bnd_test): Add gcctestdir/ld + to DEPENDENCIES. + * testsuite/Makefile.in: Regenerate. + +2014-09-18 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> + + * testsuite/Makefile.am (plugin_test_10): New test. + * testsuite/Makefile.in: Regenerate + * testsuite/plugin_common_test_2.c (c1): Align to 8. + * testsuite/plugin_test_10.sh: New file. + +2014-09-17 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> + + * plugin.cc (Sized_pluginobj::do_add_symbols): Ignore isym->size. + * resolve.cc (Symbol_table::resolve): Don't override common symbols + during the replacement phase. + +2014-09-17 Han Shen <shenhan@google.com> + Jing Yu <jingyu@google.com> + + * aarch64-reloc.def: Add TLSGD_ADR_PAGE21, TLSGD_ADD_LO12_NC, + TLSDESC_ADR_PAGE21, TLSDESC_LD64_LO12, TLSDESC_ADD_LO12, TLSDESC_CALL. + * aarch64.cc (Target_aarch64): Add data members + got_irelative_, got_tlsdesc_, rela_irelative_, got_mod_index_offset_, + tlsdesc_reloc_info_, tls_base_symbol_defined_. Initialize them in + constructor. + (Target_aarch64::do_reloc_symbol_index): New method. + (Target_aarch64::do_reloc_addend): New method. + (Target_aarch64::add_tlsdesc_info): New method. + (Target_aarch64::do_dynsym_value): New method. + (Target_aarch64::do_make_data_plt): Add new parameters: got, + got_irelative. Pass them to Output_data_plt_aarch64_standard. + (Target_aarch64::make_data_plt): Add new parameters: got, + got_irelative. Pass them to do_make_data_plt. + (Target_aarch64::Relocate): Add skip_call_tls_get_addr_ variable. + (Target_aarch64::Relocate:tls_gd_to_le): New method. + (Target_aarch64::Relocate:tls_ie_to_le): New method. + (Target_aarch64::Relocate:tls_desc_gd_to_le): New method. + (Target_aarch64::Relocate:tls_desc_gd_to_ie): New method. + (Target_aarch64::got_tlsdesc_section): New method. + (Target_aarch64::make_local_ifunc_plt_entry): New method. + (Target_aarch64::define_tls_base_symbol): New method. + (Target_aarch64::reserve_tlsdesc_entries): New method. + (Target_aarch64::got_mod_index_entry): New method. + (Target_aarch64::rela_tlsdesc_section): New method. + (Target_aarch64::rela_irelative_section): New method. + (Target_aarch64::Tlsdesc_info): New struct. + (Target_aarch64::got_section): Create .got.plt space for IRELATIVE + relocations and tlsdesc relocations. + (Target_aarch64::optimize_tls_reloc): Implement method. + (Output_data_plt_aarch64): Add member variables: tlsdesc_rel_, got_, + got_irelative_, irelative_count_, tlsdesc_got_offset_. Initialize them + in constructor. + (Output_data_plt_aarch64::reserve_tlsdesc_entry): New method. + (Output_data_plt_aarch64::has_tlsdesc_entry): New method. + (Output_data_plt_aarch64::get_tlsdesc_got_offset): New method. + (Output_data_plt_aarch64::get_tlsdesc_plt_offset): New method. + (Output_data_plt_aarch64::rela_tlsdesc): New method. + (Output_data_plt_aarch64::rela_irelative): New method. + (Output_data_plt_aarch64::entry_count): Count IRELATIVE relocations. + (Output_data_plt_aarch64::first_plt_entry_offset): Add const attribute. + (Output_data_plt_aarch64::get_plt_tlsdesc_entry_size): New method. + (Output_data_plt_aarch64::fill_tlsdesc_entry): New method. + (Output_data_plt_aarch64::do_get_plt_tlsdesc_entry_size): New method. + (Output_data_plt_aarch64::do_fill_tlsdesc_entry): New method. + (Output_data_plt_aarch64_standard): New member variables: + plt_tlsdesc_entry_size, tlsdesc_plt_entry. + (Output_data_plt_aarch64_standard::Output_data_plt_aarch64_standard): + New parameter: got, got_irelative. + (Output_data_plt_aarch64_standard::do_get_plt_entry_size): New method. + (Output_data_plt_aarch64_standard::do_fill_tlsdesc_entry): New method. + (Output_data_plt_aarch64::do_write): Replace got_address with + gotplt_address. Add irelative_count_ to count. Write tlsdesc entry. + (AArch64_relocate_functions::update_movnz): New method. + (AArch64_relocate_functions): Correct format. + (AArch64_relocate_functions::movnz): New method. + (Target_aarch64::Scan::local): Correct format. Move r_sym, got to + before the switch. Add new cases to switch. + Check ie_to_le relaxation on tlsie relocations. Add code handling + tlsgd tlsdesc cases. + (Target_aarch64::Scan::global): Move arp to front. Do copy_reloc when + needed. Add new cases to switch. Insert dynamic RELATIVE relocation + when needed. Add code handling tlsgd, tlsie, tlsdesc cases. + Call reloc_name_in_error_message to print unsupported reloc. + (Target_aarch64::make_plt_section): Pass got_ and got_irelative_ to + make_data_plt. + (Target_aarch64::do_finalize_sections): Emit relocs to save COPY + relocs. Fill in some more dynamic tags. + (Target_aarch64::Relocate::relocate): Handle tlsgd, tlsdesc relocs. + Skip call tls_get_addr when tlsgd is relaxed. + (Target_aarch64::Relocate::relocate_tls): Correct format. Add code + handling tlsgd, tlsdesc relocs, and tls gd->le, ie->le, tlsdesc->le, + tlsdesc->ie relaxation. + +2014-09-03 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * mips.cc (Target_mips_nacl): New class. + (Target_selector_mips_nacl): New class. + (target_selector_mips32): Rename from target_selector_mips32be and use + Target_selector_mips_nacl instead of Target_selector_mips. + (target_selector_mips32el): Rename from target_selector_mips32 and use + Target_selector_mips_nacl instead of Target_selector_mips. + (target_selector_mips64): Rename from target_selector_mips64be and use + Target_selector_mips_nacl instead of Target_selector_mips. + (target_selector_mips64el): Rename from target_selector_mips64 and use + Target_selector_mips_nacl instead of Target_selector_mips. + (Target_mips::mips_info): Add const attribute. + +2014-09-02 Cary Coutant <ccoutant@google.com> + + * dwp.cc (Sized_relobj_dwo::do_section_name): Add const attribute. + * dynobj.h (Sized_dynobj::do_section_name): Likewise. + * incremental.cc (Sized_relobj_incr::do_section_name): Likewise. + (Sized_incr_dynobj::do_section_name): Likewise. + * incremental.h (Sized_relobj_incr::do_section_name): Likewise. + (Sized_incr_dynobj::do_section_name): Likewise. + * object.h (Object::section_name): Likewise. + (Object::do_section_name): Likewise. + (Sized_relobj_file::do_section_name): Likewise. + * plugin.cc (Sized_pluginobj::do_section_name): Likewise. + * plugin.h (Sized_pluginobj::do_section_name): Likewise. + +2014-09-02 Cary Coutant <ccoutant@google.com> + + PR gold/17005 + * ehframe.cc (Fde::write): Add output_offset parameter. + (Cie::write): Likewise. + (Eh_frame::set_final_data_size): Account for offset within output + section. + (Eh_frame::do_sized_write): Likewise. + * ehframe.h (Fde::write): Add output_offset parameter. + (Cie::write): Likewise. + * output.cc (Output_section::Input_section_sort_entry): Remove + section_has_name_; add output_section_name parameter. Use + output section name for non-input sections. + (Output_section::Input_section_sort_entry::section_has_name): Remove. + (Output_section::Input_section_sort_entry::section_has_name_): Remove. + (Output_section::Input_section_sort_compare): Remove logic for + sections without names. + (Output_section::Input_section_sort_init_fini_compare): Likewise. + (Output_section::Input_section_sort_section_prefix_special_ordering_compare): + Likewise. + (Output_section::Input_section_sort_section_name_compare): Likewise. + +2014-08-29 Han Shen <shenhan@google.com> + Jing Yu <jingyu@google.com> + + * aarch64-reloc-property.cc + (AArch64_reloc_property_table::reloc_name_in_error_message): Fix bug in + reference reloc property in the table. + * aarch64-reloc.def: Add TLSLE reloc types and fix some errors in + 3 other entries. + * aarch64.cc: (Output_data_got_aarch64::add_static_reloc): + 2 new overloaded methods. + (Output_data_got_aarch64::do_write): Add code to write out + static relocs. + (class Output_data_got_aarch64::Static_reloc): New class to wrap + static relocs. + (Output_data_got_aarch64::static_relocs): New vector to + hold static relocs. + (Target_aarch64::TCB_SIZE): New const static memeber. + (Target_aarch64::tcb_size): New method. + (Target_aarch64::Relocate::relocate): Add code handling new reloc types. + (Target_aarch64::Relocate::relocate_tls): New method. + (Target_aarch64::Scan::local): Add code handling new reloc types. + (Target_aarch64::Scan::global): Add code handling new reloc types. + +2014-08-13 Sriraman Tallam <tmsriram@google.com> + + * options.h (-no-pie): Add option. + +2014-08-08 Jing Yu <jingyu@google.com> + Han Shen <shenhan@google.com> + + * Makefile.am (HFILES): Add aarch64-reloc-property.h. + (DEFFILES): add aarch64-reloc.def. + (TARGETSOURCES): Add aarch64-reloc-property.cc. + (ALL_TARGETOBJS): Add aarch64-reloc-property.$(OBJEXT). + * Makefile.in: Regenerate. + * aarch64-reloc-property.cc: New file. + * aarch64-reloc-property.h: New file. + * aarch64-reloc.def: New file. + * aarch64.cc: Include aarch64-reloc-property.h. Replace spaces + with tab to make the format consistent. + (Output_data_got_aarch64::symbol_table_): New method. + (Target_aarch64::do_plt_address_for_global): New method. + (Target_aarch64::do_plt_address_for_local): New method. + (Target_aarch64::do_select_as_default_target): New method. + (Target_aarch64::do_make_data_plt): New method. + (Target_aarch64::make_data_plt): New method. + (Output_data_plt_aarch64::has_irelative_section): New method. + (Output_data_plt_aarch64::address_for_global): New method. + (Output_data_plt_aarch64::address_for_local): New method. + (Output_data_plt_aarch64::irelative_rel_): New parameter. + (Output_data_plt_aarch64::add_entry): Implement contents. + (Output_data_plt_aarch64::set_final_data_size): Fix typo. + (Output_data_plt_aarch64::do_write): Remove useless got_base. Set + the got_pov entry to plt0. + (Output_data_plt_aarch64_standard::do_fill_first_plt_entry): + Implement contents. + (Output_data_plt_aarch64_standard::do_fill_plt_entry): Implement. + (AArch64_howto): New struct. + (aarch64_howto[]): New static const array. + (AArch64_relocate_functions): New class. + (Target_aarch64::Scan::get_reference_flags): Remove method. + (Target_aarch64::Scan::local): Implement to support a few relocations. + (Target_aarch64::Scan::global): Implement to support a few relocations. + (Target_aarch64::make_plt_section): Implement contents. + (Target_aarch64::make_plt_entry): Implement contents. + (Target_aarch64::do_finalize_sections): Implement contents. + (Target_aarch64::Relocate::relocate): Implement a few relocations. + (Target_aarch64::relocate_section): Implement contents. + +2014-08-06 Alan Modra <amodra@gmail.com> + + * testsuite/defsym_test.sh: Allow ppc64le localentry annotation. + +2014-08-06 Alan Modra <amodra@gmail.com> + + PR 13227 + * symtab.cc (Symbol_table::add_from_relobj): Warn on __gnu_lto_slim. + +2014-07-21 Sriraman Tallam <tmsriram@google.com> + + * object.cc (Relobj::is_section_name_included): Add + ".rodata.nptl_version" to not garbage collect this section. + +2014-07-08 Cary Coutant <ccoutant@google.com> + + * expression.cc (struct Expression::Expression_eval_info): Add + new fields type_pointer, vis_pointer, and nonvis_pointer. + (Expression::eval_maybe_dot): Add type_pointer, vis_pointer, and + nonvis_pointer parameters. Adjust all calls. + (Symbol_expression::value): Update type, visibility, and nonvis bits + in caller. + * script.cc (Symbol_assignment::sized_finalize): Update type, + visibility, and remaining st_other bits for new symbol. + * script.h: (Expression::eval_maybe_dot): Add type_pointer, + vis_pointer, and nonvis_pointer parameters. + * symtab.h (Symbol::set_type): New method. + + * testsuite/Makefile.am (defsym_test): New test. + * testsuite/Makefile.in: Regenerate. + * testsuite/defsym_test.c: New file. + * testsuite/defsym_test.sh: New file. + +2014-07-08 Cary Coutant <ccoutant@google.com> + + PR gold/15639 + * dynobj.h (Sized_dynobj::base_read_symbols): New method. + * dynobj.cc (Sized_dynobj::do_read_symbols): Move body to... + (Sized_dynobj::base_read_symbols): ...new method. + * object.h (Sized_relobj_file::base_read_symbols): New method. + * object.cc (Sized_relobj_file::do_read_symbols): Move body to... + (Sized_relobj_file::base_read_symbols): ...new method. + * arm.cc (Arm_relobj::do_read_symbols): Call base_read_symbols. + * mips.cc: (Mips_relobj::do_read_symbols): Likewise. + * powerpc.cc (Powerpc_dynobj::do_read_symbols): Likewise. + +2014-07-04 Alan Modra <amodra@gmail.com> + + * po/POTFILES.in: Regenerate. + +2014-07-02 Jing Yu <jingyu@google.com> + + * aarch64.cc: New file + * Makefile.am (TARGETSOURCES): Add aarch64.cc + (ALL_TARGETOBJS): Add aarch64.$(OBJEXT) + * Makefile.in: Regenerate. + * configure.tgt: Add entries for aarch64*. + * configure.ac: Likewise. + * configure: Likewise. + +2014-06-27 Alan Modra <amodra@gmail.com> + + * symtab.cc (Symbol::should_add_dynsym_entry): Don't make inline. + +2014-06-24 Cary Coutant <ccoutant@google.com> + + * dwp.cc (Dwo_file::read): Allow files with no .debug_types + sections. + (Dwo_file::sized_read_unit_index): Likewise. + +2014-06-23 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * mips.cc: New file. + * Makefile.am (TARGETSOURCES): Add mips.cc + (ALL_TARGETOBJS): Add mips.$(OBJEXT) + * configure.tgt: Add entries for mips*. + * configure.ac: Likewise. + * Makefile.in: Regenerate. + * configure: Likewise. + +2014-06-09 Cary Coutant <ccoutant@google.com> + + * dwarf_reader.cc (Dwarf_pubnames_table::read_header): Check that + unit_length is within section bounds. + +2014-06-09 Cary Coutant <ccoutant@google.com> + + PR gold/16980 + * layout.cc (Layout::print_to_mapfile): Print unattached sections in + map. + +2014-06-07 Alan Modra <amodra@gmail.com> + + * powerpc.cc (relocate): Treat field of cmpli insn as a bitfield. + +2014-06-06 Cary Coutant <ccoutant@google.com> + + * dwarf_reader.h (Dwarf_pubnames_table): Remove output_section_offset_. + * dwarf_reader.cc (Dwarf_pubnames_table::read_section): Likewise. + (Dwarf_pubnames_table::read_header): Likewise. + * layout.cc (gdb_fast_lookup_sections): Add .debug_gnu_pubnames and + .debug_gnu_pubtypes. + +2014-06-05 Joel Brobecker <brobecker@adacore.com> + + * Makefile.am (CONFIG_STATUS_DEPENDENCIES): New. + * Makefile.in, configure: Regenerate. + +2014-06-03 Alan Modra <amodra@gmail.com> + + * powerpc.cc (addis_12_2): Define. + (Stub_table::do_write): Support fusion on ELFv2 stubs. + +2014-06-03 Alan Modra <amodra@gmail.com> + + * testsuite/plugin_test.c (parse_readelf_line): Skip non-visibility + st_other output. + +2014-06-02 Alan Modra <amodra@gmail.com> + + * powerpc.cc (Target_powerpc::local_reloc_may_be_function_pointer): + Only ignore relocs on ELFv1. + (Target_powerpc::global_reloc_may_be_function_pointer): Likewise. + +2014-05-30 Cary Coutant <ccoutant@google.com> + + * testsuite/Makefile.am (ehdr_start_test_4): Fix typo in -B option. + * testsuite/Makefile.in: Regenerate. + * testsuite/ehdr_start_test_4.sh: Look for "U" instead of "w". + +2014-05-27 H.J. Lu <hongjiu.lu@intel.com> + + PR gold/16945 + * x86_64.cc (Target_x86_64::Relocate::relocate): Use signed int + for got_offset. Properly get GOT address for R_X86_64_PLTOFF64. + +2014-05-15 Alan Modra <amodra@gmail.com> + + * powerpc.cc (do_plt_fde_location): Handle zero length .glink. + Compare FDE contents with DW_CFA_nop rather than 0. + +2014-05-13 Sriraman Tallam <tmsriram@google.com> + + * symtab.h (may_need_copy_reloc): Remove check for position independent + code. + * x86_64.cc (Target_x86_64<size>::Scan::global): Add check for no + position independence before pc absolute may_need_copy_reloc call. + Add check for executable output befor pc relative may_need_copy_reloc + call. + * i386.cc: Ditto. + * arm.cc: Ditto. + * sparc.cc: Ditto. + * tilegx.cc: Ditto. + * powerpc.cc: Add check for no position independence before + may_need_copy_reloc calls. + * testsuite/pie_copyrelocs_test.cc: New file. + * testsuite/pie_copyrelocs_shared_test.cc: New file. + * Makefile.am (pie_copyrelocs_test): New test. + * Makefile.in: Regenerate. + +2014-05-08 Martin Liška <mliska@suse.cz> + + * output.cc (Sized_relobj_file::do_layout): Fix typo in info message. + +2014-05-06 Cary Coutant <ccoutant@google.com> + + PR gold/16900 + * i386.cc (Output_data_got_plt_i386): New class. + (Output_data_plt_i386::Output_data_plt_i386): Change type of got_plt + parameter. Change all callers. + (Output_data_plt_i386::layout_): Remove. + (Output_data_plt_i386::got_plt_): Change type. + (Target_i386::got_plt_): Change type. Change all references. + (Target_i386::got_section): Create instance of new class. + (Output_data_got_plt_i386::do_write): New function. + * x86_64.cc (Output_data_got_plt_x86_64): New class. + (Output_data_plt_x86_64::Output_data_plt_x86_64): Change type of got_plt + parameter. Change all callers. + (Output_data_plt_x86_64::layout_): Remove. + (Output_data_plt_x86_64::got_plt_): Change type. + (Target_x86_64::got_plt_): Change type. Change all references. + (Target_x86_64::got_section): Create instance of new class. + (Output_data_got_plt_x86_64::do_write): New function. + (Output_data_plt_x86_64::do_write): Don't write reserved words in GOT. + (Target_x86_64<size>::init_got_plt_for_update): Create instance of new + class. + +2014-05-05 Cary Coutant <ccoutant@google.com> + + * gdb-index.cc (Gdb_index_info_reader): Don't complain about language + if we have pubnames/pubtypes. + +2014-05-02 Cary Coutant <ccoutant@google.com> + + * defstd.cc (in_segment): Define __ehdr_start here... + * layout.cc (Layout::finalize): ...Instead of here. Set the + output segment when known. + * resolve.cc (Symbol::override_base_with_special): Remember + the original binding. + * symtab.cc (Symbol::set_output_segment): New function. + (Symbol::set_undefined): New function. + * symtab.h (Symbol::is_weak_undefined): Check original undef + binding. + (Symbol::is_strong_undefined): New function. + (Symbol::set_output_segment): New function. + (Symbol::set_undefined): New function. + * target-reloc.h (is_strong_undefined): Remove. + (issue_undefined_symbol_error): Call Symbol::is_weak_undefined. + Check for hidden undefs. + (relocate_section): Call Symbol::is_strong_undefined. + + * testsuite/Makefile.am (ehdr_start_test_1) + (ehdr_start_test_2, ehdr_start_test_3) + (ehdr_start_test_4, ehdr_start_test_5): New test cases. + * testsuite/Makefile.in: Regenerate. + * testsuite/ehdr_start_def.cc: New source file. + * testsuite/ehdr_start_test.cc: New source file. + * testsuite/ehdr_start_test.t: New linker script. + * testsuite/ehdr_start_test_4.sh: New shell script. + +2014-04-23 Cary Coutant <ccoutant@google.com> + + PR gold/16870 + * x86_64.cc (Target_x86_64::Relocate::relocate): Add missing break. + +2014-04-15 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * layout.cc (Layout::include_section): Allow a target to decide + whether to include a section. + * target.h (Target::should_include_section): New function. + (Target::do_should_include_section): New function. + +2014-04-15 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Remove and + inline into ... + (Copy_relocs::emit): ... here. + * copy-relocs.h (Copy_reloc_entry): Change from class to struct. + (Copy_reloc_entry::make_copy_reloc): Change from private to protected. + (Copy_reloc_entry::entries_): Change from private to protected. + +2014-04-02 Sriraman Tallam <tmsriram@google.com> + + * icf.cc (get_section_contents): Replace copies of reloc + vectors with const references. + +2014-04-02 Cary Coutant <ccoutant@google.com> + + * configure.ac (HAVE_PUBNAMES): Use C instead of C++. + (HAVE_NO_USE_LINKER_PLUGIN): Check for -fno-use-linker-plugin. + * configure: Regenerate. + * testsuite/Makefile.am (OPT_NO_PLUGINS): New macro for + -fno-use-linker-plugin. + (LINK1, CXXLINK1): Add it to the link command. + * testsuite/Makefile.in: Regenerate. + +2014-03-12 Alan Modra <amodra@gmail.com> + + * Makefile.in: Regenerate. + +2014-03-10 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * symtab.h (Symbol::set_nonvis): New function. + +2014-03-10 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * symtab.cc (Sized_symbol<32>::init_output_data): + Instantiate the template. + (Sized_symbol<64>::init_output_data): Likewise. + +2014-03-10 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * symtab.cc (Symbol_table::sized_write_globals): Allow a target to + adjust dynamic symbol value. + * target.h (Target::adjust_dyn_symbol): New function. + (Target::do_adjust_dyn_symbol): New function. + +2014-03-10 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * output.cc (Output_data_dynamic::Dynamic_entry::write): + Get the value of DYNAMIC_CUSTOM dynamic entry. + * output.h (Output_data_dynamic::add_custom): New function. + (Dynamic_entry::Dynamic_entry): New constructor for DYNAMIC_CUSTOM + dynamic entry. + (enum Dynamic_entry::Classification): Add DYNAMIC_CUSTOM. + * target.h (Target::dynamic_tag_custom_value): New function. + (Target::do_dynamic_tag_custom_value): New function. + +2014-03-10 Sasa Stankovic <Sasa.Stankovic@imgtec.com> + + * symtab.cc (Symbol_table::set_dynsym_indexes): Allow a target to set + dynsym indexes. + * target.h (Target::has_custom_set_dynsym_indexes): New function. + (Target::do_has_custom_set_dynsym_indexes): New function. + (Target::set_dynsym_indexes): New function. + (Target::do_set_dynsym_indexes): New function. + +2014-03-07 Alan Modra <amodra@gmail.com> + + * powerpc.cc (Powerpc_relocate_functions::Overflow_check): Add + CHECK_UNSIGNED, CHECK_LOW_INSN, CHECK_HIGH_INSN. + (Powerpc_relocate_functions::has_overflow_unsigned): New function. + (Powerpc_relocate_functions::has_overflow_bitfield, + overflowed): Use the above. + (Target_powerpc::Relocate::relocate): Correct overflow checking + for a number of relocations. Modify overflow test for 16-bit + fields in instructions to signed/unsigned according to whether + the field takes a signed or unsigned value. + +2014-03-05 Alan Modra <amodra@gmail.com> + + Update copyright years. + +2014-03-05 Alan Modra <amodra@gmail.com> + + * powerpc.cc (Target_powerpc::Scan::local, global): Support + R_PPC64_ADDR64_LOCAL. + (Target_powerpc::Relocate::relocate): Likewise. + +2014-03-03 Alan Modra <amodra@gmail.com> + + * dwp.cc (print_version): Update copyright year to current. + +2014-02-10 Alan Modra <amodra@gmail.com> + + * po/gold.pot: Regenerate. + +2014-02-06 Cary Coutant <ccoutant@google.com> + + Fix problem where -u is ignored when a weak undef is seen. + + * archive.cc (Library_base::should_include_member): Reorder + code to check for -u option if a weak undef has already been seen. + * testsuite/Makefile.am (weak_undef_test_2): New test case. + * testsuite/Makefile.in: Regenerate. + * testsuite/weak_undef_file3.cc: New file. + * testsuite/weak_undef_file4.cc: New file. + * testsuite/weak_undef_test_2.cc: New file. + +2014-02-05 Cary Coutant <ccoutant@google.com> + + Fix issues with gold undefined symbol diagnostics. + + PR binutils/15435 + * errors.cc (Errors::undefined_symbol): Move undef vtable symbol + check to here. + * target-reloc.h (is_strong_undefined): New function. + (relocate_section): Move undef vtable symbol check from here. + Check for is_strong_undefined. + +2014-02-05 Cary Coutant <ccoutant@google.com> + + Fix problems with the --dynamic-list option. + + PR gold/13577 + * options.cc (General_options::parse_dynamic_list): + Set have_dynamic_list_. + (General_options::General_options): Initialize have_dynamic_list_. + (General_options::finalize): Turn off -Bsymbolic and + -Bsymbolic-functions if --dynamic-list provided. + * options.h (General_options::have_dynamic_list): New function. + (General_options::have_dynamic_list_): New data member. + * symtab.h (Symbol::is_preemptible): Handle --dynamic-list + correctly. + + PR gold/16530 + * symtab.cc (Symbol_table::add_from_relobj): If symbol is named + in --dynamic-list, mark it. + + * testsuite/Makefile.am (gc_dynamic_list_test.sh): New test case. + (dynamic_list_2): New test case. + * testsuite/Makefile.in: Regenerate. + * testsuite/dynamic_list_2.cc: New file. + * testsuite/dynamic_list_2.t: New file. + * testsuite/dynamic_list_lib1.cc: New file. + * testsuite/dynamic_list_lib2.cc: New file. + * testsuite/gc_dynamic_list_test.c: New file. + * testsuite/gc_dynamic_list_test.sh: New file. + * testsuite/gc_dynamic_list_test.t: New file. + +2014-01-28 Cary Coutant <ccoutant@google.com> + + Add .gdb_index version 7 support. + + * gold/dwarf_reader.cc: include <utility> (for make_pair). + (Dwarf_abbrev_table::do_read_abbrevs): Check for compressed + debug sections. + (Dwarf_ranges_table::read_ranges_table): Likewise. + (Dwarf_pubnames_table::read_section): Check for GNU-style + sections, and for compressed debug sections. + (Dwarf_pubnames_table::read_header): Compute end address of table. + (Dwarf_pubnames_table::next_name): Return flag_byte. Check + for end of list by offset, not by offset == 0. + (Dwarf_info_reader::do_read_string_table): Check for compressed + debug sections. + * gold/dwarf_reader.h (Dwarf_pubnames_table::Dwarf_pubnames_table): + Initialize new data members. + (Dwarf_pubnames_table::next_name): return flag_byte. + (Dwarf_pubnames_table::end_of_table_): New data member. + (Dwarf_pubnames_table::is_gnu_style_): New data member. + * gold/gdb-index.cc (gdb_index_version): Update to version 7. + (Gdb_index_info_reader::read_pubtable): Read flag_byte. + (Gdb_index_info_reader::read_pubnames_and_pubtypes): Don't + read skeleton type unit DIEs. + (Gdb_index::add_symbol): Add flag_byte; adjust all callers. + (Gdb_index::do_write): Write flag_byte. + * gold/gdb-index.h (Gdb_index::add_symbol): Add flags parameter. + (Gdb_index::Cu_vector): Store flags along with cu indexes. + * gold/testsuite/gdb_index_test_3.sh: Allow versions 4-7. + * gold/testsuite/gdb_index_test_comm.sh: Likewise. + +2014-01-08 H.J. Lu <hongjiu.lu@intel.com> + + * version.cc (print_version): Update copyright year to 2014. + +2013-12-19 Dimitry Andric <dimitry@andric.com> + + * stringpool.cc (Stringpool_template::reserve): Add + HAVE_UNORDERED_MAP case. + * stringpool.cc (Stringpool_template::print_stats): Likewise. + +2013-12-18 Cary Coutant <ccoutant@google.com> + + * configure.ac: Check for <unordered_set> and <unordered_map>. + * config.in: Regenerate. + * configure: Regenerate. + * system.h: Use <unordered_set> and <unordered_map> if available. + +2013-12-10 Roland McGrath <mcgrathr@google.com> + + * Makefile.am (install-exec-local): Prefix $(INSTALL_PROGRAM) uses + with $(INSTALL_PROGRAM_ENV). + * Makefile.in: Regenerate. + +2013-11-22 Cary Coutant <ccoutant@google.com> + + * configure.ac: Add check for which library is needed for + dlopen. + * configure: Regenerate. + +2013-11-22 Cary Coutant <ccoutant@google.com> + + * testsuite/Makefile.am (exception_x86_64_bnd_test): Use in-tree + assembler. + * testsuite/Makefile.in: Regenerate. + +2013-11-17 H.J. Lu <hongjiu.lu@intel.com> + + * x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags): + Handle R_X86_64_PC32_BND and R_X86_64_PLT32_BND just like + R_X86_64_PC32 and R_X86_64_PLT32, respectively. + (Target_x86_64<size>::Scan::local): Likewise. + (Target_x86_64<size>::Scan::global): Likewise. + (Target_x86_64<size>::Relocate::relocate): Likewise. + (Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc): + Likewise. + (Target_x86_64<size>::Scan::check_non_pic(): Handle + R_X86_64_PC32_BND. + + * testsuite/Makefile.am (check_PROGRAMS): Add + exception_x86_64_bnd_test. + (exception_x86_64_bnd_test_SOURCES): New macro. + (exception_x86_64_bnd_test_DEPENDENCIES): Likewise. + (exception_x86_64_bnd_test_LDFLAGS): Likewise. + (exception_x86_64_bnd_test_LDADD): Likewise. + (exception_x86_64_bnd_1.o): New rule. + (exception_x86_64_bnd_2.o): Likewise. + * testsuite/Makefile.in: Regenerated. + +2013-11-15 Alan Modra <amodra@gmail.com> + + * powerpc.cc (Target_powerpc::glink_section): Provide non-const + accessor. + (Target_powerpc::Branch_info::make_stub): Make global entry stubs. + Only call ppc64_local_entry_offset for 64-bit. Restrict + symval_for_branch lookup to ELFv1. + (Stub_table::add_plt_call_entry): Use unsigned int off. + (Output_data_glink::Address, invalid_address): New. + (Output_data_glink::add_eh_frame): Move out of line. Add + support for ELFv2. + (Output_data_glink::add_global_entry, find_global_entry, + global_entry_address): New functions. + (Output_data_glink::global_entry_stubs_, end_branch_table_, + ge_size): New variables. + (Output_data_glink::set_final_data_size): Add global entry + stub sizing. + (Output_data_glink::do_write): Write global entry stubs. + (Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Add target + parameter. Return true for ELFv2. Adjust callers. + (Target_powerpc::Scan::local, global): Restrict opd lookup to + ELFv1. Similarly for ifunc and dynamic relocation processing + specific to ELFv1. Recognize that symbols are defined on + their plt entries for ELFv2. + (Target_powerpc::symval_for_branch): Assert if called for + ELFv2 or ppc32. + (Target_powerpc::Relocate::relocate): Use global entry plt + stub for symbol value if such exists on ELFv2. + (Target_powerpc::Relocate::relocate): Don't call + symval_for_branch when ELFv2. Do adjust for local entry + offset when ELFv2. + (Target_powerpc::do_dynsym_value): Set symbols to global entry + plt stub for ELFv2. + (Target_powerpc::do_plt_address_for_global): Similarly. + +2013-11-14 Cary Coutant <ccoutant@google.com> + + Revert patch -- this did not fix the problem, and there is + no race there. + + 2013-11-14 Cary Coutant <ccoutant@google.com> + + PR gold/14860 + * ehframe.cc (Eh_frame_hdr::Eh_frame_hdr): Initialize lock_. + (Ehframe_hdr::set_final_data_size): Allocate a Lock. + * ehframe.h (Eh_frame_hdr::record_fde): Hold the lock while + updating fde_offsets_. + (Eh_frame_hdr::lock_): New data member. + +2013-11-14 Cary Coutant <ccoutant@google.com> + + * dwp.cc (Dwo_file_entry): New type. + (File_list): Use Dwo_file_entry. + (Dwo_file::verify): New function. + (Dwo_file::verify_dwo_list): New function. + (Dwo_file::sized_verify_dwo_list): New function. + (Dwo_name_info_reader::visit_compilation_unit): Add dwo_id to file + list. + (Dwp_options): New enum type. + (dwp_options): Add --verify-only. + (usage): Likewise. + (main): Likewise. + * dwp.h (gold_info): Add declaration. + +2013-11-14 Cary Coutant <ccoutant@google.com> + + PR gold/14860 + * ehframe.cc (Eh_frame_hdr::Eh_frame_hdr): Initialize lock_. + (Ehframe_hdr::set_final_data_size): Allocate a Lock. + * ehframe.h (Eh_frame_hdr::record_fde): Hold the lock while + updating fde_offsets_. + (Eh_frame_hdr::lock_): New data member. + +2013-11-06 Cary Coutant <ccoutant@google.com> + + PR gold/15758 + * object.cc (Sized_relobj_file::do_layout): Handle .eh_frame sections + before reloc sections. + +2013-11-04 Alan Modra <amodra@gmail.com> + + * symtab.h (Symbol::Reference_flags): Add FUNC_DESC_ABI. + (Symbol::needs_dynamic_reloc): Test new flag. + * powerpc.cc (needs_dynamic_reloc, use_plt_offset): Delete. + (Target_powerpc::Scan::get_reference_flags): Add target param. + Return FUNC_DESC_ABI for 64-bit ELFv1. + (Target_powerpc::Branch_info::make_stub): Adjust get_reference_flags + call. + (Target_powerpc::Scan::global): Use Symbol::needs_dynamic_reloc. + (Target_powerpc::Relocate::relocate): Use Symbol::use_plt_offset. + +2013-10-31 Cary Coutant <ccoutant@google.com> + + Restore support for dwp v2 DWARF package file format. + + * dwarf_reader.cc (Dwarf_info_reader::visit_type_unit): Add + tu_length parameter. Adjust all callers. + * dwarf_reader.h (Dwarf_info_reader::visit_type_unit): Likewise. + * dwp.cc: Include dwarf.h. + (Section_bounds): New struct type. + (Unit_set): New struct type. + (Dwo_file::Dwo_file): Initialize new data member. + (Dwo_file::read_compunit_index, Dwo_file::read_typeunit_index): + Combine and rename to... + (Dwo_file::read_unit_index): ...this. + (Dwo_file::sized_read_compunit_index) + (Dwo_file::sized_read_typeunit_index): Combine and rename to... + (Dwo_file::sized_read_unit_index): ...this. + (Dwo_file::copy_section): Remove section_name, is_str_offsets + parameters; add section_id parameter. + (Dwo_file::add_cu_set, Dwo_file::add_tu_set): Combine and rename to... + (Dwo_file::add_unit_set): ...this. + (Dwo_file::shndx_map_): Remove. + (Dwo_file::sect_offsets_): New data member. + (Dwp_output_file::Dwp_output_file): Initialize new data members. + (Dwp_output_file::add_section): Rename to... + (Dwp_output_file::add_contribution): ...this. + (Dwp_output_file::add_cu_set): Combine parameters into a struct. + (Dwp_output_file::add_tu_set): Likewise. + (Dwp_output_file::Contribution): New type. + (Dwp_output_file::Section::contributions): New data member. + (Dwp_output_file::Cu_or_tu_set): Remove. + (Dwp_output_file::Section::Section): New ctor. + (Dwp_output_file::Dwp_index::Shndx_pool): Remove. + (Dwp_output_file::Dwp_index::Section_table): New type. + (Dwp_output_file::Dwp_index::Dwp_index): Initialize new data members. + (Dwp_output_file::Dwp_index::enter_set): Change type of "set" + parameter. + (Dwp_output_file::Dwp_index::shndx_pool): Remove. + (Dwp_output_file::Dwp_index::shndx_pool_end): Remove. + (Dwp_output_file::Dwp_index::section_table): New member function. + (Dwp_output_file::Dwp_index::section_table_end): New member function. + (Dwp_output_file::Dwp_index::shndx_pool_size): Remove. + (Dwp_output_file::Dwp_index::section_table_rows): New member function. + (Dwp_output_file::Dwp_index::section_table_cols): New member function. + (Dwp_output_file::Dwp_index::shndx_pool_): Remove. + (Dwp_output_file::Dwp_index::section_table_): New data member. + (Dwp_output_file::Dwp_index::section_mask_): New data member. + (Dwp_output_file::add_output_section): New member function. + (Dwp_output_file::write_new_section): New member function. + (Dwp_output_file::write_contributions): New member function. + (Dwp_output_file::section_id_map_): New data member. + (class Dwo_id_info_reader): Remove. + (class Unit_reader): New class. + (get_dwarf_section_name): New function. + (Dwo_file::read_executable): Adjust initializations of class data. + (Dwo_file::read): Add support for v2 package file format. + (Dwo_file::read_unit_index): Likewise. + (Dwo_file::sized_read_unit_index): Likewise. + (Dwo_file::copy_section): Likewise. + (Dwo_file::add_unit_set): Likewise. + (Dwp_output_file::add_output_section): Likewise. + (Dwp_output_file::add_contribution): Likewise. + (Dwp_output_file::Dwp_index::find_or_add): Use row index to check + for empty slot. + (Dwp_output_file::Dwp_index::enter_set): Add support for v2 package + file format. + (Dwp_output_file::Dwp_index::grow): Use row index to check for empty + slot. + (Dwp_output_file::initialize): Remove unused function. + (Dwp_output_file::finalize): Add support for v2 package file format. + (Dwp_output_file::write_index): Likewise. + * gdb-index.cc (Gdb_index_info_reader::visit_type_unit): Adjust + function prototype. + +2013-10-31 Cary Coutant <ccoutant@google.com> + + * configure.ac: Fix check for -fmerge-constants. + * configure.ac: Regenerate. + +2013-10-30 Roland McGrath <mcgrathr@google.com> + + * x86_64.cc (Output_data_plt_x86_64_nacl::first_plt_entry): + Correct 9-byte nop sequence to match what the assembler generates. + +2013-10-30 Alan Modra <amodra@gmail.com> + + * powerpc.cc (Powerpc_relobj::abiversion, set_abiversion, + ppc64_local_entry_offset, ppc64_local_entry_offset, + do_read_symbols): New functions. + (Powerpc_relobj::e_flags_, st_other_): New vars. + (Powerpc_relobj::Powerpc_relobj): Call set_abiversion. + (Powerpc_dynobj::abiversion, set_abiversion): New functions. + (Powerpc_relobj::e_flags_): New var. + (Target_powerpc::first_plt_entry_offset, plt_entry_size): Inline + and adjust for ELFv2. + (Target_powerpc::abiversion, set_abiversion, stk_toc): New functions. + (Powerpc_relobj::do_find_special_sections): Check no .opd in ELFv2. + (Powerpc_dynobj::do_find_special_sections): Likewise. + (Target_powerpc::do_define_standard_symbols): Define ".TOC.". + (Target_powerpc::Branch_info::make_stub): Adjust stub destination + to ELFv2 local entry. + (Target_powerpc::do_relax): No thread safe barriers needed for + ELFv2. + (Output_data_plt_powerpc::initial_plt_entry_size_, + plt_entry_size): Delete. Replace all uses with + first_plt_entry_offset() and plt_entry_size(). + (Output_data_plt_powerpc::Output_data_plt_powerpc): Remove + reserved_size parm. Update callers. + (Output_data_plt_powerpc::entry_count): Update. + (Output_data_plt_powerpc::first_plt_entry_offset): Make private + and use Target_powerpc::first_plt_entry_offset(). + (Output_data_plt_powerpc::get_plt_entry_size): Similarly and + rename to plt_entry_size. + (Output_data_plt_powerpc::add_ifunc_entry, + add_local_ifunc_entry): Adjust reloc for ELFv2. + (glink_eh_frame_fde_64): Rename to glink_eh_frame_fde_64v1. + (glink_eh_frame_fde_64v2): New. + (Stub_table::plt_call_size): Support ELFv2 sizing. + (Output_data_glink::add_eh_frame): Use the new FDE. + (Output_data_glink::set_final_data_size): Adjust for ELFv2 glink. + (Stub_table::do_write): Write ELFv2 stubs and glink. + (Target_powerpc::Relocate::relocate): Replaces nop after call + with ld 2,24(1) and adjust local offset destination for ELFv2. + +2013-10-30 Alan Modra <amodra@gmail.com> + + * powerpc.cc (Target_powerpc::Scan::check_non_pic): Handle new relocs. + (Target_powerpc::Scan::global, local): Likewise. + (Target_powerpc::Relocate::relocate): Likewise. Check for overflow + on all ppc64 @h and @ha relocs. + 2013-10-14 Alan Modra <amodra@gmail.com> * output.h (Output_data_got::add_constant): Tidy. @@ -15210,7 +16164,7 @@ * Added source code to GNU binutils. -Copyright (C) 2008-2013 Free Software Foundation, Inc. +Copyright (C) 2008-2014 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/binutils-2.25/gold/Makefile.am b/binutils-2.25/gold/Makefile.am index 8e2fff1..df99f23 100644 --- a/binutils-2.25/gold/Makefile.am +++ b/binutils-2.25/gold/Makefile.am @@ -1,18 +1,17 @@ ## Process this file with automake to generate Makefile.in # -# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -# Free Software Foundation, Inc. +# Copyright (C) 2006-2014 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING3. If not see # <http://www.gnu.org/licenses/>. @@ -107,6 +106,7 @@ CCFILES = \ HFILES = \ arm-reloc-property.h \ + aarch64-reloc-property.h \ archive.h \ attributes.h \ binary.h \ @@ -159,16 +159,18 @@ HFILES = \ YFILES = \ yyscript.y -DEFFILES = arm-reloc.def +DEFFILES = arm-reloc.def aarch64-reloc.def EXTRA_DIST = yyscript.c yyscript.h TARGETSOURCES = \ - i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc + i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \ + mips.cc aarch64.cc aarch64-reloc-property.cc ALL_TARGETOBJS = \ i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \ - arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) + arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) \ + mips.$(OBJEXT) aarch64.$(OBJEXT) aarch64-reloc-property.$(OBJEXT) libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES) libgold_a_LIBADD = $(LIBOBJS) @@ -198,6 +200,8 @@ dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADSLIB) \ $(LIBDL) dwp_LDFLAGS = $(GOLD_LDFLAGS) +CONFIG_STATUS_DEPENDENCIES = $(srcdir)/../bfd/development.sh + # Use an explicit dependency for the bison generated header file. expression.$(OBJEXT): yyscript.h script-sections.$(OBJEXT): yyscript.h @@ -211,21 +215,22 @@ check: libgold.a install-exec-local: ld-new$(EXEEXT) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin n=`echo $(installed_linker) | sed '$(transform)'`; \ - $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) \ + ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \ if test "$(bindir)" != "$(tooldir)/bin"; then \ rm -f $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \ ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT) >/dev/null 2>/dev/null \ - || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \ + || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \ fi; \ if test "x$(install_as_default)" = "xyes"; then \ ld=`echo ld | sed '$(transform)'`; \ rm -f $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \ ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT) >/dev/null 2>/dev/null \ - || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \ + || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \ if test "$(bindir)" != "$(tooldir)/bin"; then \ rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \ ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \ - || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \ + || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \ fi; \ fi diff --git a/binutils-2.25/gold/Makefile.in b/binutils-2.25/gold/Makefile.in index 3bd9fae..3e49957 100644 --- a/binutils-2.25/gold/Makefile.in +++ b/binutils-2.25/gold/Makefile.in @@ -16,19 +16,18 @@ @SET_MAKE@ # -# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -# Free Software Foundation, Inc. +# Copyright (C) 2006-2014 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING3. If not see # <http://www.gnu.org/licenses/>. @@ -478,6 +477,7 @@ CCFILES = \ HFILES = \ arm-reloc-property.h \ + aarch64-reloc-property.h \ archive.h \ attributes.h \ binary.h \ @@ -530,14 +530,16 @@ HFILES = \ YFILES = \ yyscript.y -DEFFILES = arm-reloc.def +DEFFILES = arm-reloc.def aarch64-reloc.def EXTRA_DIST = yyscript.c yyscript.h TARGETSOURCES = \ - i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc + i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \ + mips.cc aarch64.cc aarch64-reloc-property.cc ALL_TARGETOBJS = \ i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \ - arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) + arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) \ + mips.$(OBJEXT) aarch64.$(OBJEXT) aarch64-reloc-property.$(OBJEXT) libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES) libgold_a_LIBADD = $(LIBOBJS) @@ -565,6 +567,7 @@ dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADSLIB) \ $(LIBDL) dwp_LDFLAGS = $(GOLD_LDFLAGS) +CONFIG_STATUS_DEPENDENCIES = $(srcdir)/../bfd/development.sh POTFILES = $(CCFILES) $(HFILES) $(TARGETSOURCES) @GCC_TRUE@@NATIVE_LINKER_TRUE@ld1_SOURCES = $(sources_var) @GCC_TRUE@@NATIVE_LINKER_TRUE@ld1_DEPENDENCIES = $(deps_var) gcctestdir1/ld @@ -760,6 +763,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ftruncate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/mremap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pread.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aarch64-reloc-property.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aarch64.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/archive.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm-reloc-property.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm.Po@am__quote@ @@ -792,6 +797,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/merge.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mips.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nacl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ @@ -1295,21 +1301,22 @@ check: libgold.a install-exec-local: ld-new$(EXEEXT) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin n=`echo $(installed_linker) | sed '$(transform)'`; \ - $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) \ + ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \ if test "$(bindir)" != "$(tooldir)/bin"; then \ rm -f $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \ ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT) >/dev/null 2>/dev/null \ - || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \ + || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \ fi; \ if test "x$(install_as_default)" = "xyes"; then \ ld=`echo ld | sed '$(transform)'`; \ rm -f $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \ ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT) >/dev/null 2>/dev/null \ - || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \ + || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \ if test "$(bindir)" != "$(tooldir)/bin"; then \ rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \ ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \ - || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \ + || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \ fi; \ fi diff --git a/binutils-2.25/gold/NEWS b/binutils-2.25/gold/NEWS index d73ceeb..bb246f6 100644 --- a/binutils-2.25/gold/NEWS +++ b/binutils-2.25/gold/NEWS @@ -1,6 +1,6 @@ * gold added to GNU binutils. -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2012-2014 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/binutils-2.25/gold/README b/binutils-2.25/gold/README index 0fccc13..b1b24f1 100644 --- a/binutils-2.25/gold/README +++ b/binutils-2.25/gold/README @@ -62,7 +62,7 @@ to fail. If you are building gold from an official binutils release, the bison output should already be included. -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2012-2014 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/binutils-2.25/gold/aarch64-reloc-property.cc b/binutils-2.25/gold/aarch64-reloc-property.cc new file mode 100644 index 0000000..16f8449 --- /dev/null +++ b/binutils-2.25/gold/aarch64-reloc-property.cc @@ -0,0 +1,163 @@ +// aarch64-reloc-property.cc -- AArch64 relocation properties -*- C++ -*- + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Han Shen <shenhan@google.com> and Jing Yu <jingyu@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +#include "gold.h" + +#include "aarch64-reloc-property.h" +#include "aarch64.h" + +#include "symtab.h" + +#include<stdio.h> + +namespace gold +{ + +template<int L, int U> +bool +rvalue_checkup(int64_t x) +{ + // We save the extra_alignment_requirement bits on [31:16] of U. + // "extra_alignment_requirement" could be 0, 1, 3, 7 and 15. + unsigned short extra_alignment_requirement = (U & 0xFFFF0000) >> 16; + // [15:0] of U indicates the upper bound check. + int64_t u = U & 0x0000FFFF; + if (u == 0) + { + // No requirement to check overflow. + gold_assert(L == 0); + return (x & extra_alignment_requirement) == 0; + } + + // Check both overflow and alignment if needed. + int64_t low_bound = -(L == 0 ? 0 : ((int64_t)1 << L)); + int64_t up_bound = ((int64_t)1 << u); + return ((low_bound <= x && x < up_bound) + && ((x & extra_alignment_requirement) == 0)); +} + +template<> +bool +rvalue_checkup<0, 0>(int64_t) { return true; } + +template<int L, int U> +uint64_t +rvalue_bit_select(uint64_t x) +{ + if (U == 63) return x >> L; + return (x & (((uint64_t)1 << (U+1)) - 1)) >> L; +} + +template<> +uint64_t +rvalue_bit_select<0, 0>(uint64_t x) { return x; } + +AArch64_reloc_property::AArch64_reloc_property( + unsigned int code, + const char* name, + Reloc_type rtype, + Reloc_class rclass, + bool is_implemented, + int group_index, + int reference_flags, + Reloc_inst reloc_inst, + rvalue_checkup_func_p rvalue_checkup_func, + rvalue_bit_select_func rvalue_bit_select) + : code_(code), name_(name), reloc_type_(rtype), reloc_class_(rclass), + group_index_(group_index), + is_implemented_(is_implemented), + reference_flags_(reference_flags), + reloc_inst_(reloc_inst), + rvalue_checkup_func_(rvalue_checkup_func), + rvalue_bit_select_func_(rvalue_bit_select) +{} + +AArch64_reloc_property_table::AArch64_reloc_property_table() +{ + const bool Y(true), N(false); + for (unsigned int i = 0; i < Property_table_size; ++i) + table_[i] = NULL; + +#define RL_CHECK_ALIGN2 (1 << 16) +#define RL_CHECK_ALIGN4 (3 << 16) +#define RL_CHECK_ALIGN8 (7 << 16) +#define RL_CHECK_ALIGN16 (15 << 16) + +#undef ARD +#define ARD(rname, type, class, is_implemented, group_index, LB, UB, BSL, BSH, RFLAGS, inst) \ + do \ + { \ + int tidx = code_to_array_index(elfcpp::R_AARCH64_##rname); \ + AArch64_reloc_property * p = new AArch64_reloc_property( \ + elfcpp::R_AARCH64_##rname, "R_AARCH64_" #rname, \ + AArch64_reloc_property::RT_##type, \ + AArch64_reloc_property::RC_##class, \ + is_implemented, \ + group_index, \ + (RFLAGS), \ + AArch64_reloc_property::INST_##inst, \ + rvalue_checkup<LB,UB>, \ + rvalue_bit_select<BSL,BSH>); \ + table_[tidx] = p; \ + } \ + while (0); +#include"aarch64-reloc.def" +#undef ARD +} + +// Return a string describing a relocation code that fails to get a +// relocation property in get_implemented_static_reloc_property(). + +std::string +AArch64_reloc_property_table::reloc_name_in_error_message(unsigned int code) +{ + int tidx = code_to_array_index(code); + const AArch64_reloc_property* arp = this->table_[tidx]; + + if (arp == NULL) + { + char buffer[100]; + sprintf(buffer, _("invalid reloc %u"), code); + return std::string(buffer); + } + + // gold only implements static relocation codes. + AArch64_reloc_property::Reloc_type reloc_type = arp->reloc_type(); + gold_assert(reloc_type == AArch64_reloc_property::RT_STATIC + || !arp->is_implemented()); + + const char* prefix = NULL; + switch (reloc_type) + { + case AArch64_reloc_property::RT_STATIC: + prefix = arp->is_implemented() ? _("reloc ") : _("unimplemented reloc "); + break; + case AArch64_reloc_property::RT_DYNAMIC: + prefix = _("dynamic reloc "); + break; + default: + gold_unreachable(); + } + return std::string(prefix) + arp->name(); +} + +} diff --git a/binutils-2.25/gold/aarch64-reloc-property.h b/binutils-2.25/gold/aarch64-reloc-property.h new file mode 100644 index 0000000..d8d1301 --- /dev/null +++ b/binutils-2.25/gold/aarch64-reloc-property.h @@ -0,0 +1,245 @@ +// aarch64-reloc-property.h -- AArch64 relocation properties -*- C++ -*- + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Han Shen <shenhan@google.com> and Jing Yu <jingyu@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +#ifndef GOLD_AARCH64_RELOC_PROPERTY_H +#define GOLD_AARCH64_RELOC_PROPERTY_H + +#include<vector> +#include<string> + +#include"aarch64.h" + +namespace gold +{ +// The AArch64_reloc_property class is to store information about a particular +// relocation code. + +class AArch64_reloc_property +{ + public: + // Types of relocation codes. + enum Reloc_type { + RT_NONE, // No relocation type. + RT_STATIC, // Relocations processed by static linkers. + RT_DYNAMIC, // Relocations processed by dynamic linkers. + }; + + // Classes of relocation codes. + enum Reloc_class { + RC_NONE, // No relocation class. + RC_DATA, // Data relocation. + RC_AARCH64, // Static AArch64 relocations + RC_CFLOW, // Control flow + RC_TLS, // Thread local storage + RC_DYNAMIC, // Dynamic relocation + }; + + // Instructions that are associated with relocations. + enum Reloc_inst { + INST_DATA = 0, + INST_MOVW = 1, // movz, movk, movn + INST_LD = 2, // ld literal + INST_ADR = 3, // adr + INST_ADRP = 4, // adrp + INST_ADD = 5, // add + INST_LDST = 6, // ld/st + INST_TBZNZ = 7, // tbz/tbnz + INST_CONDB = 8, // B.cond + INST_B = 9, // b [25:0] + INST_CALL = 10, // bl [25:0] + INST_NUM = 11, // total number of entries in the table + }; + + // Types of bases of relative addressing relocation codes. + // enum Relative_address_base { + // RAB_NONE, // Relocation is not relative addressing + // }; + + typedef bool (*rvalue_checkup_func_p)(int64_t); + typedef uint64_t (*rvalue_bit_select_func)(uint64_t); + + // Relocation code represented by this. + unsigned int + code() const + { return this->code_; } + + // Name of the relocation code. + const std::string& + name() const + { return this->name_; } + + // Type of relocation code. + Reloc_type + reloc_type() const + { return this->reloc_type_; } + + // Class of relocation code. + Reloc_class + reloc_class() const + { return this->reloc_class_; } + + // Whether this code is implemented in gold. + bool + is_implemented() const + { return this->is_implemented_; } + + // If code is a group relocation code, return the group number, otherwise -1. + int + group_index() const + { return this->group_index_; } + + // Return alignment of relocation. + size_t + align() const + { return this->align_; } + + int + reference_flags() const + { return this->reference_flags_; } + + // Instruction associated with this relocation. + Reloc_inst + reloc_inst() const + { return this->reloc_inst_; } + + // Check overflow of x + bool checkup_x_value(int64_t x) const + { return this->rvalue_checkup_func_(x); } + + // Return portions of x as is defined in aarch64-reloc.def. + uint64_t select_x_value(uint64_t x) const + { return this->rvalue_bit_select_func_(x); } + + protected: + // These are protected. We only allow AArch64_reloc_property_table to + // manage AArch64_reloc_property. + AArch64_reloc_property(unsigned int code, const char* name, Reloc_type rtype, + Reloc_class rclass, + bool is_implemented, + int group_index, + int reference_flags, + Reloc_inst reloc_inst, + rvalue_checkup_func_p rvalue_checkup_func, + rvalue_bit_select_func rvalue_bit_select); + + friend class AArch64_reloc_property_table; + + private: + // Copying is not allowed. + AArch64_reloc_property(const AArch64_reloc_property&); + AArch64_reloc_property& operator=(const AArch64_reloc_property&); + + // Relocation code. + const unsigned int code_; + // Relocation name. + const std::string name_; + // Type of relocation. + Reloc_type reloc_type_; + // Class of relocation. + Reloc_class reloc_class_; + // Group index (0, 1, or 2) if this is a group relocation or -1 otherwise. + int group_index_; + // Size of relocation. + size_t size_; + // Alignment of relocation. + size_t align_; + // Relative address base. + // Relative_address_base relative_address_base_; + // Whether this is deprecated. + bool is_deprecated_ : 1; + // Whether this is implemented in gold. + bool is_implemented_ : 1; + // Whether this checks overflow. + bool checks_overflow_ : 1; + const int reference_flags_; + // Instruction associated with relocation. + Reloc_inst reloc_inst_; + rvalue_checkup_func_p rvalue_checkup_func_; + rvalue_bit_select_func rvalue_bit_select_func_; +}; + +class AArch64_reloc_property_table +{ + public: + AArch64_reloc_property_table(); + + const AArch64_reloc_property* + get_reloc_property(unsigned int code) const + { + unsigned int idx = code_to_array_index(code); + return this->table_[idx]; + } + + // Like get_reloc_property but only return non-NULL if relocation code is + // static and implemented. + const AArch64_reloc_property* + get_implemented_static_reloc_property(unsigned int code) const + { + unsigned int idx = code_to_array_index(code); + const AArch64_reloc_property* arp = this->table_[idx]; + return ((arp != NULL + && (arp->reloc_type() == AArch64_reloc_property::RT_STATIC) + && arp->is_implemented()) + ? arp + : NULL); + } + + // Return a string describing the relocation code that is not + // an implemented static reloc code. + std::string + reloc_name_in_error_message(unsigned int code); + + private: + // Copying is not allowed. + AArch64_reloc_property_table(const AArch64_reloc_property_table&); + AArch64_reloc_property_table& operator=(const AArch64_reloc_property_table&); + + // Map aarch64 rtypes into range(0,300) as following + // 256 ~ 313 -> 0 ~ 57 + // 512 ~ 573 -> 128 ~ 189 + int + code_to_array_index(unsigned int code) const + { + if (code == 0) return 0; + if (!((code >= elfcpp::R_AARCH64_ABS64 && + code <= elfcpp::R_AARCH64_LD64_GOTPAGE_LO15) + || (code >= elfcpp::R_AARCH64_TLSGD_ADR_PREL21 && + code <= elfcpp::R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC))) + { + gold_error(_("Invalid/unrecognized reloc reloc %d."), code); + } + unsigned int rv = -1; + if (code & (1 << 9)) + rv = 128 + code - 512; // 512 - 573 + else if (code & (1 << 8)) + rv = code - 256; // 256 - 313 + gold_assert(rv <= Property_table_size); + return rv; + } + + static const unsigned int Property_table_size = 300; + AArch64_reloc_property* table_[Property_table_size]; +}; // End of class AArch64_reloc_property_table + +} // End namespace gold. + +#endif // !defined(GOLD_AARCH64_RELOC_PROPERTY_H) diff --git a/binutils-2.25/gold/aarch64-reloc.def b/binutils-2.25/gold/aarch64-reloc.def new file mode 100644 index 0000000..b9ce49e --- /dev/null +++ b/binutils-2.25/gold/aarch64-reloc.def @@ -0,0 +1,84 @@ +// aarch64-reloc.def -- AArch64 relocation definitions. + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Han Shen <shenhan@google.com> and Jing Yu <jingyu@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. +// +// +// +// Insn modified by relocation, see enum Reloc_inst -------------------------------------------------------------------------+ +// Symbol reference type -----------------------------------------------------------------------------+ | +// Portion off X to retrieve -------------------------------------------------------------------+ | | +// Checking function, see Note(A)---------------------------------------+ | | | +// Group index---------------------------------------------------+ | | | | +// Implemented----------------------------------------------+ | | | | | +// Class-------------------------------------+ | | | | | | +// Type----------------------------+ | | | | | | | +// Name | | | | | | | | +// | | | | | | | | | +ARD(ABS64 , STATIC , DATA , Y, -1, 0,0 , 0,0 , Symbol::ABSOLUTE_REF , DATA ) +ARD(ABS32 , STATIC , DATA , Y, -1, 31,32 , 0,0 , Symbol::ABSOLUTE_REF , DATA ) +ARD(ABS16 , STATIC , DATA , Y, -1, 15,16 , 0,0 , Symbol::ABSOLUTE_REF , DATA ) +ARD(PREL64 , STATIC , DATA , Y, -1, 0,0 , 0,0 , Symbol::RELATIVE_REF , DATA ) +ARD(PREL32 , STATIC , DATA , Y, -1, 31,32 , 0,0 , Symbol::RELATIVE_REF , DATA ) +ARD(PREL16 , STATIC , DATA , Y, -1, 15,16 , 0,0 , Symbol::RELATIVE_REF , DATA ) +// Above is from Table 4-6, Data relocations, 257-262. + +ARD(ADR_PREL_PG_HI21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::RELATIVE_REF , ADRP ) +ARD(ADR_PREL_PG_HI21_NC , STATIC , AARCH64 , Y, -1, 0,0 , 12,32 , Symbol::RELATIVE_REF , ADRP ) +ARD(LDST8_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , LDST ) +ARD(LDST16_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN2 , 1,11 , Symbol::ABSOLUTE_REF , LDST ) +ARD(LDST32_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN4 , 2,11 , Symbol::ABSOLUTE_REF , LDST ) +ARD(LDST64_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN8 , 3,11 , Symbol::ABSOLUTE_REF , LDST ) +ARD(LDST128_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN16 , 4,11 , Symbol::ABSOLUTE_REF , LDST ) +ARD(ADD_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , ADD ) +ARD(ADR_GOT_PAGE , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::RELATIVE_REF , ADRP ) +ARD(LD64_GOT_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN8 , 3,11 , Symbol::ABSOLUTE_REF , LDST ) +ARD(TSTBR14 , STATIC , CFLOW , N, -1, 15,15 , 2,15 , (Symbol::FUNCTION_CALL|Symbol::ABSOLUTE_REF) , TBZNZ ) +ARD(CONDBR19 , STATIC , CFLOW , N, -1, 20,20 , 2,20 , (Symbol::FUNCTION_CALL|Symbol::ABSOLUTE_REF) , CONDB ) +ARD(CALL26 , STATIC , CFLOW , Y, -1, 27,27 , 2,27 , (Symbol::FUNCTION_CALL|Symbol::RELATIVE_REF) , CALL ) +ARD(JUMP26 , STATIC , CFLOW , Y, -1, 27,27 , 2,27 , (Symbol::FUNCTION_CALL|Symbol::RELATIVE_REF) , B ) +// Above is from Table 4-10, Relocations for control-flow instructions, +// 279-283. + +ARD(TLSGD_ADR_PAGE21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::ABSOLUTE_REF , ADRP ) +ARD(TLSGD_ADD_LO12_NC , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , ADD ) + +ARD(TLSIE_MOVW_GOTTPREL_G1 , STATIC , AARCH64 , N, -1, 0,0 , 16,31 , Symbol::ABSOLUTE_REF , MOVW ) +ARD(TLSIE_MOVW_GOTTPREL_G0_NC , STATIC , AARCH64 , N, -1, 0,0 , 0,15 , Symbol::ABSOLUTE_REF , MOVW ) +ARD(TLSIE_ADR_GOTTPREL_PAGE21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::ABSOLUTE_REF , ADRP ) +ARD(TLSIE_LD64_GOTTPREL_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN8 , 3,11 , Symbol::ABSOLUTE_REF , LDST ) +ARD(TLSIE_LD_GOTTPREL_PREL19 , STATIC , AARCH64 , N, -1, 20,20 , 2,20 , Symbol::ABSOLUTE_REF , LD ) +// Above is from Table 4-17, Initial Exec TLS relocations, 539-543. + +ARD(TLSLE_ADD_TPREL_HI12 , STATIC , AARCH64 , Y, -1, 0,24 , 12,23 , Symbol::ABSOLUTE_REF , ADD ) +ARD(TLSLE_ADD_TPREL_LO12 , STATIC , AARCH64 , Y, -1, 0,12 , 0,11 , Symbol::ABSOLUTE_REF , ADD ) +ARD(TLSLE_ADD_TPREL_LO12_NC , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , ADD ) +// Above is from Table 4-18, Local Exec TLS relocations, 544-571. + +ARD(TLSDESC_ADR_PAGE21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::RELATIVE_REF , ADRP ) +ARD(TLSDESC_LD64_LO12 , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN8 , 3,11 , Symbol::ABSOLUTE_REF , LDST ) +ARD(TLSDESC_ADD_LO12 , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , ADD ) +ARD(TLSDESC_CALL , STATIC , CFLOW , Y, -1, 0,0 , 0,0 , (Symbol::FUNCTION_CALL|Symbol::ABSOLUTE_REF) , CALL ) +// Above is from Table 4-19, TLS descriptor relocations, 560-569. + +// Note - +// A - Checking X, (L,U), if L == 0 && U == 0, no check. Otherwise, L!=0, +// check that -2^L<=X<2^U. Also an extra alignment check could be embeded +// into U. diff --git a/binutils-2.25/gold/aarch64.cc b/binutils-2.25/gold/aarch64.cc new file mode 100644 index 0000000..afb9024 --- /dev/null +++ b/binutils-2.25/gold/aarch64.cc @@ -0,0 +1,4188 @@ +// aarch64.cc -- aarch64 target support for gold. + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Jing Yu <jingyu@google.com> and Han Shen <shenhan@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +#include "gold.h" + +#include <cstring> + +#include "elfcpp.h" +#include "dwarf.h" +#include "parameters.h" +#include "reloc.h" +#include "aarch64.h" +#include "object.h" +#include "symtab.h" +#include "layout.h" +#include "output.h" +#include "copy-relocs.h" +#include "target.h" +#include "target-reloc.h" +#include "target-select.h" +#include "tls.h" +#include "freebsd.h" +#include "nacl.h" +#include "gc.h" +#include "icf.h" +#include "aarch64-reloc-property.h" + +// The first three .got.plt entries are reserved. +const int32_t AARCH64_GOTPLT_RESERVE_COUNT = 3; + +namespace +{ + +using namespace gold; + +template<int size, bool big_endian> +class Output_data_plt_aarch64; + +template<int size, bool big_endian> +class Output_data_plt_aarch64_standard; + +template<int size, bool big_endian> +class Target_aarch64; + +template<int size, bool big_endian> +class AArch64_relocate_functions; + +// Output_data_got_aarch64 class. + +template<int size, bool big_endian> +class Output_data_got_aarch64 : public Output_data_got<size, big_endian> +{ + public: + typedef typename elfcpp::Elf_types<size>::Elf_Addr Valtype; + Output_data_got_aarch64(Symbol_table* symtab, Layout* layout) + : Output_data_got<size, big_endian>(), + symbol_table_(symtab), layout_(layout) + { } + + // Add a static entry for the GOT entry at OFFSET. GSYM is a global + // symbol and R_TYPE is the code of a dynamic relocation that needs to be + // applied in a static link. + void + add_static_reloc(unsigned int got_offset, unsigned int r_type, Symbol* gsym) + { this->static_relocs_.push_back(Static_reloc(got_offset, r_type, gsym)); } + + + // Add a static reloc for the GOT entry at OFFSET. RELOBJ is an object + // defining a local symbol with INDEX. R_TYPE is the code of a dynamic + // relocation that needs to be applied in a static link. + void + add_static_reloc(unsigned int got_offset, unsigned int r_type, + Sized_relobj_file<size, big_endian>* relobj, + unsigned int index) + { + this->static_relocs_.push_back(Static_reloc(got_offset, r_type, relobj, + index)); + } + + + protected: + // Write out the GOT table. + void + do_write(Output_file* of) { + // The first entry in the GOT is the address of the .dynamic section. + gold_assert(this->data_size() >= size / 8); + Output_section* dynamic = this->layout_->dynamic_section(); + Valtype dynamic_addr = dynamic == NULL ? 0 : dynamic->address(); + this->replace_constant(0, dynamic_addr); + Output_data_got<size, big_endian>::do_write(of); + + // Handling static relocs + if (this->static_relocs_.empty()) + return; + + typedef typename elfcpp::Elf_types<size>::Elf_Addr AArch64_address; + + gold_assert(parameters->doing_static_link()); + const off_t offset = this->offset(); + const section_size_type oview_size = + convert_to_section_size_type(this->data_size()); + unsigned char* const oview = of->get_output_view(offset, oview_size); + + Output_segment* tls_segment = this->layout_->tls_segment(); + gold_assert(tls_segment != NULL); + + AArch64_address aligned_tcb_address = + align_address(Target_aarch64<size,big_endian>::TCB_SIZE, + tls_segment->maximum_alignment()); + + for (size_t i = 0; i < this->static_relocs_.size(); ++i) + { + Static_reloc& reloc(this->static_relocs_[i]); + AArch64_address value; + + if (!reloc.symbol_is_global()) + { + Sized_relobj_file<size, big_endian>* object = reloc.relobj(); + const Symbol_value<size>* psymval = + reloc.relobj()->local_symbol(reloc.index()); + + // We are doing static linking. Issue an error and skip this + // relocation if the symbol is undefined or in a discarded_section. + bool is_ordinary; + unsigned int shndx = psymval->input_shndx(&is_ordinary); + if ((shndx == elfcpp::SHN_UNDEF) + || (is_ordinary + && shndx != elfcpp::SHN_UNDEF + && !object->is_section_included(shndx) + && !this->symbol_table_->is_section_folded(object, shndx))) + { + gold_error(_("undefined or discarded local symbol %u from " + " object %s in GOT"), + reloc.index(), reloc.relobj()->name().c_str()); + continue; + } + value = psymval->value(object, 0); + } + else + { + const Symbol* gsym = reloc.symbol(); + gold_assert(gsym != NULL); + if (gsym->is_forwarder()) + gsym = this->symbol_table_->resolve_forwards(gsym); + + // We are doing static linking. Issue an error and skip this + // relocation if the symbol is undefined or in a discarded_section + // unless it is a weakly_undefined symbol. + if ((gsym->is_defined_in_discarded_section() + || gsym->is_undefined()) + && !gsym->is_weak_undefined()) + { + gold_error(_("undefined or discarded symbol %s in GOT"), + gsym->name()); + continue; + } + + if (!gsym->is_weak_undefined()) + { + const Sized_symbol<size>* sym = + static_cast<const Sized_symbol<size>*>(gsym); + value = sym->value(); + } + else + value = 0; + } + + unsigned got_offset = reloc.got_offset(); + gold_assert(got_offset < oview_size); + + typedef typename elfcpp::Swap<size, big_endian>::Valtype Valtype; + Valtype* wv = reinterpret_cast<Valtype*>(oview + got_offset); + Valtype x; + switch (reloc.r_type()) + { + case elfcpp::R_AARCH64_TLS_DTPREL64: + x = value; + break; + case elfcpp::R_AARCH64_TLS_TPREL64: + x = value + aligned_tcb_address; + break; + default: + gold_unreachable(); + } + elfcpp::Swap<size, big_endian>::writeval(wv, x); + } + + of->write_output_view(offset, oview_size, oview); + } + + private: + // Symbol table of the output object. + Symbol_table* symbol_table_; + // A pointer to the Layout class, so that we can find the .dynamic + // section when we write out the GOT section. + Layout* layout_; + + // This class represent dynamic relocations that need to be applied by + // gold because we are using TLS relocations in a static link. + class Static_reloc + { + public: + Static_reloc(unsigned int got_offset, unsigned int r_type, Symbol* gsym) + : got_offset_(got_offset), r_type_(r_type), symbol_is_global_(true) + { this->u_.global.symbol = gsym; } + + Static_reloc(unsigned int got_offset, unsigned int r_type, + Sized_relobj_file<size, big_endian>* relobj, unsigned int index) + : got_offset_(got_offset), r_type_(r_type), symbol_is_global_(false) + { + this->u_.local.relobj = relobj; + this->u_.local.index = index; + } + + // Return the GOT offset. + unsigned int + got_offset() const + { return this->got_offset_; } + + // Relocation type. + unsigned int + r_type() const + { return this->r_type_; } + + // Whether the symbol is global or not. + bool + symbol_is_global() const + { return this->symbol_is_global_; } + + // For a relocation against a global symbol, the global symbol. + Symbol* + symbol() const + { + gold_assert(this->symbol_is_global_); + return this->u_.global.symbol; + } + + // For a relocation against a local symbol, the defining object. + Sized_relobj_file<size, big_endian>* + relobj() const + { + gold_assert(!this->symbol_is_global_); + return this->u_.local.relobj; + } + + // For a relocation against a local symbol, the local symbol index. + unsigned int + index() const + { + gold_assert(!this->symbol_is_global_); + return this->u_.local.index; + } + + private: + // GOT offset of the entry to which this relocation is applied. + unsigned int got_offset_; + // Type of relocation. + unsigned int r_type_; + // Whether this relocation is against a global symbol. + bool symbol_is_global_; + // A global or local symbol. + union + { + struct + { + // For a global symbol, the symbol itself. + Symbol* symbol; + } global; + struct + { + // For a local symbol, the object defining object. + Sized_relobj_file<size, big_endian>* relobj; + // For a local symbol, the symbol index. + unsigned int index; + } local; + } u_; + }; // End of inner class Static_reloc + + std::vector<Static_reloc> static_relocs_; +}; // End of Output_data_got_aarch64 + + +AArch64_reloc_property_table* aarch64_reloc_property_table = NULL; + + +// The aarch64 target class. +// See the ABI at +// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0056b/IHI0056B_aaelf64.pdf +template<int size, bool big_endian> +class Target_aarch64 : public Sized_target<size, big_endian> +{ + public: + typedef Target_aarch64<size,big_endian> This; + typedef Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian> + Reloc_section; + typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; + const static int TCB_SIZE = size / 8 * 2; + + Target_aarch64(const Target::Target_info* info = &aarch64_info) + : Sized_target<size, big_endian>(info), + got_(NULL), plt_(NULL), got_plt_(NULL), got_irelative_(NULL), + got_tlsdesc_(NULL), global_offset_table_(NULL), rela_dyn_(NULL), + rela_irelative_(NULL), copy_relocs_(elfcpp::R_AARCH64_COPY), + got_mod_index_offset_(-1U), tlsdesc_reloc_info_(), + tls_base_symbol_defined_(false) + { } + + // Scan the relocations to determine unreferenced sections for + // garbage collection. + void + gc_process_relocs(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols); + + // Scan the relocations to look for symbol adjustments. + void + scan_relocs(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols); + + // Finalize the sections. + void + do_finalize_sections(Layout*, const Input_objects*, Symbol_table*); + + // Return the value to use for a dynamic which requires special + // treatment. + uint64_t + do_dynsym_value(const Symbol*) const; + + // Relocate a section. + void + relocate_section(const Relocate_info<size, big_endian>*, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + unsigned char* view, + typename elfcpp::Elf_types<size>::Elf_Addr view_address, + section_size_type view_size, + const Reloc_symbol_changes*); + + // Scan the relocs during a relocatable link. + void + scan_relocatable_relocs(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols, + Relocatable_relocs*); + + // Relocate a section during a relocatable link. + void + relocate_relocs( + const Relocate_info<size, big_endian>*, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + typename elfcpp::Elf_types<size>::Elf_Off offset_in_output_section, + const Relocatable_relocs*, + unsigned char* view, + typename elfcpp::Elf_types<size>::Elf_Addr view_address, + section_size_type view_size, + unsigned char* reloc_view, + section_size_type reloc_view_size); + + // Return the symbol index to use for a target specific relocation. + // The only target specific relocation is R_AARCH64_TLSDESC for a + // local symbol, which is an absolute reloc. + unsigned int + do_reloc_symbol_index(void*, unsigned int r_type) const + { + gold_assert(r_type == elfcpp::R_AARCH64_TLSDESC); + return 0; + } + + // Return the addend to use for a target specific relocation. + typename elfcpp::Elf_types<size>::Elf_Addr + do_reloc_addend(void* arg, unsigned int r_type, + typename elfcpp::Elf_types<size>::Elf_Addr addend) const; + + // Return the PLT section. + uint64_t + do_plt_address_for_global(const Symbol* gsym) const + { return this->plt_section()->address_for_global(gsym); } + + uint64_t + do_plt_address_for_local(const Relobj* relobj, unsigned int symndx) const + { return this->plt_section()->address_for_local(relobj, symndx); } + + // Return the number of entries in the PLT. + unsigned int + plt_entry_count() const; + + //Return the offset of the first non-reserved PLT entry. + unsigned int + first_plt_entry_offset() const; + + // Return the size of each PLT entry. + unsigned int + plt_entry_size() const; + + unsigned int + tcb_size() const { return This::TCB_SIZE; } + + protected: + void + do_select_as_default_target() + { + gold_assert(aarch64_reloc_property_table == NULL); + aarch64_reloc_property_table = new AArch64_reloc_property_table(); + } + + // Add a new reloc argument, returning the index in the vector. + size_t + add_tlsdesc_info(Sized_relobj_file<size, big_endian>* object, + unsigned int r_sym) + { + this->tlsdesc_reloc_info_.push_back(Tlsdesc_info(object, r_sym)); + return this->tlsdesc_reloc_info_.size() - 1; + } + + virtual Output_data_plt_aarch64<size, big_endian>* + do_make_data_plt(Layout* layout, + Output_data_got_aarch64<size, big_endian>* got, + Output_data_space* got_plt, + Output_data_space* got_irelative) + { + return new Output_data_plt_aarch64_standard<size, big_endian>( + layout, got, got_plt, got_irelative); + } + + Output_data_plt_aarch64<size, big_endian>* + make_data_plt(Layout* layout, + Output_data_got_aarch64<size, big_endian>* got, + Output_data_space* got_plt, + Output_data_space* got_irelative) + { + return this->do_make_data_plt(layout, got, got_plt, got_irelative); + } + + private: + // The class which scans relocations. + class Scan + { + public: + Scan() + : issued_non_pic_error_(false) + { } + + inline void + local(Symbol_table* symtab, Layout* layout, Target_aarch64* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>& reloc, unsigned int r_type, + const elfcpp::Sym<size, big_endian>& lsym, + bool is_discarded); + + inline void + global(Symbol_table* symtab, Layout* layout, Target_aarch64* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>& reloc, unsigned int r_type, + Symbol* gsym); + + inline bool + local_reloc_may_be_function_pointer(Symbol_table* , Layout* , + Target_aarch64<size, big_endian>* , + Sized_relobj_file<size, big_endian>* , + unsigned int , + Output_section* , + const elfcpp::Rela<size, big_endian>& , + unsigned int r_type, + const elfcpp::Sym<size, big_endian>&); + + inline bool + global_reloc_may_be_function_pointer(Symbol_table* , Layout* , + Target_aarch64<size, big_endian>* , + Sized_relobj_file<size, big_endian>* , + unsigned int , + Output_section* , + const elfcpp::Rela<size, big_endian>& , + unsigned int r_type, + Symbol* gsym); + + private: + static void + unsupported_reloc_local(Sized_relobj_file<size, big_endian>*, + unsigned int r_type); + + static void + unsupported_reloc_global(Sized_relobj_file<size, big_endian>*, + unsigned int r_type, Symbol*); + + inline bool + possible_function_pointer_reloc(unsigned int r_type); + + void + check_non_pic(Relobj*, unsigned int r_type); + + // Whether we have issued an error about a non-PIC compilation. + bool issued_non_pic_error_; + }; + + // The class which implements relocation. + class Relocate + { + public: + Relocate() + : skip_call_tls_get_addr_(false) + { } + + ~Relocate() + { } + + // Do a relocation. Return false if the caller should not issue + // any warnings about this relocation. + inline bool + relocate(const Relocate_info<size, big_endian>*, Target_aarch64*, + Output_section*, + size_t relnum, const elfcpp::Rela<size, big_endian>&, + unsigned int r_type, const Sized_symbol<size>*, + const Symbol_value<size>*, + unsigned char*, typename elfcpp::Elf_types<size>::Elf_Addr, + section_size_type); + + private: + inline typename AArch64_relocate_functions<size,big_endian>::Status + relocate_tls(const Relocate_info<size,big_endian>*, + Target_aarch64<size, big_endian>*, + size_t, + const elfcpp::Rela<size, big_endian>&, + unsigned int r_type, const Sized_symbol<size>*, + const Symbol_value<size>*, + unsigned char*, + typename elfcpp::Elf_types<size>::Elf_Addr); + + inline typename AArch64_relocate_functions<size,big_endian>::Status + tls_gd_to_le( + const Relocate_info<size,big_endian>*, + Target_aarch64<size, big_endian>*, + const elfcpp::Rela<size, big_endian>&, + unsigned int, + unsigned char*, + const Symbol_value<size>*); + + inline typename AArch64_relocate_functions<size,big_endian>::Status + tls_ie_to_le( + const Relocate_info<size,big_endian>*, + Target_aarch64<size, big_endian>*, + const elfcpp::Rela<size, big_endian>&, + unsigned int, + unsigned char*, + const Symbol_value<size>*); + + inline typename AArch64_relocate_functions<size,big_endian>::Status + tls_desc_gd_to_le( + const Relocate_info<size,big_endian>*, + Target_aarch64<size, big_endian>*, + const elfcpp::Rela<size, big_endian>&, + unsigned int, + unsigned char*, + const Symbol_value<size>*); + + inline typename AArch64_relocate_functions<size,big_endian>::Status + tls_desc_gd_to_ie( + const Relocate_info<size,big_endian>*, + Target_aarch64<size, big_endian>*, + const elfcpp::Rela<size, big_endian>&, + unsigned int, + unsigned char*, + const Symbol_value<size>*, + typename elfcpp::Elf_types<size>::Elf_Addr, + typename elfcpp::Elf_types<size>::Elf_Addr); + + bool skip_call_tls_get_addr_; + + }; // End of class Relocate + + // A class which returns the size required for a relocation type, + // used while scanning relocs during a relocatable link. + class Relocatable_size_for_reloc + { + public: + unsigned int + get_size_for_reloc(unsigned int, Relobj*); + }; + + // Adjust TLS relocation type based on the options and whether this + // is a local symbol. + static tls::Tls_optimization + optimize_tls_reloc(bool is_final, int r_type); + + // Get the GOT section, creating it if necessary. + Output_data_got_aarch64<size, big_endian>* + got_section(Symbol_table*, Layout*); + + // Get the GOT PLT section. + Output_data_space* + got_plt_section() const + { + gold_assert(this->got_plt_ != NULL); + return this->got_plt_; + } + + // Get the GOT section for TLSDESC entries. + Output_data_got<size, big_endian>* + got_tlsdesc_section() const + { + gold_assert(this->got_tlsdesc_ != NULL); + return this->got_tlsdesc_; + } + + // Create the PLT section. + void + make_plt_section(Symbol_table* symtab, Layout* layout); + + // Create a PLT entry for a global symbol. + void + make_plt_entry(Symbol_table*, Layout*, Symbol*); + + // Create a PLT entry for a local STT_GNU_IFUNC symbol. + void + make_local_ifunc_plt_entry(Symbol_table*, Layout*, + Sized_relobj_file<size, big_endian>* relobj, + unsigned int local_sym_index); + + // Define the _TLS_MODULE_BASE_ symbol in the TLS segment. + void + define_tls_base_symbol(Symbol_table*, Layout*); + + // Create the reserved PLT and GOT entries for the TLS descriptor resolver. + void + reserve_tlsdesc_entries(Symbol_table* symtab, Layout* layout); + + // Create a GOT entry for the TLS module index. + unsigned int + got_mod_index_entry(Symbol_table* symtab, Layout* layout, + Sized_relobj_file<size, big_endian>* object); + + // Get the PLT section. + Output_data_plt_aarch64<size, big_endian>* + plt_section() const + { + gold_assert(this->plt_ != NULL); + return this->plt_; + } + + // Get the dynamic reloc section, creating it if necessary. + Reloc_section* + rela_dyn_section(Layout*); + + // Get the section to use for TLSDESC relocations. + Reloc_section* + rela_tlsdesc_section(Layout*) const; + + // Get the section to use for IRELATIVE relocations. + Reloc_section* + rela_irelative_section(Layout*); + + // Add a potential copy relocation. + void + copy_reloc(Symbol_table* symtab, Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int shndx, Output_section* output_section, + Symbol* sym, const elfcpp::Rela<size, big_endian>& reloc) + { + this->copy_relocs_.copy_reloc(symtab, layout, + symtab->get_sized_symbol<size>(sym), + object, shndx, output_section, + reloc, this->rela_dyn_section(layout)); + } + + // Information about this specific target which we pass to the + // general Target structure. + static const Target::Target_info aarch64_info; + + // The types of GOT entries needed for this platform. + // These values are exposed to the ABI in an incremental link. + // Do not renumber existing values without changing the version + // number of the .gnu_incremental_inputs section. + enum Got_type + { + GOT_TYPE_STANDARD = 0, // GOT entry for a regular symbol + GOT_TYPE_TLS_OFFSET = 1, // GOT entry for TLS offset + GOT_TYPE_TLS_PAIR = 2, // GOT entry for TLS module/offset pair + GOT_TYPE_TLS_DESC = 3 // GOT entry for TLS_DESC pair + }; + + // This type is used as the argument to the target specific + // relocation routines. The only target specific reloc is + // R_AARCh64_TLSDESC against a local symbol. + struct Tlsdesc_info + { + Tlsdesc_info(Sized_relobj_file<size, big_endian>* a_object, + unsigned int a_r_sym) + : object(a_object), r_sym(a_r_sym) + { } + + // The object in which the local symbol is defined. + Sized_relobj_file<size, big_endian>* object; + // The local symbol index in the object. + unsigned int r_sym; + }; + + // The GOT section. + Output_data_got_aarch64<size, big_endian>* got_; + // The PLT section. + Output_data_plt_aarch64<size, big_endian>* plt_; + // The GOT PLT section. + Output_data_space* got_plt_; + // The GOT section for IRELATIVE relocations. + Output_data_space* got_irelative_; + // The GOT section for TLSDESC relocations. + Output_data_got<size, big_endian>* got_tlsdesc_; + // The _GLOBAL_OFFSET_TABLE_ symbol. + Symbol* global_offset_table_; + // The dynamic reloc section. + Reloc_section* rela_dyn_; + // The section to use for IRELATIVE relocs. + Reloc_section* rela_irelative_; + // Relocs saved to avoid a COPY reloc. + Copy_relocs<elfcpp::SHT_RELA, size, big_endian> copy_relocs_; + // Offset of the GOT entry for the TLS module index. + unsigned int got_mod_index_offset_; + // We handle R_AARCH64_TLSDESC against a local symbol as a target + // specific relocation. Here we store the object and local symbol + // index for the relocation. + std::vector<Tlsdesc_info> tlsdesc_reloc_info_; + // True if the _TLS_MODULE_BASE_ symbol has been defined. + bool tls_base_symbol_defined_; +}; // End of Target_aarch64 + + +template<> +const Target::Target_info Target_aarch64<64, false>::aarch64_info = +{ + 64, // size + false, // is_big_endian + elfcpp::EM_AARCH64, // machine_code + false, // has_make_symbol + false, // has_resolve + false, // has_code_fill + true, // is_default_stack_executable + false, // can_icf_inline_merge_sections + '\0', // wrap_char + "/lib/ld.so.1", // program interpreter + 0x400000, // default_text_segment_address + 0x1000, // abi_pagesize (overridable by -z max-page-size) + 0x1000, // common_pagesize (overridable by -z common-page-size) + false, // isolate_execinstr + 0, // rosegment_gap + elfcpp::SHN_UNDEF, // small_common_shndx + elfcpp::SHN_UNDEF, // large_common_shndx + 0, // small_common_section_flags + 0, // large_common_section_flags + NULL, // attributes_section + NULL, // attributes_vendor + "_start" // entry_symbol_name +}; + +template<> +const Target::Target_info Target_aarch64<32, false>::aarch64_info = +{ + 32, // size + false, // is_big_endian + elfcpp::EM_AARCH64, // machine_code + false, // has_make_symbol + false, // has_resolve + false, // has_code_fill + true, // is_default_stack_executable + false, // can_icf_inline_merge_sections + '\0', // wrap_char + "/lib/ld.so.1", // program interpreter + 0x400000, // default_text_segment_address + 0x1000, // abi_pagesize (overridable by -z max-page-size) + 0x1000, // common_pagesize (overridable by -z common-page-size) + false, // isolate_execinstr + 0, // rosegment_gap + elfcpp::SHN_UNDEF, // small_common_shndx + elfcpp::SHN_UNDEF, // large_common_shndx + 0, // small_common_section_flags + 0, // large_common_section_flags + NULL, // attributes_section + NULL, // attributes_vendor + "_start" // entry_symbol_name +}; + +template<> +const Target::Target_info Target_aarch64<64, true>::aarch64_info = +{ + 64, // size + true, // is_big_endian + elfcpp::EM_AARCH64, // machine_code + false, // has_make_symbol + false, // has_resolve + false, // has_code_fill + true, // is_default_stack_executable + false, // can_icf_inline_merge_sections + '\0', // wrap_char + "/lib/ld.so.1", // program interpreter + 0x400000, // default_text_segment_address + 0x1000, // abi_pagesize (overridable by -z max-page-size) + 0x1000, // common_pagesize (overridable by -z common-page-size) + false, // isolate_execinstr + 0, // rosegment_gap + elfcpp::SHN_UNDEF, // small_common_shndx + elfcpp::SHN_UNDEF, // large_common_shndx + 0, // small_common_section_flags + 0, // large_common_section_flags + NULL, // attributes_section + NULL, // attributes_vendor + "_start" // entry_symbol_name +}; + +template<> +const Target::Target_info Target_aarch64<32, true>::aarch64_info = +{ + 32, // size + true, // is_big_endian + elfcpp::EM_AARCH64, // machine_code + false, // has_make_symbol + false, // has_resolve + false, // has_code_fill + true, // is_default_stack_executable + false, // can_icf_inline_merge_sections + '\0', // wrap_char + "/lib/ld.so.1", // program interpreter + 0x400000, // default_text_segment_address + 0x1000, // abi_pagesize (overridable by -z max-page-size) + 0x1000, // common_pagesize (overridable by -z common-page-size) + false, // isolate_execinstr + 0, // rosegment_gap + elfcpp::SHN_UNDEF, // small_common_shndx + elfcpp::SHN_UNDEF, // large_common_shndx + 0, // small_common_section_flags + 0, // large_common_section_flags + NULL, // attributes_section + NULL, // attributes_vendor + "_start" // entry_symbol_name +}; + +// Get the GOT section, creating it if necessary. + +template<int size, bool big_endian> +Output_data_got_aarch64<size, big_endian>* +Target_aarch64<size, big_endian>::got_section(Symbol_table* symtab, + Layout* layout) +{ + if (this->got_ == NULL) + { + gold_assert(symtab != NULL && layout != NULL); + + // When using -z now, we can treat .got.plt as a relro section. + // Without -z now, it is modified after program startup by lazy + // PLT relocations. + bool is_got_plt_relro = parameters->options().now(); + Output_section_order got_order = (is_got_plt_relro + ? ORDER_RELRO + : ORDER_RELRO_LAST); + Output_section_order got_plt_order = (is_got_plt_relro + ? ORDER_RELRO + : ORDER_NON_RELRO_FIRST); + + // Layout of .got and .got.plt sections. + // .got[0] &_DYNAMIC <-_GLOBAL_OFFSET_TABLE_ + // ... + // .gotplt[0] reserved for ld.so (&linkmap) <--DT_PLTGOT + // .gotplt[1] reserved for ld.so (resolver) + // .gotplt[2] reserved + + // Generate .got section. + this->got_ = new Output_data_got_aarch64<size, big_endian>(symtab, + layout); + layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), + this->got_, got_order, true); + // The first word of GOT is reserved for the address of .dynamic. + // We put 0 here now. The value will be replaced later in + // Output_data_got_aarch64::do_write. + this->got_->add_constant(0); + + // Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT. + // _GLOBAL_OFFSET_TABLE_ value points to the start of the .got section, + // even if there is a .got.plt section. + this->global_offset_table_ = + symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL, + Symbol_table::PREDEFINED, + this->got_, + 0, 0, elfcpp::STT_OBJECT, + elfcpp::STB_LOCAL, + elfcpp::STV_HIDDEN, 0, + false, false); + + // Generate .got.plt section. + this->got_plt_ = new Output_data_space(size / 8, "** GOT PLT"); + layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC + | elfcpp::SHF_WRITE), + this->got_plt_, got_plt_order, + is_got_plt_relro); + + // The first three entries are reserved. + this->got_plt_->set_current_data_size( + AARCH64_GOTPLT_RESERVE_COUNT * (size / 8)); + + // If there are any IRELATIVE relocations, they get GOT entries + // in .got.plt after the jump slot entries. + this->got_irelative_ = new Output_data_space(size / 8, + "** GOT IRELATIVE PLT"); + layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC + | elfcpp::SHF_WRITE), + this->got_irelative_, + got_plt_order, + is_got_plt_relro); + + // If there are any TLSDESC relocations, they get GOT entries in + // .got.plt after the jump slot and IRELATIVE entries. + this->got_tlsdesc_ = new Output_data_got<size, big_endian>(); + layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC + | elfcpp::SHF_WRITE), + this->got_tlsdesc_, + got_plt_order, + is_got_plt_relro); + + if (!is_got_plt_relro) + { + // Those bytes can go into the relro segment. + layout->increase_relro( + AARCH64_GOTPLT_RESERVE_COUNT * (size / 8)); + } + + } + return this->got_; +} + +// Get the dynamic reloc section, creating it if necessary. + +template<int size, bool big_endian> +typename Target_aarch64<size, big_endian>::Reloc_section* +Target_aarch64<size, big_endian>::rela_dyn_section(Layout* layout) +{ + if (this->rela_dyn_ == NULL) + { + gold_assert(layout != NULL); + this->rela_dyn_ = new Reloc_section(parameters->options().combreloc()); + layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA, + elfcpp::SHF_ALLOC, this->rela_dyn_, + ORDER_DYNAMIC_RELOCS, false); + } + return this->rela_dyn_; +} + +// Get the section to use for IRELATIVE relocs, creating it if +// necessary. These go in .rela.dyn, but only after all other dynamic +// relocations. They need to follow the other dynamic relocations so +// that they can refer to global variables initialized by those +// relocs. + +template<int size, bool big_endian> +typename Target_aarch64<size, big_endian>::Reloc_section* +Target_aarch64<size, big_endian>::rela_irelative_section(Layout* layout) +{ + if (this->rela_irelative_ == NULL) + { + // Make sure we have already created the dynamic reloc section. + this->rela_dyn_section(layout); + this->rela_irelative_ = new Reloc_section(false); + layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA, + elfcpp::SHF_ALLOC, this->rela_irelative_, + ORDER_DYNAMIC_RELOCS, false); + gold_assert(this->rela_dyn_->output_section() + == this->rela_irelative_->output_section()); + } + return this->rela_irelative_; +} + + +// A class to handle the PLT data. +// This is an abstract base class that handles most of the linker details +// but does not know the actual contents of PLT entries. The derived +// classes below fill in those details. + +template<int size, bool big_endian> +class Output_data_plt_aarch64 : public Output_section_data +{ + public: + typedef Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian> + Reloc_section; + typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; + + Output_data_plt_aarch64(Layout* layout, + uint64_t addralign, + Output_data_got_aarch64<size, big_endian>* got, + Output_data_space* got_plt, + Output_data_space* got_irelative) + : Output_section_data(addralign), tlsdesc_rel_(NULL), + got_(got), got_plt_(got_plt), got_irelative_(got_irelative), + count_(0), irelative_count_(0), tlsdesc_got_offset_(-1U) + { this->init(layout); } + + // Initialize the PLT section. + void + init(Layout* layout); + + // Add an entry to the PLT. + void + add_entry(Symbol* gsym); + + // Add the reserved TLSDESC_PLT entry to the PLT. + void + reserve_tlsdesc_entry(unsigned int got_offset) + { this->tlsdesc_got_offset_ = got_offset; } + + // Return true if a TLSDESC_PLT entry has been reserved. + bool + has_tlsdesc_entry() const + { return this->tlsdesc_got_offset_ != -1U; } + + // Return the GOT offset for the reserved TLSDESC_PLT entry. + unsigned int + get_tlsdesc_got_offset() const + { return this->tlsdesc_got_offset_; } + + // Return the PLT offset of the reserved TLSDESC_PLT entry. + unsigned int + get_tlsdesc_plt_offset() const + { + return (this->first_plt_entry_offset() + + (this->count_ + this->irelative_count_) + * this->get_plt_entry_size()); + } + + // Return the .rela.plt section data. + Reloc_section* + rela_plt() + { return this->rel_; } + + // Return where the TLSDESC relocations should go. + Reloc_section* + rela_tlsdesc(Layout*); + + // Return where the IRELATIVE relocations should go in the PLT + // relocations. + Reloc_section* + rela_irelative(Symbol_table*, Layout*); + + // Return whether we created a section for IRELATIVE relocations. + bool + has_irelative_section() const + { return this->irelative_rel_ != NULL; } + + // Return the number of PLT entries. + unsigned int + entry_count() const + { return this->count_ + this->irelative_count_; } + + // Return the offset of the first non-reserved PLT entry. + unsigned int + first_plt_entry_offset() const + { return this->do_first_plt_entry_offset(); } + + // Return the size of a PLT entry. + unsigned int + get_plt_entry_size() const + { return this->do_get_plt_entry_size(); } + + // Return the reserved tlsdesc entry size. + unsigned int + get_plt_tlsdesc_entry_size() const + { return this->do_get_plt_tlsdesc_entry_size(); } + + // Return the PLT address to use for a global symbol. + uint64_t + address_for_global(const Symbol*); + + // Return the PLT address to use for a local symbol. + uint64_t + address_for_local(const Relobj*, unsigned int symndx); + + protected: + // Fill in the first PLT entry. + void + fill_first_plt_entry(unsigned char* pov, + Address got_address, + Address plt_address) + { this->do_fill_first_plt_entry(pov, got_address, plt_address); } + + // Fill in a normal PLT entry. + void + fill_plt_entry(unsigned char* pov, + Address got_address, + Address plt_address, + unsigned int got_offset, + unsigned int plt_offset) + { + this->do_fill_plt_entry(pov, got_address, plt_address, + got_offset, plt_offset); + } + + // Fill in the reserved TLSDESC PLT entry. + void + fill_tlsdesc_entry(unsigned char* pov, + Address gotplt_address, + Address plt_address, + Address got_base, + unsigned int tlsdesc_got_offset, + unsigned int plt_offset) + { + this->do_fill_tlsdesc_entry(pov, gotplt_address, plt_address, got_base, + tlsdesc_got_offset, plt_offset); + } + + virtual unsigned int + do_first_plt_entry_offset() const = 0; + + virtual unsigned int + do_get_plt_entry_size() const = 0; + + virtual unsigned int + do_get_plt_tlsdesc_entry_size() const = 0; + + virtual void + do_fill_first_plt_entry(unsigned char* pov, + Address got_addr, + Address plt_addr) = 0; + + virtual void + do_fill_plt_entry(unsigned char* pov, + Address got_address, + Address plt_address, + unsigned int got_offset, + unsigned int plt_offset) = 0; + + virtual void + do_fill_tlsdesc_entry(unsigned char* pov, + Address gotplt_address, + Address plt_address, + Address got_base, + unsigned int tlsdesc_got_offset, + unsigned int plt_offset) = 0; + + void + do_adjust_output_section(Output_section* os); + + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** PLT")); } + + private: + // Set the final size. + void + set_final_data_size(); + + // Write out the PLT data. + void + do_write(Output_file*); + + // The reloc section. + Reloc_section* rel_; + + // The TLSDESC relocs, if necessary. These must follow the regular + // PLT relocs. + Reloc_section* tlsdesc_rel_; + + // The IRELATIVE relocs, if necessary. These must follow the + // regular PLT relocations. + Reloc_section* irelative_rel_; + + // The .got section. + Output_data_got_aarch64<size, big_endian>* got_; + + // The .got.plt section. + Output_data_space* got_plt_; + + // The part of the .got.plt section used for IRELATIVE relocs. + Output_data_space* got_irelative_; + + // The number of PLT entries. + unsigned int count_; + + // Number of PLT entries with R_X86_64_IRELATIVE relocs. These + // follow the regular PLT entries. + unsigned int irelative_count_; + + // GOT offset of the reserved TLSDESC_GOT entry for the lazy trampoline. + // Communicated to the loader via DT_TLSDESC_GOT. The magic value -1 + // indicates an offset is not allocated. + unsigned int tlsdesc_got_offset_; +}; + +// Initialize the PLT section. + +template<int size, bool big_endian> +void +Output_data_plt_aarch64<size, big_endian>::init(Layout* layout) +{ + this->rel_ = new Reloc_section(false); + layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA, + elfcpp::SHF_ALLOC, this->rel_, + ORDER_DYNAMIC_PLT_RELOCS, false); +} + +template<int size, bool big_endian> +void +Output_data_plt_aarch64<size, big_endian>::do_adjust_output_section( + Output_section* os) +{ + os->set_entsize(this->get_plt_entry_size()); +} + +// Add an entry to the PLT. + +template<int size, bool big_endian> +void +Output_data_plt_aarch64<size, big_endian>::add_entry(Symbol* gsym) +{ + gold_assert(!gsym->has_plt_offset()); + + gsym->set_plt_offset((this->count_) * this->get_plt_entry_size() + + this->first_plt_entry_offset()); + + ++this->count_; + + section_offset_type got_offset = this->got_plt_->current_data_size(); + + // Every PLT entry needs a GOT entry which points back to the PLT + // entry (this will be changed by the dynamic linker, normally + // lazily when the function is called). + this->got_plt_->set_current_data_size(got_offset + size / 8); + + // Every PLT entry needs a reloc. + gsym->set_needs_dynsym_entry(); + this->rel_->add_global(gsym, elfcpp::R_AARCH64_JUMP_SLOT, + this->got_plt_, got_offset, 0); + + // Note that we don't need to save the symbol. The contents of the + // PLT are independent of which symbols are used. The symbols only + // appear in the relocations. +} + +// Return where the TLSDESC relocations should go, creating it if +// necessary. These follow the JUMP_SLOT relocations. + +template<int size, bool big_endian> +typename Output_data_plt_aarch64<size, big_endian>::Reloc_section* +Output_data_plt_aarch64<size, big_endian>::rela_tlsdesc(Layout* layout) +{ + if (this->tlsdesc_rel_ == NULL) + { + this->tlsdesc_rel_ = new Reloc_section(false); + layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA, + elfcpp::SHF_ALLOC, this->tlsdesc_rel_, + ORDER_DYNAMIC_PLT_RELOCS, false); + gold_assert(this->tlsdesc_rel_->output_section() + == this->rel_->output_section()); + } + return this->tlsdesc_rel_; +} + +// Return where the IRELATIVE relocations should go in the PLT. These +// follow the JUMP_SLOT and the TLSDESC relocations. + +template<int size, bool big_endian> +typename Output_data_plt_aarch64<size, big_endian>::Reloc_section* +Output_data_plt_aarch64<size, big_endian>::rela_irelative(Symbol_table* symtab, + Layout* layout) +{ + if (this->irelative_rel_ == NULL) + { + // Make sure we have a place for the TLSDESC relocations, in + // case we see any later on. + this->rela_tlsdesc(layout); + this->irelative_rel_ = new Reloc_section(false); + layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA, + elfcpp::SHF_ALLOC, this->irelative_rel_, + ORDER_DYNAMIC_PLT_RELOCS, false); + gold_assert(this->irelative_rel_->output_section() + == this->rel_->output_section()); + + if (parameters->doing_static_link()) + { + // A statically linked executable will only have a .rela.plt + // section to hold R_AARCH64_IRELATIVE relocs for + // STT_GNU_IFUNC symbols. The library will use these + // symbols to locate the IRELATIVE relocs at program startup + // time. + symtab->define_in_output_data("__rela_iplt_start", NULL, + Symbol_table::PREDEFINED, + this->irelative_rel_, 0, 0, + elfcpp::STT_NOTYPE, elfcpp::STB_GLOBAL, + elfcpp::STV_HIDDEN, 0, false, true); + symtab->define_in_output_data("__rela_iplt_end", NULL, + Symbol_table::PREDEFINED, + this->irelative_rel_, 0, 0, + elfcpp::STT_NOTYPE, elfcpp::STB_GLOBAL, + elfcpp::STV_HIDDEN, 0, true, true); + } + } + return this->irelative_rel_; +} + +// Return the PLT address to use for a global symbol. + +template<int size, bool big_endian> +uint64_t +Output_data_plt_aarch64<size, big_endian>::address_for_global( + const Symbol* gsym) +{ + uint64_t offset = 0; + if (gsym->type() == elfcpp::STT_GNU_IFUNC + && gsym->can_use_relative_reloc(false)) + offset = (this->first_plt_entry_offset() + + this->count_ * this->get_plt_entry_size()); + return this->address() + offset + gsym->plt_offset(); +} + +// Return the PLT address to use for a local symbol. These are always +// IRELATIVE relocs. + +template<int size, bool big_endian> +uint64_t +Output_data_plt_aarch64<size, big_endian>::address_for_local( + const Relobj* object, + unsigned int r_sym) +{ + return (this->address() + + this->first_plt_entry_offset() + + this->count_ * this->get_plt_entry_size() + + object->local_plt_offset(r_sym)); +} + +// Set the final size. + +template<int size, bool big_endian> +void +Output_data_plt_aarch64<size, big_endian>::set_final_data_size() +{ + unsigned int count = this->count_ + this->irelative_count_; + unsigned int extra_size = 0; + if (this->has_tlsdesc_entry()) + extra_size += this->get_plt_tlsdesc_entry_size(); + this->set_data_size(this->first_plt_entry_offset() + + count * this->get_plt_entry_size() + + extra_size); +} + +template<int size, bool big_endian> +class Output_data_plt_aarch64_standard : + public Output_data_plt_aarch64<size, big_endian> +{ + public: + typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; + Output_data_plt_aarch64_standard( + Layout* layout, + Output_data_got_aarch64<size, big_endian>* got, + Output_data_space* got_plt, + Output_data_space* got_irelative) + : Output_data_plt_aarch64<size, big_endian>(layout, + size == 32 ? 4 : 8, + got, got_plt, + got_irelative) + { } + + protected: + // Return the offset of the first non-reserved PLT entry. + virtual unsigned int + do_first_plt_entry_offset() const + { return this->first_plt_entry_size; } + + // Return the size of a PLT entry + virtual unsigned int + do_get_plt_entry_size() const + { return this->plt_entry_size; } + + // Return the size of a tlsdesc entry + virtual unsigned int + do_get_plt_tlsdesc_entry_size() const + { return this->plt_tlsdesc_entry_size; } + + virtual void + do_fill_first_plt_entry(unsigned char* pov, + Address got_address, + Address plt_address); + + virtual void + do_fill_plt_entry(unsigned char* pov, + Address got_address, + Address plt_address, + unsigned int got_offset, + unsigned int plt_offset); + + virtual void + do_fill_tlsdesc_entry(unsigned char* pov, + Address gotplt_address, + Address plt_address, + Address got_base, + unsigned int tlsdesc_got_offset, + unsigned int plt_offset); + + private: + // The size of the first plt entry size. + static const int first_plt_entry_size = 32; + // The size of the plt entry size. + static const int plt_entry_size = 16; + // The size of the plt tlsdesc entry size. + static const int plt_tlsdesc_entry_size = 32; + // Template for the first PLT entry. + static const uint32_t first_plt_entry[first_plt_entry_size / 4]; + // Template for subsequent PLT entries. + static const uint32_t plt_entry[plt_entry_size / 4]; + // The reserved TLSDESC entry in the PLT for an executable. + static const uint32_t tlsdesc_plt_entry[plt_tlsdesc_entry_size / 4]; +}; + +// The first entry in the PLT for an executable. + +template<> +const uint32_t +Output_data_plt_aarch64_standard<32, false>:: + first_plt_entry[first_plt_entry_size / 4] = +{ + 0xa9bf7bf0, /* stp x16, x30, [sp, #-16]! */ + 0x90000010, /* adrp x16, PLT_GOT+0x8 */ + 0xb9400A11, /* ldr w17, [x16, #PLT_GOT+0x8] */ + 0x11002210, /* add w16, w16,#PLT_GOT+0x8 */ + 0xd61f0220, /* br x17 */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<32, true>:: + first_plt_entry[first_plt_entry_size / 4] = +{ + 0xa9bf7bf0, /* stp x16, x30, [sp, #-16]! */ + 0x90000010, /* adrp x16, PLT_GOT+0x8 */ + 0xb9400A11, /* ldr w17, [x16, #PLT_GOT+0x8] */ + 0x11002210, /* add w16, w16,#PLT_GOT+0x8 */ + 0xd61f0220, /* br x17 */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<64, false>:: + first_plt_entry[first_plt_entry_size / 4] = +{ + 0xa9bf7bf0, /* stp x16, x30, [sp, #-16]! */ + 0x90000010, /* adrp x16, PLT_GOT+16 */ + 0xf9400A11, /* ldr x17, [x16, #PLT_GOT+0x10] */ + 0x91004210, /* add x16, x16,#PLT_GOT+0x10 */ + 0xd61f0220, /* br x17 */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<64, true>:: + first_plt_entry[first_plt_entry_size / 4] = +{ + 0xa9bf7bf0, /* stp x16, x30, [sp, #-16]! */ + 0x90000010, /* adrp x16, PLT_GOT+16 */ + 0xf9400A11, /* ldr x17, [x16, #PLT_GOT+0x10] */ + 0x91004210, /* add x16, x16,#PLT_GOT+0x10 */ + 0xd61f0220, /* br x17 */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<32, false>:: + plt_entry[plt_entry_size / 4] = +{ + 0x90000010, /* adrp x16, PLTGOT + n * 4 */ + 0xb9400211, /* ldr w17, [w16, PLTGOT + n * 4] */ + 0x11000210, /* add w16, w16, :lo12:PLTGOT + n * 4 */ + 0xd61f0220, /* br x17. */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<32, true>:: + plt_entry[plt_entry_size / 4] = +{ + 0x90000010, /* adrp x16, PLTGOT + n * 4 */ + 0xb9400211, /* ldr w17, [w16, PLTGOT + n * 4] */ + 0x11000210, /* add w16, w16, :lo12:PLTGOT + n * 4 */ + 0xd61f0220, /* br x17. */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<64, false>:: + plt_entry[plt_entry_size / 4] = +{ + 0x90000010, /* adrp x16, PLTGOT + n * 8 */ + 0xf9400211, /* ldr x17, [x16, PLTGOT + n * 8] */ + 0x91000210, /* add x16, x16, :lo12:PLTGOT + n * 8 */ + 0xd61f0220, /* br x17. */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<64, true>:: + plt_entry[plt_entry_size / 4] = +{ + 0x90000010, /* adrp x16, PLTGOT + n * 8 */ + 0xf9400211, /* ldr x17, [x16, PLTGOT + n * 8] */ + 0x91000210, /* add x16, x16, :lo12:PLTGOT + n * 8 */ + 0xd61f0220, /* br x17. */ +}; + +template<int size, bool big_endian> +void +Output_data_plt_aarch64_standard<size, big_endian>::do_fill_first_plt_entry( + unsigned char* pov, + Address got_address, + Address plt_address) +{ + // PLT0 of the small PLT looks like this in ELF64 - + // stp x16, x30, [sp, #-16]! Save the reloc and lr on stack. + // adrp x16, PLT_GOT + 16 Get the page base of the GOTPLT + // ldr x17, [x16, #:lo12:PLT_GOT+16] Load the address of the + // symbol resolver + // add x16, x16, #:lo12:PLT_GOT+16 Load the lo12 bits of the + // GOTPLT entry for this. + // br x17 + // PLT0 will be slightly different in ELF32 due to different got entry + // size. + memcpy(pov, this->first_plt_entry, this->first_plt_entry_size); + Address gotplt_2nd_ent = got_address + (size / 8) * 2; + + // Fill in the top 21 bits for this: ADRP x16, PLT_GOT + 8 * 2. + // ADRP: (PG(S+A)-PG(P)) >> 12) & 0x1fffff. + // FIXME: This only works for 64bit + AArch64_relocate_functions<size, big_endian>::adrp(pov + 4, + gotplt_2nd_ent, plt_address + 4); + + // Fill in R_AARCH64_LDST8_LO12 + elfcpp::Swap<32, big_endian>::writeval( + pov + 8, + ((this->first_plt_entry[2] & 0xffc003ff) + | ((gotplt_2nd_ent & 0xff8) << 7))); + + // Fill in R_AARCH64_ADD_ABS_LO12 + elfcpp::Swap<32, big_endian>::writeval( + pov + 12, + ((this->first_plt_entry[3] & 0xffc003ff) + | ((gotplt_2nd_ent & 0xfff) << 10))); +} + +// Subsequent entries in the PLT for an executable. +// FIXME: This only works for 64bit + +template<int size, bool big_endian> +void +Output_data_plt_aarch64_standard<size, big_endian>::do_fill_plt_entry( + unsigned char* pov, + Address got_address, + Address plt_address, + unsigned int got_offset, + unsigned int plt_offset) +{ + memcpy(pov, this->plt_entry, this->plt_entry_size); + + Address gotplt_entry_address = got_address + got_offset; + Address plt_entry_address = plt_address + plt_offset; + + // Fill in R_AARCH64_PCREL_ADR_HI21 + AArch64_relocate_functions<size, big_endian>::adrp( + pov, + gotplt_entry_address, + plt_entry_address); + + // Fill in R_AARCH64_LDST64_ABS_LO12 + elfcpp::Swap<32, big_endian>::writeval( + pov + 4, + ((this->plt_entry[1] & 0xffc003ff) + | ((gotplt_entry_address & 0xff8) << 7))); + + // Fill in R_AARCH64_ADD_ABS_LO12 + elfcpp::Swap<32, big_endian>::writeval( + pov + 8, + ((this->plt_entry[2] & 0xffc003ff) + | ((gotplt_entry_address & 0xfff) <<10))); + +} + + +template<> +const uint32_t +Output_data_plt_aarch64_standard<32, false>:: + tlsdesc_plt_entry[plt_tlsdesc_entry_size / 4] = +{ + 0xa9bf0fe2, /* stp x2, x3, [sp, #-16]! */ + 0x90000002, /* adrp x2, 0 */ + 0x90000003, /* adrp x3, 0 */ + 0xb9400042, /* ldr w2, [w2, #0] */ + 0x11000063, /* add w3, w3, 0 */ + 0xd61f0040, /* br x2 */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<32, true>:: + tlsdesc_plt_entry[plt_tlsdesc_entry_size / 4] = +{ + 0xa9bf0fe2, /* stp x2, x3, [sp, #-16]! */ + 0x90000002, /* adrp x2, 0 */ + 0x90000003, /* adrp x3, 0 */ + 0xb9400042, /* ldr w2, [w2, #0] */ + 0x11000063, /* add w3, w3, 0 */ + 0xd61f0040, /* br x2 */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<64, false>:: + tlsdesc_plt_entry[plt_tlsdesc_entry_size / 4] = +{ + 0xa9bf0fe2, /* stp x2, x3, [sp, #-16]! */ + 0x90000002, /* adrp x2, 0 */ + 0x90000003, /* adrp x3, 0 */ + 0xf9400042, /* ldr x2, [x2, #0] */ + 0x91000063, /* add x3, x3, 0 */ + 0xd61f0040, /* br x2 */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ +}; + +template<> +const uint32_t +Output_data_plt_aarch64_standard<64, true>:: + tlsdesc_plt_entry[plt_tlsdesc_entry_size / 4] = +{ + 0xa9bf0fe2, /* stp x2, x3, [sp, #-16]! */ + 0x90000002, /* adrp x2, 0 */ + 0x90000003, /* adrp x3, 0 */ + 0xf9400042, /* ldr x2, [x2, #0] */ + 0x91000063, /* add x3, x3, 0 */ + 0xd61f0040, /* br x2 */ + 0xd503201f, /* nop */ + 0xd503201f, /* nop */ +}; + +template<int size, bool big_endian> +void +Output_data_plt_aarch64_standard<size, big_endian>::do_fill_tlsdesc_entry( + unsigned char* pov, + Address gotplt_address, + Address plt_address, + Address got_base, + unsigned int tlsdesc_got_offset, + unsigned int plt_offset) +{ + memcpy(pov, tlsdesc_plt_entry, plt_tlsdesc_entry_size); + + // move DT_TLSDESC_GOT address into x2 + // move .got.plt address into x3 + Address tlsdesc_got_entry = got_base + tlsdesc_got_offset; + Address plt_entry_address = plt_address + plt_offset; + + // R_AARCH64_ADR_PREL_PG_HI21 + AArch64_relocate_functions<size, big_endian>::adrp( + pov + 4, + tlsdesc_got_entry, + plt_entry_address + 4); + + // R_AARCH64_ADR_PREL_PG_HI21 + AArch64_relocate_functions<size, big_endian>::adrp( + pov + 8, + gotplt_address, + plt_entry_address + 8); + + // R_AARCH64_LDST64_ABS_LO12 + elfcpp::Swap<32, big_endian>::writeval( + pov + 12, + ((this->tlsdesc_plt_entry[3] & 0xffc003ff) + | ((tlsdesc_got_entry & 0xff8) << 7))); + + // R_AARCH64_ADD_ABS_LO12 + elfcpp::Swap<32, big_endian>::writeval( + pov + 16, + ((this->tlsdesc_plt_entry[4] & 0xffc003ff) + | ((gotplt_address & 0xfff) << 10))); +} + +// Write out the PLT. This uses the hand-coded instructions above, +// and adjusts them as needed. This is specified by the AMD64 ABI. + +template<int size, bool big_endian> +void +Output_data_plt_aarch64<size, big_endian>::do_write(Output_file* of) +{ + const off_t offset = this->offset(); + const section_size_type oview_size = + convert_to_section_size_type(this->data_size()); + unsigned char* const oview = of->get_output_view(offset, oview_size); + + const off_t got_file_offset = this->got_plt_->offset(); + const section_size_type got_size = + convert_to_section_size_type(this->got_plt_->data_size()); + unsigned char* const got_view = of->get_output_view(got_file_offset, + got_size); + + unsigned char* pov = oview; + + // The base address of the .plt section. + typename elfcpp::Elf_types<size>::Elf_Addr plt_address = this->address(); + // The base address of the PLT portion of the .got section. + typename elfcpp::Elf_types<size>::Elf_Addr gotplt_address + = this->got_plt_->address(); + + this->fill_first_plt_entry(pov, gotplt_address, plt_address); + pov += this->first_plt_entry_offset(); + + // The first three entries in .got.plt are reserved. + unsigned char* got_pov = got_view; + memset(got_pov, 0, size / 8 * AARCH64_GOTPLT_RESERVE_COUNT); + got_pov += (size / 8) * AARCH64_GOTPLT_RESERVE_COUNT; + + unsigned int plt_offset = this->first_plt_entry_offset(); + unsigned int got_offset = (size / 8) * AARCH64_GOTPLT_RESERVE_COUNT; + const unsigned int count = this->count_ + this->irelative_count_; + for (unsigned int plt_index = 0; + plt_index < count; + ++plt_index, + pov += this->get_plt_entry_size(), + got_pov += size / 8, + plt_offset += this->get_plt_entry_size(), + got_offset += size / 8) + { + // Set and adjust the PLT entry itself. + this->fill_plt_entry(pov, gotplt_address, plt_address, + got_offset, plt_offset); + + // Set the entry in the GOT, which points to plt0. + elfcpp::Swap<size, big_endian>::writeval(got_pov, plt_address); + } + + if (this->has_tlsdesc_entry()) + { + // Set and adjust the reserved TLSDESC PLT entry. + unsigned int tlsdesc_got_offset = this->get_tlsdesc_got_offset(); + // The base address of the .base section. + typename elfcpp::Elf_types<size>::Elf_Addr got_base = + this->got_->address(); + this->fill_tlsdesc_entry(pov, gotplt_address, plt_address, got_base, + tlsdesc_got_offset, plt_offset); + pov += this->get_plt_tlsdesc_entry_size(); + } + + gold_assert(static_cast<section_size_type>(pov - oview) == oview_size); + gold_assert(static_cast<section_size_type>(got_pov - got_view) == got_size); + + of->write_output_view(offset, oview_size, oview); + of->write_output_view(got_file_offset, got_size, got_view); +} + +// Telling how to update the immediate field of an instruction. +struct AArch64_howto +{ + // The immediate field mask. + elfcpp::Elf_Xword dst_mask; + + // The offset to apply relocation immediate + int doffset; + + // The second part offset, if the immediate field has two parts. + // -1 if the immediate field has only one part. + int doffset2; +}; + +static const AArch64_howto aarch64_howto[AArch64_reloc_property::INST_NUM] = +{ + {0, -1, -1}, // DATA + {0x1fffe0, 5, -1}, // MOVW [20:5]-imm16 + {0xffffe0, 5, -1}, // LD [23:5]-imm19 + {0x60ffffe0, 29, 5}, // ADR [30:29]-immlo [23:5]-immhi + {0x60ffffe0, 29, 5}, // ADRP [30:29]-immlo [23:5]-immhi + {0x3ffc00, 10, -1}, // ADD [21:10]-imm12 + {0x3ffc00, 10, -1}, // LDST [21:10]-imm12 + {0x7ffe0, 5, -1}, // TBZNZ [18:5]-imm14 + {0xffffe0, 5, -1}, // CONDB [23:5]-imm19 + {0x3ffffff, 0, -1}, // B [25:0]-imm26 + {0x3ffffff, 0, -1}, // CALL [25:0]-imm26 +}; + +// AArch64 relocate function class + +template<int size, bool big_endian> +class AArch64_relocate_functions +{ + public: + typedef enum + { + STATUS_OKAY, // No error during relocation. + STATUS_OVERFLOW, // Relocation overflow. + STATUS_BAD_RELOC, // Relocation cannot be applied. + } Status; + + private: + typedef AArch64_relocate_functions<size, big_endian> This; + typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; + + // Return the page address of the address. + // Page(address) = address & ~0xFFF + + static inline typename elfcpp::Swap<size, big_endian>::Valtype + Page(Address address) + { + return (address & (~static_cast<Address>(0xFFF))); + } + + // Update instruction (pointed by view) with selected bits (immed). + // val = (val & ~dst_mask) | (immed << doffset) + + template<int valsize> + static inline void + update_view(unsigned char* view, + typename elfcpp::Swap<size, big_endian>::Valtype immed, + elfcpp::Elf_Xword doffset, + elfcpp::Elf_Xword dst_mask) + { + typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype; + Valtype* wv = reinterpret_cast<Valtype*>(view); + Valtype val = elfcpp::Swap<valsize, big_endian>::readval(wv); + + // Clear immediate fields. + val &= ~dst_mask; + elfcpp::Swap<valsize, big_endian>::writeval(wv, + static_cast<Valtype>(val | (immed << doffset))); + } + + // Update two parts of an instruction (pointed by view) with selected + // bits (immed1 and immed2). + // val = (val & ~dst_mask) | (immed1 << doffset1) | (immed2 << doffset2) + + template<int valsize> + static inline void + update_view_two_parts( + unsigned char* view, + typename elfcpp::Swap<size, big_endian>::Valtype immed1, + typename elfcpp::Swap<size, big_endian>::Valtype immed2, + elfcpp::Elf_Xword doffset1, + elfcpp::Elf_Xword doffset2, + elfcpp::Elf_Xword dst_mask) + { + typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype; + Valtype* wv = reinterpret_cast<Valtype*>(view); + Valtype val = elfcpp::Swap<valsize, big_endian>::readval(wv); + val &= ~dst_mask; + elfcpp::Swap<valsize, big_endian>::writeval(wv, + static_cast<Valtype>(val | (immed1 << doffset1) | + (immed2 << doffset2))); + } + + // Update adr or adrp instruction with [32:12] of X. + // In adr and adrp: [30:29] immlo [23:5] immhi + + static inline void + update_adr(unsigned char* view, + typename elfcpp::Swap<size, big_endian>::Valtype x, + const AArch64_reloc_property* /* reloc_property */) + { + elfcpp::Elf_Xword dst_mask = (0x3 << 29) | (0x7ffff << 5); + typename elfcpp::Swap<32, big_endian>::Valtype immed = + (x >> 12) & 0x1fffff; + This::template update_view_two_parts<32>( + view, + immed & 0x3, + (immed & 0x1ffffc) >> 2, + 29, + 5, + dst_mask); + } + + // Update movz/movn instruction with bits immed. + // Set instruction to movz if is_movz is true, otherwise set instruction + // to movn. + static inline void + update_movnz(unsigned char* view, + typename elfcpp::Swap<size, big_endian>::Valtype immed, + bool is_movz) + { + typedef typename elfcpp::Swap<32, big_endian>::Valtype Valtype; + Valtype* wv = reinterpret_cast<Valtype*>(view); + Valtype val = elfcpp::Swap<32, big_endian>::readval(wv); + + const elfcpp::Elf_Xword doffset = + aarch64_howto[AArch64_reloc_property::INST_MOVW].doffset; + const elfcpp::Elf_Xword dst_mask = + aarch64_howto[AArch64_reloc_property::INST_MOVW].dst_mask; + + // Clear immediate fields and opc code. + val &= ~(dst_mask | (0x11 << 29)); + + // Set instruction to movz or movn. + // movz: [30:29] is 10 movn: [30:29] is 00 + if (is_movz) + val |= (0x10 << 29); + + elfcpp::Swap<32, big_endian>::writeval(wv, + static_cast<Valtype>(val | (immed << doffset))); + } + + public: + + // Do a simple rela relocation at unaligned addresses. + + template<int valsize> + static inline typename This::Status + rela_ua(unsigned char* view, + const Sized_relobj_file<size, big_endian>* object, + const Symbol_value<size>* psymval, + typename elfcpp::Swap<size, big_endian>::Valtype addend, + const AArch64_reloc_property* reloc_property) + { + typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype + Valtype; + typename elfcpp::Elf_types<size>::Elf_Addr x = + psymval->value(object, addend); + elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view, + static_cast<Valtype>(x)); + return (reloc_property->checkup_x_value(x) + ? This::STATUS_OKAY + : This::STATUS_OVERFLOW); + } + + // Do a simple pc-relative relocation at unaligned addresses. + + template<int valsize> + static inline typename This::Status + pcrela_ua(unsigned char* view, + const Sized_relobj_file<size, big_endian>* object, + const Symbol_value<size>* psymval, + typename elfcpp::Swap<size, big_endian>::Valtype addend, + Address address, + const AArch64_reloc_property* reloc_property) + { + typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype + Valtype; + Address x = psymval->value(object, addend) - address; + elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view, + static_cast<Valtype>(x)); + return (reloc_property->checkup_x_value(x) + ? This::STATUS_OKAY + : This::STATUS_OVERFLOW); + } + + // Do a simple rela relocation at aligned addresses. + + template<int valsize> + static inline typename This::Status + rela( + unsigned char* view, + const Sized_relobj_file<size, big_endian>* object, + const Symbol_value<size>* psymval, + typename elfcpp::Swap<size, big_endian>::Valtype addend, + const AArch64_reloc_property* reloc_property) + { + typedef typename elfcpp::Swap<valsize, big_endian>::Valtype + Valtype; + Valtype* wv = reinterpret_cast<Valtype*>(view); + Address x = psymval->value(object, addend); + elfcpp::Swap<valsize, big_endian>::writeval(wv, + static_cast<Valtype>(x)); + return (reloc_property->checkup_x_value(x) + ? This::STATUS_OKAY + : This::STATUS_OVERFLOW); + } + + // Do relocate. Update selected bits in text. + // new_val = (val & ~dst_mask) | (immed << doffset) + + template<int valsize> + static inline typename This::Status + rela_general(unsigned char* view, + const Sized_relobj_file<size, big_endian>* object, + const Symbol_value<size>* psymval, + typename elfcpp::Swap<size, big_endian>::Valtype addend, + const AArch64_reloc_property* reloc_property) + { + // Calculate relocation. + Address x = psymval->value(object, addend); + + // Select bits from X. + Address immed = reloc_property->select_x_value(x); + + // Update view. + const AArch64_reloc_property::Reloc_inst inst = + reloc_property->reloc_inst(); + // If it is a data relocation or instruction has 2 parts of immediate + // fields, you should not call rela_general. + gold_assert(aarch64_howto[inst].doffset2 == -1 && + aarch64_howto[inst].doffset != -1); + This::template update_view<valsize>(view, immed, + aarch64_howto[inst].doffset, + aarch64_howto[inst].dst_mask); + + // Do check overflow or alignment if needed. + return (reloc_property->checkup_x_value(x) + ? This::STATUS_OKAY + : This::STATUS_OVERFLOW); + } + + // Do relocate. Update selected bits in text. + // new val = (val & ~dst_mask) | (immed << doffset) + + template<int valsize> + static inline typename This::Status + rela_general( + unsigned char* view, + typename elfcpp::Swap<size, big_endian>::Valtype s, + typename elfcpp::Swap<size, big_endian>::Valtype addend, + const AArch64_reloc_property* reloc_property) + { + // Calculate relocation. + Address x = s + addend; + + // Select bits from X. + Address immed = reloc_property->select_x_value(x); + + // Update view. + const AArch64_reloc_property::Reloc_inst inst = + reloc_property->reloc_inst(); + // If it is a data relocation or instruction has 2 parts of immediate + // fields, you should not call rela_general. + gold_assert(aarch64_howto[inst].doffset2 == -1 && + aarch64_howto[inst].doffset != -1); + This::template update_view<valsize>(view, immed, + aarch64_howto[inst].doffset, + aarch64_howto[inst].dst_mask); + + // Do check overflow or alignment if needed. + return (reloc_property->checkup_x_value(x) + ? This::STATUS_OKAY + : This::STATUS_OVERFLOW); + } + + // Do address relative relocate. Update selected bits in text. + // new val = (val & ~dst_mask) | (immed << doffset) + + template<int valsize> + static inline typename This::Status + pcrela_general( + unsigned char* view, + const Sized_relobj_file<size, big_endian>* object, + const Symbol_value<size>* psymval, + typename elfcpp::Swap<size, big_endian>::Valtype addend, + Address address, + const AArch64_reloc_property* reloc_property) + { + // Calculate relocation. + Address x = psymval->value(object, addend) - address; + + // Select bits from X. + Address immed = reloc_property->select_x_value(x); + + // Update view. + const AArch64_reloc_property::Reloc_inst inst = + reloc_property->reloc_inst(); + // If it is a data relocation or instruction has 2 parts of immediate + // fields, you should not call pcrela_general. + gold_assert(aarch64_howto[inst].doffset2 == -1 && + aarch64_howto[inst].doffset != -1); + This::template update_view<valsize>(view, immed, + aarch64_howto[inst].doffset, + aarch64_howto[inst].dst_mask); + + // Do check overflow or alignment if needed. + return (reloc_property->checkup_x_value(x) + ? This::STATUS_OKAY + : This::STATUS_OVERFLOW); + } + + // Calculate PG(S+A) - PG(address), update adrp instruction. + // R_AARCH64_ADR_PREL_PG_HI21 + + static inline typename This::Status + adrp( + unsigned char* view, + Address sa, + Address address) + { + typename elfcpp::Swap<size, big_endian>::Valtype x = + This::Page(sa) - This::Page(address); + update_adr(view, x, NULL); + return (size == 64 && Bits<32>::has_overflow(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // Calculate PG(S+A) - PG(address), update adrp instruction. + // R_AARCH64_ADR_PREL_PG_HI21 + + static inline typename This::Status + adrp(unsigned char* view, + const Sized_relobj_file<size, big_endian>* object, + const Symbol_value<size>* psymval, + Address addend, + Address address, + const AArch64_reloc_property* reloc_property) + { + Address sa = psymval->value(object, addend); + typename elfcpp::Swap<size, big_endian>::Valtype x = + This::Page(sa) - This::Page(address); + update_adr(view, x, reloc_property); + return (reloc_property->checkup_x_value(x) + ? This::STATUS_OKAY + : This::STATUS_OVERFLOW); + } + + // Update mov[n/z] instruction. Check overflow if needed. + // If X >=0, set the instruction to movz and its immediate value to the + // selected bits S. + // If X < 0, set the instruction to movn and its immediate value to + // NOT (selected bits of). + + static inline typename This::Status + movnz(unsigned char* view, + typename elfcpp::Swap<size, big_endian>::Valtype x, + const AArch64_reloc_property* reloc_property) + { + // Select bits from X. + Address immed = reloc_property->select_x_value(x); + bool is_movz = true; + if (static_cast<int64_t>(x) < 0) + { + immed = ~immed; + is_movz = false; + } + + // Update movnz instruction. + update_movnz(view, immed, is_movz); + + // Do check overflow or alignment if needed. + return (reloc_property->checkup_x_value(x) + ? This::STATUS_OKAY + : This::STATUS_OVERFLOW); + } + +}; // End of AArch64_relocate_functions + + +template<int size, bool big_endian> +typename elfcpp::Elf_types<size>::Elf_Addr +Target_aarch64<size, big_endian>::do_reloc_addend( + void* arg, unsigned int r_type, + typename elfcpp::Elf_types<size>::Elf_Addr) const +{ + gold_assert(r_type == elfcpp::R_AARCH64_TLSDESC); + uintptr_t intarg = reinterpret_cast<uintptr_t>(arg); + gold_assert(intarg < this->tlsdesc_reloc_info_.size()); + const Tlsdesc_info& ti(this->tlsdesc_reloc_info_[intarg]); + const Symbol_value<size>* psymval = ti.object->local_symbol(ti.r_sym); + gold_assert(psymval->is_tls_symbol()); + // The value of a TLS symbol is the offset in the TLS segment. + return psymval->value(ti.object, 0); +} + +// Return the number of entries in the PLT. + +template<int size, bool big_endian> +unsigned int +Target_aarch64<size, big_endian>::plt_entry_count() const +{ + if (this->plt_ == NULL) + return 0; + return this->plt_->entry_count(); +} + +// Return the offset of the first non-reserved PLT entry. + +template<int size, bool big_endian> +unsigned int +Target_aarch64<size, big_endian>::first_plt_entry_offset() const +{ + return this->plt_->first_plt_entry_offset(); +} + +// Return the size of each PLT entry. + +template<int size, bool big_endian> +unsigned int +Target_aarch64<size, big_endian>::plt_entry_size() const +{ + return this->plt_->get_plt_entry_size(); +} + +// Define the _TLS_MODULE_BASE_ symbol in the TLS segment. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::define_tls_base_symbol( + Symbol_table* symtab, Layout* layout) +{ + if (this->tls_base_symbol_defined_) + return; + + Output_segment* tls_segment = layout->tls_segment(); + if (tls_segment != NULL) + { + bool is_exec = parameters->options().output_is_executable(); + symtab->define_in_output_segment("_TLS_MODULE_BASE_", NULL, + Symbol_table::PREDEFINED, + tls_segment, 0, 0, + elfcpp::STT_TLS, + elfcpp::STB_LOCAL, + elfcpp::STV_HIDDEN, 0, + (is_exec + ? Symbol::SEGMENT_END + : Symbol::SEGMENT_START), + true); + } + this->tls_base_symbol_defined_ = true; +} + +// Create the reserved PLT and GOT entries for the TLS descriptor resolver. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::reserve_tlsdesc_entries( + Symbol_table* symtab, Layout* layout) +{ + if (this->plt_ == NULL) + this->make_plt_section(symtab, layout); + + if (!this->plt_->has_tlsdesc_entry()) + { + // Allocate the TLSDESC_GOT entry. + Output_data_got_aarch64<size, big_endian>* got = + this->got_section(symtab, layout); + unsigned int got_offset = got->add_constant(0); + + // Allocate the TLSDESC_PLT entry. + this->plt_->reserve_tlsdesc_entry(got_offset); + } +} + +// Create a GOT entry for the TLS module index. + +template<int size, bool big_endian> +unsigned int +Target_aarch64<size, big_endian>::got_mod_index_entry( + Symbol_table* symtab, Layout* layout, + Sized_relobj_file<size, big_endian>* object) +{ + if (this->got_mod_index_offset_ == -1U) + { + gold_assert(symtab != NULL && layout != NULL && object != NULL); + Reloc_section* rela_dyn = this->rela_dyn_section(layout); + Output_data_got_aarch64<size, big_endian>* got = + this->got_section(symtab, layout); + unsigned int got_offset = got->add_constant(0); + rela_dyn->add_local(object, 0, elfcpp::R_AARCH64_TLS_DTPMOD64, got, + got_offset, 0); + got->add_constant(0); + this->got_mod_index_offset_ = got_offset; + } + return this->got_mod_index_offset_; +} + +// Optimize the TLS relocation type based on what we know about the +// symbol. IS_FINAL is true if the final address of this symbol is +// known at link time. + +template<int size, bool big_endian> +tls::Tls_optimization +Target_aarch64<size, big_endian>::optimize_tls_reloc(bool is_final, + int r_type) +{ + // If we are generating a shared library, then we can't do anything + // in the linker + if (parameters->options().shared()) + return tls::TLSOPT_NONE; + + switch (r_type) + { + case elfcpp::R_AARCH64_TLSGD_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSGD_ADD_LO12_NC: + case elfcpp::R_AARCH64_TLSDESC_LD_PREL19: + case elfcpp::R_AARCH64_TLSDESC_ADR_PREL21: + case elfcpp::R_AARCH64_TLSDESC_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSDESC_LD64_LO12: + case elfcpp::R_AARCH64_TLSDESC_ADD_LO12: + case elfcpp::R_AARCH64_TLSDESC_OFF_G1: + case elfcpp::R_AARCH64_TLSDESC_OFF_G0_NC: + case elfcpp::R_AARCH64_TLSDESC_LDR: + case elfcpp::R_AARCH64_TLSDESC_ADD: + case elfcpp::R_AARCH64_TLSDESC_CALL: + // These are General-Dynamic which permits fully general TLS + // access. Since we know that we are generating an executable, + // we can convert this to Initial-Exec. If we also know that + // this is a local symbol, we can further switch to Local-Exec. + if (is_final) + return tls::TLSOPT_TO_LE; + return tls::TLSOPT_TO_IE; + + case elfcpp::R_AARCH64_TLSIE_MOVW_GOTTPREL_G1: + case elfcpp::R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC: + case elfcpp::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: + case elfcpp::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: + case elfcpp::R_AARCH64_TLSIE_LD_GOTTPREL_PREL19: + // These are Initial-Exec relocs which get the thread offset + // from the GOT. If we know that we are linking against the + // local symbol, we can switch to Local-Exec, which links the + // thread offset into the instruction. + if (is_final) + return tls::TLSOPT_TO_LE; + return tls::TLSOPT_NONE; + + case elfcpp::R_AARCH64_TLSLE_MOVW_TPREL_G2: + case elfcpp::R_AARCH64_TLSLE_MOVW_TPREL_G1: + case elfcpp::R_AARCH64_TLSLE_MOVW_TPREL_G1_NC: + case elfcpp::R_AARCH64_TLSLE_MOVW_TPREL_G0: + case elfcpp::R_AARCH64_TLSLE_MOVW_TPREL_G0_NC: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_HI12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: + // When we already have Local-Exec, there is nothing further we + // can do. + return tls::TLSOPT_NONE; + + default: + gold_unreachable(); + } +} + +// Returns true if this relocation type could be that of a function pointer. + +template<int size, bool big_endian> +inline bool +Target_aarch64<size, big_endian>::Scan::possible_function_pointer_reloc( + unsigned int r_type) +{ + switch (r_type) + { + case elfcpp::R_AARCH64_ABS64: + //TODO + { + return true; + } + } + return false; +} + +// For safe ICF, scan a relocation for a local symbol to check if it +// corresponds to a function pointer being taken. In that case mark +// the function whose pointer was taken as not foldable. + +template<int size, bool big_endian> +inline bool +Target_aarch64<size, big_endian>::Scan::local_reloc_may_be_function_pointer( + Symbol_table* , + Layout* , + Target_aarch64<size, big_endian>* , + Sized_relobj_file<size, big_endian>* , + unsigned int , + Output_section* , + const elfcpp::Rela<size, big_endian>& , + unsigned int r_type, + const elfcpp::Sym<size, big_endian>&) +{ + // When building a shared library, do not fold any local symbols as it is + // not possible to distinguish pointer taken versus a call by looking at + // the relocation types. + return (parameters->options().shared() + || possible_function_pointer_reloc(r_type)); +} + +// For safe ICF, scan a relocation for a global symbol to check if it +// corresponds to a function pointer being taken. In that case mark +// the function whose pointer was taken as not foldable. + +template<int size, bool big_endian> +inline bool +Target_aarch64<size, big_endian>::Scan::global_reloc_may_be_function_pointer( + Symbol_table* , + Layout* , + Target_aarch64<size, big_endian>* , + Sized_relobj_file<size, big_endian>* , + unsigned int , + Output_section* , + const elfcpp::Rela<size, big_endian>& , + unsigned int r_type, + Symbol* gsym) +{ + // When building a shared library, do not fold symbols whose visibility + // is hidden, internal or protected. + return ((parameters->options().shared() + && (gsym->visibility() == elfcpp::STV_INTERNAL + || gsym->visibility() == elfcpp::STV_PROTECTED + || gsym->visibility() == elfcpp::STV_HIDDEN)) + || possible_function_pointer_reloc(r_type)); +} + +// Report an unsupported relocation against a local symbol. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::Scan::unsupported_reloc_local( + Sized_relobj_file<size, big_endian>* object, + unsigned int r_type) +{ + gold_error(_("%s: unsupported reloc %u against local symbol"), + object->name().c_str(), r_type); +} + +// We are about to emit a dynamic relocation of type R_TYPE. If the +// dynamic linker does not support it, issue an error. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::Scan::check_non_pic(Relobj* object, + unsigned int r_type) +{ + gold_assert(r_type != elfcpp::R_AARCH64_NONE); + + switch (r_type) + { + // These are the relocation types supported by glibc for AARCH64. + case elfcpp::R_AARCH64_NONE: + case elfcpp::R_AARCH64_COPY: + case elfcpp::R_AARCH64_GLOB_DAT: + case elfcpp::R_AARCH64_JUMP_SLOT: + case elfcpp::R_AARCH64_RELATIVE: + case elfcpp::R_AARCH64_TLS_DTPREL64: + case elfcpp::R_AARCH64_TLS_DTPMOD64: + case elfcpp::R_AARCH64_TLS_TPREL64: + case elfcpp::R_AARCH64_TLSDESC: + case elfcpp::R_AARCH64_IRELATIVE: + case elfcpp::R_AARCH64_ABS32: + case elfcpp::R_AARCH64_ABS64: + return; + + default: + break; + } + + // This prevents us from issuing more than one error per reloc + // section. But we can still wind up issuing more than one + // error per object file. + if (this->issued_non_pic_error_) + return; + gold_assert(parameters->options().output_is_position_independent()); + object->error(_("requires unsupported dynamic reloc; " + "recompile with -fPIC")); + this->issued_non_pic_error_ = true; + return; +} + +// Scan a relocation for a local symbol. + +template<int size, bool big_endian> +inline void +Target_aarch64<size, big_endian>::Scan::local( + Symbol_table* symtab, + Layout* layout, + Target_aarch64<size, big_endian>* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>& rela, + unsigned int r_type, + const elfcpp::Sym<size, big_endian>& /* lsym */, + bool is_discarded) +{ + if (is_discarded) + return; + + typedef Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian> + Reloc_section; + Output_data_got_aarch64<size, big_endian>* got = + target->got_section(symtab, layout); + unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); + + switch (r_type) + { + case elfcpp::R_AARCH64_ABS32: + case elfcpp::R_AARCH64_ABS16: + if (parameters->options().output_is_position_independent()) + { + gold_error(_("%s: unsupported reloc %u in pos independent link."), + object->name().c_str(), r_type); + } + break; + + case elfcpp::R_AARCH64_ABS64: + // If building a shared library or pie, we need to mark this as a dynmic + // reloction, so that the dynamic loader can relocate it. + if (parameters->options().output_is_position_independent()) + { + Reloc_section* rela_dyn = target->rela_dyn_section(layout); + rela_dyn->add_local_relative(object, r_sym, + elfcpp::R_AARCH64_RELATIVE, + output_section, + data_shndx, + rela.get_r_offset(), + rela.get_r_addend(), + false /* is ifunc */); + } + break; + + case elfcpp::R_AARCH64_PREL64: + case elfcpp::R_AARCH64_PREL32: + case elfcpp::R_AARCH64_PREL16: + break; + + case elfcpp::R_AARCH64_LD_PREL_LO19: // 273 + case elfcpp::R_AARCH64_ADR_PREL_LO21: // 274 + case elfcpp::R_AARCH64_ADR_PREL_PG_HI21: // 275 + case elfcpp::R_AARCH64_ADR_PREL_PG_HI21_NC: // 276 + case elfcpp::R_AARCH64_ADD_ABS_LO12_NC: // 277 + case elfcpp::R_AARCH64_LDST8_ABS_LO12_NC: // 278 + case elfcpp::R_AARCH64_LDST16_ABS_LO12_NC: // 284 + case elfcpp::R_AARCH64_LDST32_ABS_LO12_NC: // 285 + case elfcpp::R_AARCH64_LDST64_ABS_LO12_NC: // 286 + case elfcpp::R_AARCH64_LDST128_ABS_LO12_NC: // 299 + break; + + // Control flow, pc-relative. We don't need to do anything for a relative + // addressing relocation against a local symbol if it does not reference + // the GOT. + case elfcpp::R_AARCH64_TSTBR14: + case elfcpp::R_AARCH64_CONDBR19: + case elfcpp::R_AARCH64_JUMP26: + case elfcpp::R_AARCH64_CALL26: + break; + + case elfcpp::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: + case elfcpp::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: + { + tls::Tls_optimization tlsopt = Target_aarch64<size, big_endian>:: + optimize_tls_reloc(!parameters->options().shared(), r_type); + if (tlsopt == tls::TLSOPT_TO_LE) + break; + + layout->set_has_static_tls(); + // Create a GOT entry for the tp-relative offset. + if (!parameters->doing_static_link()) + { + got->add_local_with_rel(object, r_sym, GOT_TYPE_TLS_OFFSET, + target->rela_dyn_section(layout), + elfcpp::R_AARCH64_TLS_TPREL64); + } + else if (!object->local_has_got_offset(r_sym, + GOT_TYPE_TLS_OFFSET)) + { + got->add_local(object, r_sym, GOT_TYPE_TLS_OFFSET); + unsigned int got_offset = + object->local_got_offset(r_sym, GOT_TYPE_TLS_OFFSET); + const elfcpp::Elf_Xword addend = rela.get_r_addend(); + gold_assert(addend == 0); + got->add_static_reloc(got_offset, elfcpp::R_AARCH64_TLS_TPREL64, + object, r_sym); + } + } + break; + + case elfcpp::R_AARCH64_TLSGD_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSGD_ADD_LO12_NC: + { + tls::Tls_optimization tlsopt = Target_aarch64<size, big_endian>:: + optimize_tls_reloc(!parameters->options().shared(), r_type); + if (tlsopt == tls::TLSOPT_TO_LE) + { + layout->set_has_static_tls(); + break; + } + gold_assert(tlsopt == tls::TLSOPT_NONE); + + got->add_local_pair_with_rel(object,r_sym, data_shndx, + GOT_TYPE_TLS_PAIR, + target->rela_dyn_section(layout), + elfcpp::R_AARCH64_TLS_DTPMOD64); + } + break; + + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_HI12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: + { + layout->set_has_static_tls(); + bool output_is_shared = parameters->options().shared(); + if (output_is_shared) + gold_error(_("%s: unsupported TLSLE reloc %u in shared code."), + object->name().c_str(), r_type); + } + break; + + case elfcpp::R_AARCH64_TLSDESC_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSDESC_LD64_LO12: + case elfcpp::R_AARCH64_TLSDESC_ADD_LO12: + { + tls::Tls_optimization tlsopt = Target_aarch64<size, big_endian>:: + optimize_tls_reloc(!parameters->options().shared(), r_type); + target->define_tls_base_symbol(symtab, layout); + if (tlsopt == tls::TLSOPT_NONE) + { + // Create reserved PLT and GOT entries for the resolver. + target->reserve_tlsdesc_entries(symtab, layout); + + // Generate a double GOT entry with an R_AARCH64_TLSDESC reloc. + // The R_AARCH64_TLSDESC reloc is resolved lazily, so the GOT + // entry needs to be in an area in .got.plt, not .got. Call + // got_section to make sure the section has been created. + target->got_section(symtab, layout); + Output_data_got<size, big_endian>* got = + target->got_tlsdesc_section(); + unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); + if (!object->local_has_got_offset(r_sym, GOT_TYPE_TLS_DESC)) + { + unsigned int got_offset = got->add_constant(0); + got->add_constant(0); + object->set_local_got_offset(r_sym, GOT_TYPE_TLS_DESC, + got_offset); + Reloc_section* rt = target->rela_tlsdesc_section(layout); + // We store the arguments we need in a vector, and use + // the index into the vector as the parameter to pass + // to the target specific routines. + uintptr_t intarg = target->add_tlsdesc_info(object, r_sym); + void* arg = reinterpret_cast<void*>(intarg); + rt->add_target_specific(elfcpp::R_AARCH64_TLSDESC, arg, + got, got_offset, 0); + } + } + else if (tlsopt != tls::TLSOPT_TO_LE) + unsupported_reloc_local(object, r_type); + } + break; + + case elfcpp::R_AARCH64_TLSDESC_CALL: + break; + + default: + unsupported_reloc_local(object, r_type); + } +} + + +// Report an unsupported relocation against a global symbol. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::Scan::unsupported_reloc_global( + Sized_relobj_file<size, big_endian>* object, + unsigned int r_type, + Symbol* gsym) +{ + gold_error(_("%s: unsupported reloc %u against global symbol %s"), + object->name().c_str(), r_type, gsym->demangled_name().c_str()); +} + +template<int size, bool big_endian> +inline void +Target_aarch64<size, big_endian>::Scan::global( + Symbol_table* symtab, + Layout* layout, + Target_aarch64<size, big_endian>* target, + Sized_relobj_file<size, big_endian> * object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>& rela, + unsigned int r_type, + Symbol* gsym) +{ + typedef Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian> + Reloc_section; + const AArch64_reloc_property* arp = + aarch64_reloc_property_table->get_reloc_property(r_type); + gold_assert(arp != NULL); + + switch (r_type) + { + case elfcpp::R_AARCH64_ABS16: + case elfcpp::R_AARCH64_ABS32: + case elfcpp::R_AARCH64_ABS64: + { + // Make a PLT entry if necessary. + if (gsym->needs_plt_entry()) + { + target->make_plt_entry(symtab, layout, gsym); + // Since this is not a PC-relative relocation, we may be + // taking the address of a function. In that case we need to + // set the entry in the dynamic symbol table to the address of + // the PLT entry. + if (gsym->is_from_dynobj() && !parameters->options().shared()) + gsym->set_needs_dynsym_value(); + } + // Make a dynamic relocation if necessary. + if (gsym->needs_dynamic_reloc(arp->reference_flags())) + { + if (!parameters->options().output_is_position_independent() + && gsym->may_need_copy_reloc()) + { + target->copy_reloc(symtab, layout, object, + data_shndx, output_section, gsym, rela); + } + else if (r_type == elfcpp::R_AARCH64_ABS64 + && gsym->can_use_relative_reloc(false)) + { + Reloc_section* rela_dyn = target->rela_dyn_section(layout); + rela_dyn->add_global_relative(gsym, + elfcpp::R_AARCH64_RELATIVE, + output_section, + object, + data_shndx, + rela.get_r_offset(), + rela.get_r_addend(), + false); + } + else + { + check_non_pic(object, r_type); + Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian>* + rela_dyn = target->rela_dyn_section(layout); + rela_dyn->add_global( + gsym, r_type, output_section, object, + data_shndx, rela.get_r_offset(),rela.get_r_addend()); + } + } + } + break; + + case elfcpp::R_AARCH64_PREL16: + case elfcpp::R_AARCH64_PREL32: + case elfcpp::R_AARCH64_PREL64: + // This is used to fill the GOT absolute address. + if (gsym->needs_plt_entry()) + { + target->make_plt_entry(symtab, layout, gsym); + } + break; + + case elfcpp::R_AARCH64_LD_PREL_LO19: // 273 + case elfcpp::R_AARCH64_ADR_PREL_LO21: // 274 + case elfcpp::R_AARCH64_ADR_PREL_PG_HI21: // 275 + case elfcpp::R_AARCH64_ADR_PREL_PG_HI21_NC: // 276 + case elfcpp::R_AARCH64_ADD_ABS_LO12_NC: // 277 + case elfcpp::R_AARCH64_LDST8_ABS_LO12_NC: // 278 + case elfcpp::R_AARCH64_LDST16_ABS_LO12_NC: // 284 + case elfcpp::R_AARCH64_LDST32_ABS_LO12_NC: // 285 + case elfcpp::R_AARCH64_LDST64_ABS_LO12_NC: // 286 + case elfcpp::R_AARCH64_LDST128_ABS_LO12_NC: // 299 + { + if (gsym->needs_plt_entry()) + target->make_plt_entry(symtab, layout, gsym); + // Make a dynamic relocation if necessary. + if (gsym->needs_dynamic_reloc(arp->reference_flags())) + { + if (parameters->options().output_is_executable() + && gsym->may_need_copy_reloc()) + { + target->copy_reloc(symtab, layout, object, + data_shndx, output_section, gsym, rela); + } + } + break; + } + + case elfcpp::R_AARCH64_ADR_GOT_PAGE: + case elfcpp::R_AARCH64_LD64_GOT_LO12_NC: + { + // This pair of relocations is used to access a specific GOT entry. + // Note a GOT entry is an *address* to a symbol. + // The symbol requires a GOT entry + Output_data_got_aarch64<size, big_endian>* got = + target->got_section(symtab, layout); + if (gsym->final_value_is_known()) + { + got->add_global(gsym, GOT_TYPE_STANDARD); + } + else + { + Reloc_section* rela_dyn = target->rela_dyn_section(layout); + if (gsym->is_from_dynobj() + || gsym->is_undefined() + || gsym->is_preemptible() + || (gsym->visibility() == elfcpp::STV_PROTECTED + && parameters->options().shared())) + got->add_global_with_rel(gsym, GOT_TYPE_STANDARD, + rela_dyn, elfcpp::R_AARCH64_GLOB_DAT); + else + { + if (got->add_global(gsym, GOT_TYPE_STANDARD)) + { + rela_dyn->add_global_relative( + gsym, elfcpp::R_AARCH64_RELATIVE, + got, + gsym->got_offset(GOT_TYPE_STANDARD), + 0, + false); + } + } + } + break; + } + + case elfcpp::R_AARCH64_TSTBR14: + case elfcpp::R_AARCH64_CONDBR19: + case elfcpp::R_AARCH64_JUMP26: + case elfcpp::R_AARCH64_CALL26: + { + if (gsym->final_value_is_known()) + break; + + if (gsym->is_defined() && + !gsym->is_from_dynobj() && + !gsym->is_preemptible()) + break; + + // Make plt entry for function call. + target->make_plt_entry(symtab, layout, gsym); + break; + } + + case elfcpp::R_AARCH64_TLSGD_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSGD_ADD_LO12_NC: // General dynamic + { + tls::Tls_optimization tlsopt = Target_aarch64<size, big_endian>:: + optimize_tls_reloc(gsym->final_value_is_known(), r_type); + if (tlsopt == tls::TLSOPT_TO_LE) + { + layout->set_has_static_tls(); + break; + } + gold_assert(tlsopt == tls::TLSOPT_NONE); + + // General dynamic. + Output_data_got_aarch64<size, big_endian>* got = + target->got_section(symtab, layout); + // Create 2 consecutive entries for module index and offset. + got->add_global_pair_with_rel(gsym, GOT_TYPE_TLS_PAIR, + target->rela_dyn_section(layout), + elfcpp::R_AARCH64_TLS_DTPMOD64, + elfcpp::R_AARCH64_TLS_DTPREL64); + } + break; + + case elfcpp::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: + case elfcpp::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: // Initial executable + { + tls::Tls_optimization tlsopt =Target_aarch64<size, big_endian>:: + optimize_tls_reloc(gsym->final_value_is_known(), r_type); + if (tlsopt == tls::TLSOPT_TO_LE) + break; + + layout->set_has_static_tls(); + // Create a GOT entry for the tp-relative offset. + Output_data_got_aarch64<size, big_endian>* got + = target->got_section(symtab, layout); + if (!parameters->doing_static_link()) + { + got->add_global_with_rel( + gsym, GOT_TYPE_TLS_OFFSET, + target->rela_dyn_section(layout), + elfcpp::R_AARCH64_TLS_TPREL64); + } + if (!gsym->has_got_offset(GOT_TYPE_TLS_OFFSET)) + { + got->add_global(gsym, GOT_TYPE_TLS_OFFSET); + unsigned int got_offset = + gsym->got_offset(GOT_TYPE_TLS_OFFSET); + const elfcpp::Elf_Xword addend = rela.get_r_addend(); + gold_assert(addend == 0); + got->add_static_reloc(got_offset, + elfcpp::R_AARCH64_TLS_TPREL64, gsym); + } + } + break; + + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_HI12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: // Local executable + layout->set_has_static_tls(); + if (parameters->options().shared()) + gold_error(_("%s: unsupported TLSLE reloc type %u in shared objects."), + object->name().c_str(), r_type); + break; + + case elfcpp::R_AARCH64_TLSDESC_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSDESC_LD64_LO12: + case elfcpp::R_AARCH64_TLSDESC_ADD_LO12: // TLS descriptor + { + target->define_tls_base_symbol(symtab, layout); + tls::Tls_optimization tlsopt = Target_aarch64<size, big_endian>:: + optimize_tls_reloc(gsym->final_value_is_known(), r_type); + if (tlsopt == tls::TLSOPT_NONE) + { + // Create reserved PLT and GOT entries for the resolver. + target->reserve_tlsdesc_entries(symtab, layout); + + // Create a double GOT entry with an R_AARCH64_TLSDESC + // relocation. The R_AARCH64_TLSDESC is resolved lazily, so the GOT + // entry needs to be in an area in .got.plt, not .got. Call + // got_section to make sure the section has been created. + target->got_section(symtab, layout); + Output_data_got<size, big_endian>* got = + target->got_tlsdesc_section(); + Reloc_section* rt = target->rela_tlsdesc_section(layout); + got->add_global_pair_with_rel(gsym, GOT_TYPE_TLS_DESC, rt, + elfcpp::R_AARCH64_TLSDESC, 0); + } + else if (tlsopt == tls::TLSOPT_TO_IE) + { + // Create a GOT entry for the tp-relative offset. + Output_data_got<size, big_endian>* got + = target->got_section(symtab, layout); + got->add_global_with_rel(gsym, GOT_TYPE_TLS_OFFSET, + target->rela_dyn_section(layout), + elfcpp::R_AARCH64_TLS_TPREL64); + } + else if (tlsopt != tls::TLSOPT_TO_LE) + unsupported_reloc_global(object, r_type, gsym); + } + break; + + case elfcpp::R_AARCH64_TLSDESC_CALL: + break; + + default: + gold_error(_("%s: unsupported reloc type in global scan"), + aarch64_reloc_property_table-> + reloc_name_in_error_message(r_type).c_str()); + } + return; +} // End of Scan::global + + +// Create the PLT section. +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::make_plt_section( + Symbol_table* symtab, Layout* layout) +{ + if (this->plt_ == NULL) + { + // Create the GOT section first. + this->got_section(symtab, layout); + + this->plt_ = this->make_data_plt(layout, this->got_, this->got_plt_, + this->got_irelative_); + + layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC + | elfcpp::SHF_EXECINSTR), + this->plt_, ORDER_PLT, false); + + // Make the sh_info field of .rela.plt point to .plt. + Output_section* rela_plt_os = this->plt_->rela_plt()->output_section(); + rela_plt_os->set_info_section(this->plt_->output_section()); + } +} + +// Return the section for TLSDESC relocations. + +template<int size, bool big_endian> +typename Target_aarch64<size, big_endian>::Reloc_section* +Target_aarch64<size, big_endian>::rela_tlsdesc_section(Layout* layout) const +{ + return this->plt_section()->rela_tlsdesc(layout); +} + +// Create a PLT entry for a global symbol. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::make_plt_entry( + Symbol_table* symtab, + Layout* layout, + Symbol* gsym) +{ + if (gsym->has_plt_offset()) + return; + + if (this->plt_ == NULL) + this->make_plt_section(symtab, layout); + + this->plt_->add_entry(gsym); +} + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::gc_process_relocs( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols) +{ + if (sh_type == elfcpp::SHT_REL) + { + return; + } + + gold::gc_process_relocs< + size, big_endian, + Target_aarch64<size, big_endian>, + elfcpp::SHT_RELA, + typename Target_aarch64<size, big_endian>::Scan, + typename Target_aarch64<size, big_endian>::Relocatable_size_for_reloc>( + symtab, + layout, + this, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols); +} + +// Scan relocations for a section. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::scan_relocs( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols) +{ + if (sh_type == elfcpp::SHT_REL) + { + gold_error(_("%s: unsupported REL reloc section"), + object->name().c_str()); + return; + } + gold::scan_relocs<size, big_endian, Target_aarch64, elfcpp::SHT_RELA, Scan>( + symtab, + layout, + this, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols); +} + +// Return the value to use for a dynamic which requires special +// treatment. This is how we support equality comparisons of function +// pointers across shared library boundaries, as described in the +// processor specific ABI supplement. + +template<int size,bool big_endian> +uint64_t +Target_aarch64<size,big_endian>::do_dynsym_value(const Symbol* gsym) const +{ + gold_assert(gsym->is_from_dynobj() && gsym->has_plt_offset()); + return this->plt_address_for_global(gsym); +} + +// Finalize the sections. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::do_finalize_sections( + Layout* layout, + const Input_objects*, + Symbol_table* symtab) +{ + const Reloc_section* rel_plt = (this->plt_ == NULL + ? NULL + : this->plt_->rela_plt()); + layout->add_target_dynamic_tags(false, this->got_plt_, rel_plt, + this->rela_dyn_, true, false); + + // Emit any relocs we saved in an attempt to avoid generating COPY + // relocs. + if (this->copy_relocs_.any_saved_relocs()) + this->copy_relocs_.emit(this->rela_dyn_section(layout)); + + // Fill in some more dynamic tags. + Output_data_dynamic* const odyn = layout->dynamic_data(); + if (odyn != NULL) + { + if (this->plt_ != NULL + && this->plt_->output_section() != NULL + && this->plt_ ->has_tlsdesc_entry()) + { + unsigned int plt_offset = this->plt_->get_tlsdesc_plt_offset(); + unsigned int got_offset = this->plt_->get_tlsdesc_got_offset(); + this->got_->finalize_data_size(); + odyn->add_section_plus_offset(elfcpp::DT_TLSDESC_PLT, + this->plt_, plt_offset); + odyn->add_section_plus_offset(elfcpp::DT_TLSDESC_GOT, + this->got_, got_offset); + } + } + + // Set the size of the _GLOBAL_OFFSET_TABLE_ symbol to the size of + // the .got.plt section. + Symbol* sym = this->global_offset_table_; + if (sym != NULL) + { + uint64_t data_size = this->got_plt_->current_data_size(); + symtab->get_sized_symbol<size>(sym)->set_symsize(data_size); + + // If the .got section is more than 0x8000 bytes, we add + // 0x8000 to the value of _GLOBAL_OFFSET_TABLE_, so that 16 + // bit relocations have a greater chance of working. + if (data_size >= 0x8000) + symtab->get_sized_symbol<size>(sym)->set_value( + symtab->get_sized_symbol<size>(sym)->value() + 0x8000); + } + + if (parameters->doing_static_link() + && (this->plt_ == NULL || !this->plt_->has_irelative_section())) + { + // If linking statically, make sure that the __rela_iplt symbols + // were defined if necessary, even if we didn't create a PLT. + static const Define_symbol_in_segment syms[] = + { + { + "__rela_iplt_start", // name + elfcpp::PT_LOAD, // segment_type + elfcpp::PF_W, // segment_flags_set + elfcpp::PF(0), // segment_flags_clear + 0, // value + 0, // size + elfcpp::STT_NOTYPE, // type + elfcpp::STB_GLOBAL, // binding + elfcpp::STV_HIDDEN, // visibility + 0, // nonvis + Symbol::SEGMENT_START, // offset_from_base + true // only_if_ref + }, + { + "__rela_iplt_end", // name + elfcpp::PT_LOAD, // segment_type + elfcpp::PF_W, // segment_flags_set + elfcpp::PF(0), // segment_flags_clear + 0, // value + 0, // size + elfcpp::STT_NOTYPE, // type + elfcpp::STB_GLOBAL, // binding + elfcpp::STV_HIDDEN, // visibility + 0, // nonvis + Symbol::SEGMENT_START, // offset_from_base + true // only_if_ref + } + }; + + symtab->define_symbols(layout, 2, syms, + layout->script_options()->saw_sections_clause()); + } + + return; +} + +// Perform a relocation. + +template<int size, bool big_endian> +inline bool +Target_aarch64<size, big_endian>::Relocate::relocate( + const Relocate_info<size, big_endian>* relinfo, + Target_aarch64<size, big_endian>* target, + Output_section* , + size_t relnum, + const elfcpp::Rela<size, big_endian>& rela, + unsigned int r_type, + const Sized_symbol<size>* gsym, + const Symbol_value<size>* psymval, + unsigned char* view, + typename elfcpp::Elf_types<size>::Elf_Addr address, + section_size_type /* view_size */) +{ + if (view == NULL) + return true; + + typedef AArch64_relocate_functions<size, big_endian> Reloc; + + const AArch64_reloc_property* reloc_property = + aarch64_reloc_property_table->get_reloc_property(r_type); + + if (reloc_property == NULL) + { + std::string reloc_name = + aarch64_reloc_property_table->reloc_name_in_error_message(r_type); + gold_error_at_location(relinfo, relnum, rela.get_r_offset(), + _("cannot relocate %s in object file"), + reloc_name.c_str()); + return true; + } + + const Sized_relobj_file<size, big_endian>* object = relinfo->object; + + // Pick the value to use for symbols defined in the PLT. + Symbol_value<size> symval; + if (gsym != NULL + && gsym->use_plt_offset(reloc_property->reference_flags())) + { + symval.set_output_value(target->plt_address_for_global(gsym)); + psymval = &symval; + } + else if (gsym == NULL && psymval->is_ifunc_symbol()) + { + unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); + if (object->local_has_plt_offset(r_sym)) + { + symval.set_output_value(target->plt_address_for_local(object, r_sym)); + psymval = &symval; + } + } + + const elfcpp::Elf_Xword addend = rela.get_r_addend(); + + // Get the GOT offset if needed. + // For aarch64, the GOT pointer points to the start of the GOT section. + bool have_got_offset = false; + int got_offset = 0; + int got_base = (target->got_ != NULL + ? (target->got_->current_data_size() >= 0x8000 + ? 0x8000 : 0) + : 0); + switch (r_type) + { + case elfcpp::R_AARCH64_MOVW_GOTOFF_G0: + case elfcpp::R_AARCH64_MOVW_GOTOFF_G0_NC: + case elfcpp::R_AARCH64_MOVW_GOTOFF_G1: + case elfcpp::R_AARCH64_MOVW_GOTOFF_G1_NC: + case elfcpp::R_AARCH64_MOVW_GOTOFF_G2: + case elfcpp::R_AARCH64_MOVW_GOTOFF_G2_NC: + case elfcpp::R_AARCH64_MOVW_GOTOFF_G3: + case elfcpp::R_AARCH64_GOTREL64: + case elfcpp::R_AARCH64_GOTREL32: + case elfcpp::R_AARCH64_GOT_LD_PREL19: + case elfcpp::R_AARCH64_LD64_GOTOFF_LO15: + case elfcpp::R_AARCH64_ADR_GOT_PAGE: + case elfcpp::R_AARCH64_LD64_GOT_LO12_NC: + case elfcpp::R_AARCH64_LD64_GOTPAGE_LO15: + if (gsym != NULL) + { + gold_assert(gsym->has_got_offset(GOT_TYPE_STANDARD)); + got_offset = gsym->got_offset(GOT_TYPE_STANDARD) - got_base; + } + else + { + unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); + gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_STANDARD)); + got_offset = (object->local_got_offset(r_sym, GOT_TYPE_STANDARD) + - got_base); + } + have_got_offset = true; + break; + + default: + break; + } + + typename Reloc::Status reloc_status = Reloc::STATUS_OKAY; + typename elfcpp::Elf_types<size>::Elf_Addr value; + switch (r_type) + { + case elfcpp::R_AARCH64_NONE: + break; + + case elfcpp::R_AARCH64_ABS64: + reloc_status = Reloc::template rela_ua<64>( + view, object, psymval, addend, reloc_property); + break; + + case elfcpp::R_AARCH64_ABS32: + reloc_status = Reloc::template rela_ua<32>( + view, object, psymval, addend, reloc_property); + break; + + case elfcpp::R_AARCH64_ABS16: + reloc_status = Reloc::template rela_ua<16>( + view, object, psymval, addend, reloc_property); + break; + + case elfcpp::R_AARCH64_PREL64: + reloc_status = Reloc::template pcrela_ua<64>( + view, object, psymval, addend, address, reloc_property); + + case elfcpp::R_AARCH64_PREL32: + reloc_status = Reloc::template pcrela_ua<32>( + view, object, psymval, addend, address, reloc_property); + + case elfcpp::R_AARCH64_PREL16: + reloc_status = Reloc::template pcrela_ua<16>( + view, object, psymval, addend, address, reloc_property); + + case elfcpp::R_AARCH64_ADR_PREL_PG_HI21_NC: + case elfcpp::R_AARCH64_ADR_PREL_PG_HI21: + reloc_status = Reloc::adrp(view, object, psymval, addend, address, + reloc_property); + break; + + case elfcpp::R_AARCH64_LDST8_ABS_LO12_NC: + case elfcpp::R_AARCH64_LDST16_ABS_LO12_NC: + case elfcpp::R_AARCH64_LDST32_ABS_LO12_NC: + case elfcpp::R_AARCH64_LDST64_ABS_LO12_NC: + case elfcpp::R_AARCH64_LDST128_ABS_LO12_NC: + case elfcpp::R_AARCH64_ADD_ABS_LO12_NC: + reloc_status = Reloc::template rela_general<32>( + view, object, psymval, addend, reloc_property); + break; + + case elfcpp::R_AARCH64_CALL26: + if (this->skip_call_tls_get_addr_) + { + // Double check that the TLSGD insn has been optimized away. + typedef typename elfcpp::Swap<32, big_endian>::Valtype Insntype; + Insntype insn = elfcpp::Swap<32, big_endian>::readval( + reinterpret_cast<Insntype*>(view)); + gold_assert((insn & 0xff000000) == 0x91000000); + + reloc_status = Reloc::STATUS_OKAY; + this->skip_call_tls_get_addr_ = false; + // Return false to stop further processing this reloc. + return false; + } + // Continue. + case elfcpp::R_AARCH64_TSTBR14: + case elfcpp::R_AARCH64_CONDBR19: + case elfcpp::R_AARCH64_JUMP26: + reloc_status = Reloc::template pcrela_general<32>( + view, object, psymval, addend, address, reloc_property); + break; + + case elfcpp::R_AARCH64_ADR_GOT_PAGE: + gold_assert(have_got_offset); + value = target->got_->address() + got_base + got_offset; + reloc_status = Reloc::adrp(view, value + addend, address); + break; + + case elfcpp::R_AARCH64_LD64_GOT_LO12_NC: + gold_assert(have_got_offset); + value = target->got_->address() + got_base + got_offset; + reloc_status = Reloc::template rela_general<32>( + view, value, addend, reloc_property); + break; + + case elfcpp::R_AARCH64_TLSGD_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSGD_ADD_LO12_NC: + case elfcpp::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: + case elfcpp::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_HI12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: + case elfcpp::R_AARCH64_TLSDESC_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSDESC_LD64_LO12: + case elfcpp::R_AARCH64_TLSDESC_ADD_LO12: + case elfcpp::R_AARCH64_TLSDESC_CALL: + reloc_status = relocate_tls(relinfo, target, relnum, rela, r_type, + gsym, psymval, view, address); + break; + + // These are dynamic relocations, which are unexpected when linking. + case elfcpp::R_AARCH64_COPY: + case elfcpp::R_AARCH64_GLOB_DAT: + case elfcpp::R_AARCH64_JUMP_SLOT: + case elfcpp::R_AARCH64_RELATIVE: + case elfcpp::R_AARCH64_IRELATIVE: + case elfcpp::R_AARCH64_TLS_DTPREL64: + case elfcpp::R_AARCH64_TLS_DTPMOD64: + case elfcpp::R_AARCH64_TLS_TPREL64: + case elfcpp::R_AARCH64_TLSDESC: + gold_error_at_location(relinfo, relnum, rela.get_r_offset(), + _("unexpected reloc %u in object file"), + r_type); + break; + + default: + gold_error_at_location(relinfo, relnum, rela.get_r_offset(), + _("unsupported reloc %s"), + reloc_property->name().c_str()); + break; + } + + // Report any errors. + switch (reloc_status) + { + case Reloc::STATUS_OKAY: + break; + case Reloc::STATUS_OVERFLOW: + gold_error_at_location(relinfo, relnum, rela.get_r_offset(), + _("relocation overflow in %s"), + reloc_property->name().c_str()); + break; + case Reloc::STATUS_BAD_RELOC: + gold_error_at_location( + relinfo, + relnum, + rela.get_r_offset(), + _("unexpected opcode while processing relocation %s"), + reloc_property->name().c_str()); + break; + default: + gold_unreachable(); + } + + return true; +} + + +template<int size, bool big_endian> +inline +typename AArch64_relocate_functions<size,big_endian>::Status +Target_aarch64<size, big_endian>::Relocate::relocate_tls( + const Relocate_info<size,big_endian>* relinfo, + Target_aarch64<size, big_endian>* target, + size_t relnum, + const elfcpp::Rela<size, big_endian>& rela, + unsigned int r_type, const Sized_symbol<size>* gsym, + const Symbol_value<size>* psymval, + unsigned char* view, + typename elfcpp::Elf_types<size>::Elf_Addr address) +{ + typedef AArch64_relocate_functions<size,big_endian> aarch64_reloc_funcs; + typedef typename elfcpp::Elf_types<size>::Elf_Addr AArch64_address; + + Output_segment* tls_segment = relinfo->layout->tls_segment(); + const elfcpp::Elf_Xword addend = rela.get_r_addend(); + const AArch64_reloc_property* reloc_property = + aarch64_reloc_property_table->get_reloc_property(r_type); + gold_assert(reloc_property != NULL); + + const bool is_final = (gsym == NULL + ? !parameters->options().shared() + : gsym->final_value_is_known()); + tls::Tls_optimization tlsopt = Target_aarch64<size, big_endian>:: + optimize_tls_reloc(is_final, r_type); + + Sized_relobj_file<size,big_endian>* object = relinfo->object; + int tls_got_offset_type; + switch (r_type) + { + case elfcpp::R_AARCH64_TLSGD_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSGD_ADD_LO12_NC: // Global-dynamic + { + if (tlsopt == tls::TLSOPT_TO_LE) + { + if (tls_segment == NULL) + { + gold_assert(parameters->errors()->error_count() > 0 + || issue_undefined_symbol_error(gsym)); + return aarch64_reloc_funcs::STATUS_BAD_RELOC; + } + return tls_gd_to_le(relinfo, target, rela, r_type, view, + psymval); + } + else if (tlsopt == tls::TLSOPT_NONE) + { + tls_got_offset_type = GOT_TYPE_TLS_PAIR; + // Firstly get the address for the got entry. + typename elfcpp::Elf_types<size>::Elf_Addr got_entry_address; + if (gsym != NULL) + { + gold_assert(gsym->has_got_offset(tls_got_offset_type)); + got_entry_address = target->got_->address() + + gsym->got_offset(tls_got_offset_type); + } + else + { + unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); + gold_assert( + object->local_has_got_offset(r_sym, tls_got_offset_type)); + got_entry_address = target->got_->address() + + object->local_got_offset(r_sym, tls_got_offset_type); + } + + // Relocate the address into adrp/ld, adrp/add pair. + switch (r_type) + { + case elfcpp::R_AARCH64_TLSGD_ADR_PAGE21: + return aarch64_reloc_funcs::adrp( + view, got_entry_address + addend, address); + + break; + + case elfcpp::R_AARCH64_TLSGD_ADD_LO12_NC: + return aarch64_reloc_funcs::template rela_general<32>( + view, got_entry_address, addend, reloc_property); + break; + + default: + gold_assert(false); + } + } + gold_error_at_location(relinfo, relnum, rela.get_r_offset(), + _("unsupported gd_to_ie relaxation on %u"), + r_type); + } + break; + + case elfcpp::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: + case elfcpp::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: // Initial-exec + { + if (tlsopt == tls::TLSOPT_TO_LE) + { + if (tls_segment == NULL) + { + gold_assert(parameters->errors()->error_count() > 0 + || issue_undefined_symbol_error(gsym)); + return aarch64_reloc_funcs::STATUS_BAD_RELOC; + } + return tls_ie_to_le(relinfo, target, rela, r_type, view, + psymval); + } + tls_got_offset_type = GOT_TYPE_TLS_OFFSET; + + // Firstly get the address for the got entry. + typename elfcpp::Elf_types<size>::Elf_Addr got_entry_address; + if (gsym != NULL) + { + gold_assert(gsym->has_got_offset(tls_got_offset_type)); + got_entry_address = target->got_->address() + + gsym->got_offset(tls_got_offset_type); + } + else + { + unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); + gold_assert( + object->local_has_got_offset(r_sym, tls_got_offset_type)); + got_entry_address = target->got_->address() + + object->local_got_offset(r_sym, tls_got_offset_type); + } + // Relocate the address into adrp/ld, adrp/add pair. + switch (r_type) + { + case elfcpp::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: + return aarch64_reloc_funcs::adrp(view, got_entry_address + addend, + address); + break; + case elfcpp::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: + return aarch64_reloc_funcs::template rela_general<32>( + view, got_entry_address, addend, reloc_property); + default: + gold_assert(false); + } + } + // We shall never reach here. + break; + + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_HI12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12: + case elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: + { + gold_assert(tls_segment != NULL); + AArch64_address value = psymval->value(object, 0); + + if (!parameters->options().shared()) + { + AArch64_address aligned_tcb_size = + align_address(target->tcb_size(), + tls_segment->maximum_alignment()); + return aarch64_reloc_funcs::template + rela_general<32>(view, + value + aligned_tcb_size, + addend, + reloc_property); + } + else + gold_error(_("%s: unsupported reloc %u " + "in non-static TLSLE mode."), + object->name().c_str(), r_type); + } + break; + + case elfcpp::R_AARCH64_TLSDESC_ADR_PAGE21: + case elfcpp::R_AARCH64_TLSDESC_LD64_LO12: + case elfcpp::R_AARCH64_TLSDESC_ADD_LO12: + case elfcpp::R_AARCH64_TLSDESC_CALL: + { + if (tlsopt == tls::TLSOPT_TO_LE) + { + if (tls_segment == NULL) + { + gold_assert(parameters->errors()->error_count() > 0 + || issue_undefined_symbol_error(gsym)); + return aarch64_reloc_funcs::STATUS_BAD_RELOC; + } + return tls_desc_gd_to_le(relinfo, target, rela, r_type, + view, psymval); + } + else + { + tls_got_offset_type = (tlsopt == tls::TLSOPT_TO_IE + ? GOT_TYPE_TLS_OFFSET + : GOT_TYPE_TLS_DESC); + unsigned int got_tlsdesc_offset = 0; + if (r_type != elfcpp::R_AARCH64_TLSDESC_CALL + && tlsopt == tls::TLSOPT_NONE) + { + // We created GOT entries in the .got.tlsdesc portion of the + // .got.plt section, but the offset stored in the symbol is the + // offset within .got.tlsdesc. + got_tlsdesc_offset = (target->got_->data_size() + + target->got_plt_section()->data_size()); + } + typename elfcpp::Elf_types<size>::Elf_Addr got_entry_address; + if (gsym != NULL) + { + gold_assert(gsym->has_got_offset(tls_got_offset_type)); + got_entry_address = target->got_->address() + + got_tlsdesc_offset + + gsym->got_offset(tls_got_offset_type); + } + else + { + unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); + gold_assert( + object->local_has_got_offset(r_sym, tls_got_offset_type)); + got_entry_address = target->got_->address() + + got_tlsdesc_offset + + object->local_got_offset(r_sym, tls_got_offset_type); + } + if (tlsopt == tls::TLSOPT_TO_IE) + { + if (tls_segment == NULL) + { + gold_assert(parameters->errors()->error_count() > 0 + || issue_undefined_symbol_error(gsym)); + return aarch64_reloc_funcs::STATUS_BAD_RELOC; + } + return tls_desc_gd_to_ie(relinfo, target, rela, r_type, + view, psymval, got_entry_address, + address); + } + + // Now do tlsdesc relocation. + switch (r_type) + { + case elfcpp::R_AARCH64_TLSDESC_ADR_PAGE21: + return aarch64_reloc_funcs::adrp(view, + got_entry_address + addend, + address); + break; + case elfcpp::R_AARCH64_TLSDESC_LD64_LO12: + case elfcpp::R_AARCH64_TLSDESC_ADD_LO12: + return aarch64_reloc_funcs::template rela_general<32>( + view, got_entry_address, addend, reloc_property); + break; + case elfcpp::R_AARCH64_TLSDESC_CALL: + return aarch64_reloc_funcs::STATUS_OKAY; + break; + default: + gold_unreachable(); + } + } + } + break; + + default: + gold_error(_("%s: unsupported TLS reloc %u."), + object->name().c_str(), r_type); + } + return aarch64_reloc_funcs::STATUS_BAD_RELOC; +} // End of relocate_tls. + + +template<int size, bool big_endian> +inline +typename AArch64_relocate_functions<size,big_endian>::Status +Target_aarch64<size, big_endian>::Relocate::tls_gd_to_le( + const Relocate_info<size,big_endian>* relinfo, + Target_aarch64<size, big_endian>* target, + const elfcpp::Rela<size, big_endian>& rela, + unsigned int r_type, + unsigned char* view, + const Symbol_value<size>* psymval) +{ + typedef AArch64_relocate_functions<size,big_endian> aarch64_reloc_funcs; + typedef typename elfcpp::Swap<32, big_endian>::Valtype Insntype; + typedef typename elfcpp::Elf_types<size>::Elf_Addr AArch64_address; + + Insntype* ip = reinterpret_cast<Insntype*>(view); + Insntype insn1 = elfcpp::Swap<32, big_endian>::readval(ip); + Insntype insn2 = elfcpp::Swap<32, big_endian>::readval(ip + 1); + Insntype insn3 = elfcpp::Swap<32, big_endian>::readval(ip + 2); + + if (r_type == elfcpp::R_AARCH64_TLSGD_ADD_LO12_NC) + { + // This is the 2nd relocs, optimization should already have been + // done. + gold_assert((insn1 & 0xfff00000) == 0x91400000); + return aarch64_reloc_funcs::STATUS_OKAY; + } + + // The original sequence is - + // 90000000 adrp x0, 0 <main> + // 91000000 add x0, x0, #0x0 + // 94000000 bl 0 <__tls_get_addr> + // optimized to sequence - + // d53bd040 mrs x0, tpidr_el0 + // 91400000 add x0, x0, #0x0, lsl #12 + // 91000000 add x0, x0, #0x0 + + // Unlike tls_ie_to_le, we change the 3 insns in one function call when we + // encounter the first relocation "R_AARCH64_TLSGD_ADR_PAGE21". Because we + // have to change "bl tls_get_addr", which does not have a corresponding tls + // relocation type. So before proceeding, we need to make sure compiler + // does not change the sequence. + if(!(insn1 == 0x90000000 // adrp x0,0 + && insn2 == 0x91000000 // add x0, x0, #0x0 + && insn3 == 0x94000000)) // bl 0 + { + // Ideally we should give up gd_to_le relaxation and do gd access. + // However the gd_to_le relaxation decision has been made early + // in the scan stage, where we did not allocate any GOT entry for + // this symbol. Therefore we have to exit and report error now. + gold_error(_("unexpected reloc insn sequence while relaxing " + "tls gd to le for reloc %u."), r_type); + return aarch64_reloc_funcs::STATUS_BAD_RELOC; + } + + // Write new insns. + insn1 = 0xd53bd040; // mrs x0, tpidr_el0 + insn2 = 0x91400000; // add x0, x0, #0x0, lsl #12 + insn3 = 0x91000000; // add x0, x0, #0x0 + elfcpp::Swap<32, big_endian>::writeval(ip, insn1); + elfcpp::Swap<32, big_endian>::writeval(ip + 1, insn2); + elfcpp::Swap<32, big_endian>::writeval(ip + 2, insn3); + + // Calculate tprel value. + Output_segment* tls_segment = relinfo->layout->tls_segment(); + gold_assert(tls_segment != NULL); + AArch64_address value = psymval->value(relinfo->object, 0); + const elfcpp::Elf_Xword addend = rela.get_r_addend(); + AArch64_address aligned_tcb_size = + align_address(target->tcb_size(), tls_segment->maximum_alignment()); + AArch64_address x = value + aligned_tcb_size; + + // After new insns are written, apply TLSLE relocs. + const AArch64_reloc_property* rp1 = + aarch64_reloc_property_table->get_reloc_property( + elfcpp::R_AARCH64_TLSLE_ADD_TPREL_HI12); + const AArch64_reloc_property* rp2 = + aarch64_reloc_property_table->get_reloc_property( + elfcpp::R_AARCH64_TLSLE_ADD_TPREL_LO12); + gold_assert(rp1 != NULL && rp2 != NULL); + + typename aarch64_reloc_funcs::Status s1 = + aarch64_reloc_funcs::template rela_general<32>(view + 4, + x, + addend, + rp1); + if (s1 != aarch64_reloc_funcs::STATUS_OKAY) + return s1; + + typename aarch64_reloc_funcs::Status s2 = + aarch64_reloc_funcs::template rela_general<32>(view + 8, + x, + addend, + rp2); + + this->skip_call_tls_get_addr_ = true; + return s2; +} // End of tls_gd_to_le + + +template<int size, bool big_endian> +inline +typename AArch64_relocate_functions<size,big_endian>::Status +Target_aarch64<size, big_endian>::Relocate::tls_ie_to_le( + const Relocate_info<size,big_endian>* relinfo, + Target_aarch64<size, big_endian>* target, + const elfcpp::Rela<size, big_endian>& rela, + unsigned int r_type, + unsigned char* view, + const Symbol_value<size>* psymval) +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr AArch64_address; + typedef typename elfcpp::Swap<32, big_endian>::Valtype Insntype; + typedef AArch64_relocate_functions<size,big_endian> aarch64_reloc_funcs; + + AArch64_address value = psymval->value(relinfo->object, 0); + Output_segment* tls_segment = relinfo->layout->tls_segment(); + AArch64_address aligned_tcb_address = + align_address(target->tcb_size(), tls_segment->maximum_alignment()); + const elfcpp::Elf_Xword addend = rela.get_r_addend(); + AArch64_address x = value + addend + aligned_tcb_address; + // "x" is the offset to tp, we can only do this if x is within + // range [0, 2^32-1] + if (!(size == 32 || (size == 64 && (static_cast<uint64_t>(x) >> 32) == 0))) + { + gold_error(_("TLS variable referred by reloc %u is too far from TP."), + r_type); + return aarch64_reloc_funcs::STATUS_BAD_RELOC; + } + + Insntype* ip = reinterpret_cast<Insntype*>(view); + Insntype insn = elfcpp::Swap<32, big_endian>::readval(ip); + unsigned int regno; + Insntype newinsn; + if (r_type == elfcpp::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21) + { + // Generate movz. + regno = (insn & 0x1f); + newinsn = (0xd2a00000 | regno) | (((x >> 16) & 0xffff) << 5); + } + else if (r_type == elfcpp::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC) + { + // Generate movk. + regno = (insn & 0x1f); + gold_assert(regno == ((insn >> 5) & 0x1f)); + newinsn = (0xf2800000 | regno) | ((x & 0xffff) << 5); + } + else + gold_assert(false); + + elfcpp::Swap<32, big_endian>::writeval(ip, newinsn); + return aarch64_reloc_funcs::STATUS_OKAY; +} // End of tls_ie_to_le + + +template<int size, bool big_endian> +inline +typename AArch64_relocate_functions<size,big_endian>::Status +Target_aarch64<size, big_endian>::Relocate::tls_desc_gd_to_le( + const Relocate_info<size,big_endian>* relinfo, + Target_aarch64<size, big_endian>* target, + const elfcpp::Rela<size, big_endian>& rela, + unsigned int r_type, + unsigned char* view, + const Symbol_value<size>* psymval) +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr AArch64_address; + typedef typename elfcpp::Swap<32, big_endian>::Valtype Insntype; + typedef AArch64_relocate_functions<size,big_endian> aarch64_reloc_funcs; + + // TLSDESC-GD sequence is like: + // adrp x0, :tlsdesc:v1 + // ldr x1, [x0, #:tlsdesc_lo12:v1] + // add x0, x0, :tlsdesc_lo12:v1 + // .tlsdesccall v1 + // blr x1 + // After desc_gd_to_le optimization, the sequence will be like: + // movz x0, #0x0, lsl #16 + // movk x0, #0x10 + // nop + // nop + + // Calculate tprel value. + Output_segment* tls_segment = relinfo->layout->tls_segment(); + gold_assert(tls_segment != NULL); + Insntype* ip = reinterpret_cast<Insntype*>(view); + const elfcpp::Elf_Xword addend = rela.get_r_addend(); + AArch64_address value = psymval->value(relinfo->object, addend); + AArch64_address aligned_tcb_size = + align_address(target->tcb_size(), tls_segment->maximum_alignment()); + AArch64_address x = value + aligned_tcb_size; + // x is the offset to tp, we can only do this if x is within range + // [0, 2^32-1]. If x is out of range, fail and exit. + if (size == 64 && (static_cast<uint64_t>(x) >> 32) != 0) + { + gold_error(_("TLS variable referred by reloc %u is too far from TP. " + "We Can't do gd_to_le relaxation.\n"), r_type); + return aarch64_reloc_funcs::STATUS_BAD_RELOC; + } + Insntype newinsn; + switch (r_type) + { + case elfcpp::R_AARCH64_TLSDESC_ADD_LO12: + case elfcpp::R_AARCH64_TLSDESC_CALL: + // Change to nop + newinsn = 0xd503201f; + break; + + case elfcpp::R_AARCH64_TLSDESC_ADR_PAGE21: + // Change to movz. + newinsn = 0xd2a00000 | (((x >> 16) & 0xffff) << 5); + break; + + case elfcpp::R_AARCH64_TLSDESC_LD64_LO12: + // Change to movk. + newinsn = 0xf2800000 | ((x & 0xffff) << 5); + break; + + default: + gold_error(_("unsupported tlsdesc gd_to_le optimization on reloc %u"), + r_type); + gold_unreachable(); + } + elfcpp::Swap<32, big_endian>::writeval(ip, newinsn); + return aarch64_reloc_funcs::STATUS_OKAY; +} // End of tls_desc_gd_to_le + + +template<int size, bool big_endian> +inline +typename AArch64_relocate_functions<size,big_endian>::Status +Target_aarch64<size, big_endian>::Relocate::tls_desc_gd_to_ie( + const Relocate_info<size,big_endian>* /* relinfo */, + Target_aarch64<size, big_endian>* /* target */, + const elfcpp::Rela<size, big_endian>& rela, + unsigned int r_type, + unsigned char* view, + const Symbol_value<size>* /* psymval */, + typename elfcpp::Elf_types<size>::Elf_Addr got_entry_address, + typename elfcpp::Elf_types<size>::Elf_Addr address) +{ + typedef typename elfcpp::Swap<32, big_endian>::Valtype Insntype; + typedef AArch64_relocate_functions<size,big_endian> aarch64_reloc_funcs; + + // TLSDESC-GD sequence is like: + // adrp x0, :tlsdesc:v1 + // ldr x1, [x0, #:tlsdesc_lo12:v1] + // add x0, x0, :tlsdesc_lo12:v1 + // .tlsdesccall v1 + // blr x1 + // After desc_gd_to_ie optimization, the sequence will be like: + // adrp x0, :tlsie:v1 + // ldr x0, [x0, :tlsie_lo12:v1] + // nop + // nop + + Insntype* ip = reinterpret_cast<Insntype*>(view); + const elfcpp::Elf_Xword addend = rela.get_r_addend(); + Insntype newinsn; + switch (r_type) + { + case elfcpp::R_AARCH64_TLSDESC_ADD_LO12: + case elfcpp::R_AARCH64_TLSDESC_CALL: + // Change to nop + newinsn = 0xd503201f; + elfcpp::Swap<32, big_endian>::writeval(ip, newinsn); + break; + + case elfcpp::R_AARCH64_TLSDESC_ADR_PAGE21: + { + return aarch64_reloc_funcs::adrp(view, got_entry_address + addend, + address); + } + break; + + case elfcpp::R_AARCH64_TLSDESC_LD64_LO12: + { + const AArch64_reloc_property* reloc_property = + aarch64_reloc_property_table->get_reloc_property( + elfcpp::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC); + return aarch64_reloc_funcs::template rela_general<32>( + view, got_entry_address, addend, reloc_property); + } + break; + + default: + gold_error(_("Don't support tlsdesc gd_to_ie optimization on reloc %u"), + r_type); + gold_unreachable(); + } + return aarch64_reloc_funcs::STATUS_OKAY; +} // End of tls_desc_gd_to_ie + +// Relocate section data. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::relocate_section( + const Relocate_info<size, big_endian>* relinfo, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + unsigned char* view, + typename elfcpp::Elf_types<size>::Elf_Addr address, + section_size_type view_size, + const Reloc_symbol_changes* reloc_symbol_changes) +{ + gold_assert(sh_type == elfcpp::SHT_RELA); + typedef typename Target_aarch64<size, big_endian>::Relocate AArch64_relocate; + gold::relocate_section<size, big_endian, Target_aarch64, elfcpp::SHT_RELA, + AArch64_relocate, gold::Default_comdat_behavior>( + relinfo, + this, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + view, + address, + view_size, + reloc_symbol_changes); +} + +// Return the size of a relocation while scanning during a relocatable +// link. + +template<int size, bool big_endian> +unsigned int +Target_aarch64<size, big_endian>::Relocatable_size_for_reloc:: +get_size_for_reloc( + unsigned int , + Relobj* ) +{ + // We will never support SHT_REL relocations. + gold_unreachable(); + return 0; +} + +// Scan the relocs during a relocatable link. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::scan_relocatable_relocs( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols, + Relocatable_relocs* rr) +{ + gold_assert(sh_type == elfcpp::SHT_RELA); + + typedef gold::Default_scan_relocatable_relocs<elfcpp::SHT_RELA, + Relocatable_size_for_reloc> Scan_relocatable_relocs; + + gold::scan_relocatable_relocs<size, big_endian, elfcpp::SHT_RELA, + Scan_relocatable_relocs>( + symtab, + layout, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols, + rr); +} + +// Relocate a section during a relocatable link. + +template<int size, bool big_endian> +void +Target_aarch64<size, big_endian>::relocate_relocs( + const Relocate_info<size, big_endian>* relinfo, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + typename elfcpp::Elf_types<size>::Elf_Off offset_in_output_section, + const Relocatable_relocs* rr, + unsigned char* view, + typename elfcpp::Elf_types<size>::Elf_Addr view_address, + section_size_type view_size, + unsigned char* reloc_view, + section_size_type reloc_view_size) +{ + gold_assert(sh_type == elfcpp::SHT_RELA); + + gold::relocate_relocs<size, big_endian, elfcpp::SHT_RELA>( + relinfo, + prelocs, + reloc_count, + output_section, + offset_in_output_section, + rr, + view, + view_address, + view_size, + reloc_view, + reloc_view_size); +} + +// The selector for aarch64 object files. + +template<int size, bool big_endian> +class Target_selector_aarch64 : public Target_selector +{ + public: + Target_selector_aarch64(); + + virtual Target* + do_instantiate_target() + { return new Target_aarch64<size, big_endian>(); } +}; + +template<> +Target_selector_aarch64<32, true>::Target_selector_aarch64() + : Target_selector(elfcpp::EM_AARCH64, 32, true, + "elf32-bigaarch64", "aarch64_elf32_be_vec") +{ } + +template<> +Target_selector_aarch64<32, false>::Target_selector_aarch64() + : Target_selector(elfcpp::EM_AARCH64, 32, false, + "elf32-littleaarch64", "aarch64_elf32_le_vec") +{ } + +template<> +Target_selector_aarch64<64, true>::Target_selector_aarch64() + : Target_selector(elfcpp::EM_AARCH64, 64, true, + "elf64-bigaarch64", "aarch64_elf64_be_vec") +{ } + +template<> +Target_selector_aarch64<64, false>::Target_selector_aarch64() + : Target_selector(elfcpp::EM_AARCH64, 64, false, + "elf64-littleaarch64", "aarch64_elf64_le_vec") +{ } + +Target_selector_aarch64<32, true> target_selector_aarch64elf32b; +Target_selector_aarch64<32, false> target_selector_aarch64elf32; +Target_selector_aarch64<64, true> target_selector_aarch64elfb; +Target_selector_aarch64<64, false> target_selector_aarch64elf; + +} // End anonymous namespace. diff --git a/binutils-2.25/gold/archive.cc b/binutils-2.25/gold/archive.cc index 53d88a2..23cb0be 100644 --- a/binutils-2.25/gold/archive.cc +++ b/binutils-2.25/gold/archive.cc @@ -1,7 +1,6 @@ // archive.cc -- archive support for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -97,46 +96,56 @@ Library_base::should_include_member(Symbol_table* symtab, Layout* layout, *symp = sym; - if (sym == NULL) + if (sym != NULL) { - // Check whether the symbol was named in a -u option. - if (parameters->options().is_undefined(sym_name)) - { - *why = "-u "; - *why += sym_name; - } - else if (parameters->options().is_export_dynamic_symbol(sym_name)) - { - *why = "--export-dynamic-symbol "; - *why += sym_name; - } - else if (layout->script_options()->is_referenced(sym_name)) - { - size_t alc = 100 + strlen(sym_name); - char* buf = new char[alc]; - snprintf(buf, alc, _("script or expression reference to %s"), - sym_name); - *why = buf; - delete[] buf; - } - else if (strcmp(sym_name, parameters->entry()) == 0) - { - *why = "entry symbol "; - *why += sym_name; - } - else - return Library_base::SHOULD_INCLUDE_UNKNOWN; + if (!sym->is_undefined()) + return Library_base::SHOULD_INCLUDE_NO; + + // PR 12001: Do not include an archive when the undefined + // symbol has actually been defined on the command line. + if (layout->script_options()->is_pending_assignment(sym_name)) + return Library_base::SHOULD_INCLUDE_NO; + + // If the symbol is weak undefined, we still need to check + // for other reasons (like a -u option). + if (sym->binding() != elfcpp::STB_WEAK) + return Library_base::SHOULD_INCLUDE_YES; + } + + // Check whether the symbol was named in a -u option. + if (parameters->options().is_undefined(sym_name)) + { + *why = "-u "; + *why += sym_name; + return Library_base::SHOULD_INCLUDE_YES; + } + + if (parameters->options().is_export_dynamic_symbol(sym_name)) + { + *why = "--export-dynamic-symbol "; + *why += sym_name; + return Library_base::SHOULD_INCLUDE_YES; } - else if (!sym->is_undefined()) - return Library_base::SHOULD_INCLUDE_NO; - // PR 12001: Do not include an archive when the undefined - // symbol has actually been defined on the command line. - else if (layout->script_options()->is_pending_assignment(sym_name)) - return Library_base::SHOULD_INCLUDE_NO; - else if (sym->binding() == elfcpp::STB_WEAK) - return Library_base::SHOULD_INCLUDE_UNKNOWN; - - return Library_base::SHOULD_INCLUDE_YES; + + if (layout->script_options()->is_referenced(sym_name)) + { + size_t alc = 100 + strlen(sym_name); + char* buf = new char[alc]; + snprintf(buf, alc, _("script or expression reference to %s"), + sym_name); + *why = buf; + delete[] buf; + return Library_base::SHOULD_INCLUDE_YES; + } + + if (strcmp(sym_name, parameters->entry()) == 0) + { + *why = "entry symbol "; + *why += sym_name; + return Library_base::SHOULD_INCLUDE_YES; + } + + return Library_base::SHOULD_INCLUDE_UNKNOWN; } // The header of an entry in the archive. This is all readable text, diff --git a/binutils-2.25/gold/archive.h b/binutils-2.25/gold/archive.h index 3d75de6..e031559 100644 --- a/binutils-2.25/gold/archive.h +++ b/binutils-2.25/gold/archive.h @@ -1,6 +1,6 @@ // archive.h -- archive support for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2010, 2011, 2013 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/arm-reloc-property.cc b/binutils-2.25/gold/arm-reloc-property.cc index 3259c40..dfc2fe1 100644 --- a/binutils-2.25/gold/arm-reloc-property.cc +++ b/binutils-2.25/gold/arm-reloc-property.cc @@ -1,6 +1,6 @@ // arm-reloc-property.cc -- ARM relocation property. -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/arm-reloc-property.h b/binutils-2.25/gold/arm-reloc-property.h index afba293..d98f644 100644 --- a/binutils-2.25/gold/arm-reloc-property.h +++ b/binutils-2.25/gold/arm-reloc-property.h @@ -1,6 +1,6 @@ // arm-reloc-property.h -- ARM relocation properties -*- C++ -*- -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/arm-reloc.def b/binutils-2.25/gold/arm-reloc.def index 3a5ab6c..9bccdfa 100644 --- a/binutils-2.25/gold/arm-reloc.def +++ b/binutils-2.25/gold/arm-reloc.def @@ -1,6 +1,6 @@ // arm-reloc.def -- ARM relocation definitions. -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/arm.cc b/binutils-2.25/gold/arm.cc index 560f380..6c472bb 100644 --- a/binutils-2.25/gold/arm.cc +++ b/binutils-2.25/gold/arm.cc @@ -1,6 +1,6 @@ // arm.cc -- arm target support for gold. -// Copyright 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com> based on the i386 code // by Ian Lance Taylor <iant@google.com>. // This file also contains borrowed and adapted code from @@ -6683,7 +6683,7 @@ void Arm_relobj<big_endian>::do_read_symbols(Read_symbols_data* sd) { // Call parent class to read symbol information. - Sized_relobj_file<32, big_endian>::do_read_symbols(sd); + this->base_read_symbols(sd); // If this input file is a binary file, it has no processor // specific flags and attributes section. @@ -6974,7 +6974,7 @@ void Arm_dynobj<big_endian>::do_read_symbols(Read_symbols_data* sd) { // Call parent class to read symbol information. - Sized_dynobj<32, big_endian>::do_read_symbols(sd); + this->base_read_symbols(sd); // Read processor-specific flags in ELF file header. const unsigned char* pehdr = this->get_view(elfcpp::file_header_offset, @@ -8301,7 +8301,8 @@ Target_arm<big_endian>::Scan::global(Symbol_table* symtab, // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (gsym->may_need_copy_reloc()) + if (!parameters->options().output_is_position_independent() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); @@ -8382,7 +8383,8 @@ Target_arm<big_endian>::Scan::global(Symbol_table* symtab, // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (target->may_need_copy_reloc(gsym)) + if (parameters->options().output_is_executable() + && target->may_need_copy_reloc(gsym)) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); diff --git a/binutils-2.25/gold/attributes.cc b/binutils-2.25/gold/attributes.cc index 45ab5a0..8e2892c 100644 --- a/binutils-2.25/gold/attributes.cc +++ b/binutils-2.25/gold/attributes.cc @@ -1,6 +1,6 @@ // attributes.cc -- object attributes for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file contains code adapted from BFD. diff --git a/binutils-2.25/gold/attributes.h b/binutils-2.25/gold/attributes.h index 26fe158..2aa7a78 100644 --- a/binutils-2.25/gold/attributes.h +++ b/binutils-2.25/gold/attributes.h @@ -1,6 +1,6 @@ // attributes.h -- object attributes for gold -*- C++ -*- -// Copyright 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file contains code adapted from BFD. diff --git a/binutils-2.25/gold/binary.cc b/binutils-2.25/gold/binary.cc index 6cc99a9..4dab52c 100644 --- a/binutils-2.25/gold/binary.cc +++ b/binutils-2.25/gold/binary.cc @@ -1,6 +1,6 @@ // binary.cc -- binary input files for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/binary.h b/binutils-2.25/gold/binary.h index 75bc731..3ce84c2 100644 --- a/binutils-2.25/gold/binary.h +++ b/binutils-2.25/gold/binary.h @@ -1,6 +1,6 @@ // binary.h -- binary input files for gold -*- C++ -*- -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/common.cc b/binutils-2.25/gold/common.cc index b0c7d6e..739c890 100644 --- a/binutils-2.25/gold/common.cc +++ b/binutils-2.25/gold/common.cc @@ -1,7 +1,6 @@ // common.cc -- handle common symbols for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/common.h b/binutils-2.25/gold/common.h index 4de585c..20c37ab 100644 --- a/binutils-2.25/gold/common.h +++ b/binutils-2.25/gold/common.h @@ -1,6 +1,6 @@ // common.h -- handle common symbols for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/compressed_output.cc b/binutils-2.25/gold/compressed_output.cc index 9c7c7dd..19a7f63 100644 --- a/binutils-2.25/gold/compressed_output.cc +++ b/binutils-2.25/gold/compressed_output.cc @@ -1,6 +1,6 @@ // compressed_output.cc -- manage compressed debug sections for gold -// Copyright 2007, 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/compressed_output.h b/binutils-2.25/gold/compressed_output.h index 2d6ebd9..96a4baf 100644 --- a/binutils-2.25/gold/compressed_output.h +++ b/binutils-2.25/gold/compressed_output.h @@ -1,6 +1,6 @@ // compressed_output.h -- compressed output sections for gold -*- C++ -*- -// Copyright 2007, 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/config.in b/binutils-2.25/gold/config.in index d46fd75..be77810 100644 --- a/binutils-2.25/gold/config.in +++ b/binutils-2.25/gold/config.in @@ -187,6 +187,12 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the <unordered_map> header file. */ +#undef HAVE_UNORDERED_MAP + +/* Define to 1 if you have the <unordered_set> header file. */ +#undef HAVE_UNORDERED_SET + /* Define to 1 if you have the <windows.h> header file. */ #undef HAVE_WINDOWS_H diff --git a/binutils-2.25/gold/configure b/binutils-2.25/gold/configure index 3ef8833..7d7b849 100755 --- a/binutils-2.25/gold/configure +++ b/binutils-2.25/gold/configure @@ -594,10 +594,12 @@ LTLIBOBJS MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE -HAVE_PUBNAMES_FALSE -HAVE_PUBNAMES_TRUE DLOPEN_LIBS CXXCPP +HAVE_NO_USE_LINKER_PLUGIN_FALSE +HAVE_NO_USE_LINKER_PLUGIN_TRUE +HAVE_PUBNAMES_FALSE +HAVE_PUBNAMES_TRUE HAVE_ZLIB_FALSE HAVE_ZLIB_TRUE LIBOBJS @@ -682,6 +684,8 @@ CC NM TARGETOBJS DEFAULT_TARGET +DEFAULT_TARGET_MIPS_FALSE +DEFAULT_TARGET_MIPS_TRUE DEFAULT_TARGET_TILEGX_FALSE DEFAULT_TARGET_TILEGX_TRUE DEFAULT_TARGET_X86_64_FALSE @@ -694,6 +698,8 @@ DEFAULT_TARGET_I386_FALSE DEFAULT_TARGET_I386_TRUE DEFAULT_TARGET_ARM_FALSE DEFAULT_TARGET_ARM_TRUE +DEFAULT_TARGET_AARCH64_FALSE +DEFAULT_TARGET_AARCH64_TRUE PLUGINS_FALSE PLUGINS_TRUE THREADS_FALSE @@ -3429,6 +3435,14 @@ for targ in $target $canon_targets; do default_big_endian=$targ_big_endian default_osabi=$targ_osabi + if test "$targ_obj" = "aarch64"; then + DEFAULT_TARGET_AARCH64_TRUE= + DEFAULT_TARGET_AARCH64_FALSE='#' +else + DEFAULT_TARGET_AARCH64_TRUE='#' + DEFAULT_TARGET_AARCH64_FALSE= +fi + if test "$targ_obj" = "arm"; then DEFAULT_TARGET_ARM_TRUE= DEFAULT_TARGET_ARM_FALSE='#' @@ -3477,6 +3491,14 @@ else DEFAULT_TARGET_TILEGX_FALSE= fi + if test "$targ_obj" = "mips"; then + DEFAULT_TARGET_MIPS_TRUE= + DEFAULT_TARGET_MIPS_FALSE='#' +else + DEFAULT_TARGET_MIPS_TRUE='#' + DEFAULT_TARGET_MIPS_FALSE= +fi + DEFAULT_TARGET=${targ_obj} fi @@ -6353,9 +6375,9 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext const char *s = "foo"; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_merge_constants=yes + gold_cv_merge_constants=yes else - have_merge_constants=no + gold_cv_merge_constants=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" @@ -6628,6 +6650,9 @@ fi +# Set the 'development' global. +. $srcdir/../bfd/development.sh + GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6662,8 +6687,8 @@ case "${host}" in *) ;; esac -# Enable -Werror by default when using gcc -if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then +# Enable -Werror by default when using gcc. Turn it off for releases. +if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" -a "$development" = true ; then ERROR_ON_WARNING=yes fi @@ -6991,6 +7016,50 @@ cat >>confdefs.h <<_ACEOF _ACEOF +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror -gpubnames" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_pubnames=yes +else + have_pubnames=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" + if test "$have_pubnames" = "yes"; then + HAVE_PUBNAMES_TRUE= + HAVE_PUBNAMES_FALSE='#' +else + HAVE_PUBNAMES_TRUE='#' + HAVE_PUBNAMES_FALSE= +fi + + +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror -fno-use-linker-plugin" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_no_use_linker_plugin=yes +else + have_no_use_linker_plugin=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" + if test "$have_no_use_linker_plugin" = "yes"; then + HAVE_NO_USE_LINKER_PLUGIN_TRUE= + HAVE_NO_USE_LINKER_PLUGIN_FALSE='#' +else + HAVE_NO_USE_LINKER_PLUGIN_TRUE='#' + HAVE_NO_USE_LINKER_PLUGIN_FALSE= +fi + + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -7133,6 +7202,20 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +for ac_header in unordered_set unordered_map +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + for ac_header in tr1/unordered_set tr1/unordered_map do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -7193,13 +7276,71 @@ if test "x$ac_cv_header_dlfcn_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF - DLOPEN_LIBS="-ldl" -else - DLOPEN_LIBS="" + fi done +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 +$as_echo_n "checking for library containing dlopen... " >&6; } +if test "${ac_cv_search_dlopen+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dl dld; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_search_dlopen=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_dlopen+set}" = set; then : + break +fi +done +if test "${ac_cv_search_dlopen+set}" = set; then : + +else + ac_cv_search_dlopen=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 +$as_echo "$ac_cv_search_dlopen" >&6; } +ac_res=$ac_cv_search_dlopen +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +case "$ac_cv_search_dlopen" in + no*) DLOPEN_LIBS="";; + *) DLOPEN_LIBS="$ac_cv_search_dlopen";; +esac for ac_func in mallinfo posix_fallocate fallocate readv sysconf times @@ -7443,28 +7584,6 @@ $as_echo "#define HAVE_STAT_ST_MTIM 1" >>confdefs.h fi -save_CXXFLAGS="$CXXFLAGS" -CXXFLAGS="$CXXFLAGS -Werror -gpubnames" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int i; -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - have_pubnames=yes -else - have_pubnames=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -CXXFLAGS="$save_CXXFLAGS" - if test "$have_pubnames" = "yes"; then - HAVE_PUBNAMES_TRUE= - HAVE_PUBNAMES_FALSE='#' -else - HAVE_PUBNAMES_TRUE='#' - HAVE_PUBNAMES_FALSE= -fi - - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -7668,6 +7787,10 @@ if test -z "${PLUGINS_TRUE}" && test -z "${PLUGINS_FALSE}"; then as_fn_error "conditional \"PLUGINS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${DEFAULT_TARGET_AARCH64_TRUE}" && test -z "${DEFAULT_TARGET_AARCH64_FALSE}"; then + as_fn_error "conditional \"DEFAULT_TARGET_AARCH64\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${DEFAULT_TARGET_ARM_TRUE}" && test -z "${DEFAULT_TARGET_ARM_FALSE}"; then as_fn_error "conditional \"DEFAULT_TARGET_ARM\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -7692,6 +7815,10 @@ if test -z "${DEFAULT_TARGET_TILEGX_TRUE}" && test -z "${DEFAULT_TARGET_TILEGX_F as_fn_error "conditional \"DEFAULT_TARGET_TILEGX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${DEFAULT_TARGET_MIPS_TRUE}" && test -z "${DEFAULT_TARGET_MIPS_FALSE}"; then + as_fn_error "conditional \"DEFAULT_TARGET_MIPS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -7765,6 +7892,10 @@ if test -z "${HAVE_PUBNAMES_TRUE}" && test -z "${HAVE_PUBNAMES_FALSE}"; then as_fn_error "conditional \"HAVE_PUBNAMES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_NO_USE_LINKER_PLUGIN_TRUE}" && test -z "${HAVE_NO_USE_LINKER_PLUGIN_FALSE}"; then + as_fn_error "conditional \"HAVE_NO_USE_LINKER_PLUGIN\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/binutils-2.25/gold/configure.ac b/binutils-2.25/gold/configure.ac index c23117b..0478011 100644 --- a/binutils-2.25/gold/configure.ac +++ b/binutils-2.25/gold/configure.ac @@ -1,7 +1,6 @@ dnl Process this file with autoconf to produce a configure script. dnl -dnl Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -dnl Free Software Foundation, Inc. +dnl Copyright (C) 2006-2014 Free Software Foundation, Inc. dnl dnl This file is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by @@ -200,12 +199,14 @@ for targ in $target $canon_targets; do default_big_endian=$targ_big_endian default_osabi=$targ_osabi + AM_CONDITIONAL(DEFAULT_TARGET_AARCH64, test "$targ_obj" = "aarch64") AM_CONDITIONAL(DEFAULT_TARGET_ARM, test "$targ_obj" = "arm") AM_CONDITIONAL(DEFAULT_TARGET_I386, test "$targ_obj" = "i386") AM_CONDITIONAL(DEFAULT_TARGET_POWERPC, test "$targ_obj" = "powerpc") AM_CONDITIONAL(DEFAULT_TARGET_SPARC, test "$targ_obj" = "sparc") AM_CONDITIONAL(DEFAULT_TARGET_X86_64, test "$targ_obj" = "x86_64") AM_CONDITIONAL(DEFAULT_TARGET_TILEGX, test "$targ_obj" = "tilegx") + AM_CONDITIONAL(DEFAULT_TARGET_MIPS, test "$targ_obj" = "mips") DEFAULT_TARGET=${targ_obj} AC_SUBST(DEFAULT_TARGET) fi @@ -343,8 +344,8 @@ AC_CACHE_CHECK([whether $CC supports -fmerge-constants], save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fmerge-constants" AC_COMPILE_IFELSE([const char *s = "foo";], - [have_merge_constants=yes], - [have_merge_constants=no]) + [gold_cv_merge_constants=yes], + [gold_cv_merge_constants=no]) CFLAGS="$save_CFLAGS"]) AC_SUBST([MERGE_CONSTANTS_FLAG]) AS_IF([test "$gold_cv_merge_constants" = yes], @@ -521,16 +522,41 @@ dnl multiple declarations of functions like basename when compiling dnl with C++. AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp]) +dnl Check if gcc supports the -gpubnames option. +dnl Use -Werror in case of compilers that make unknown -g options warnings. +dnl They would pass the test here, but fail in actual use when $WARN_CFLAGS +dnl gets set later by default Autoconf magic to include -Werror. (We are +dnl assuming here that there is no compiler that groks -gpubnames +dnl but does not grok -Werror.) +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror -gpubnames" +AC_COMPILE_IFELSE([int i;], [have_pubnames=yes], [have_pubnames=no]) +CFLAGS="$save_CFLAGS" +AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes") + +dnl Check if gcc supports the -fno-use-linker-plugin option. +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror -fno-use-linker-plugin" +AC_COMPILE_IFELSE([int i;], [have_no_use_linker_plugin=yes], [have_no_use_linker_plugin=no]) +CFLAGS="$save_CFLAGS" +AM_CONDITIONAL(HAVE_NO_USE_LINKER_PLUGIN, test "$have_no_use_linker_plugin" = "yes") + AC_LANG_PUSH(C++) +AC_CHECK_HEADERS(unordered_set unordered_map) AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map) AC_CHECK_HEADERS(ext/hash_map ext/hash_set) AC_CHECK_HEADERS(byteswap.h) dnl When plugins enabled dynamic loader interface is required. Check headers -dnl which may provide this interface. In case of dlfcn.h add libdl to link. +dnl which may provide this interface. Add the necessary library to link. AC_CHECK_HEADERS(windows.h) -AC_CHECK_HEADERS(dlfcn.h, [DLOPEN_LIBS="-ldl"], [DLOPEN_LIBS=""]) +AC_CHECK_HEADERS(dlfcn.h) +AC_SEARCH_LIBS(dlopen, [dl dld]) +case "$ac_cv_search_dlopen" in + no*) DLOPEN_LIBS="";; + *) DLOPEN_LIBS="$ac_cv_search_dlopen";; +esac AC_SUBST(DLOPEN_LIBS) AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times) @@ -596,18 +622,6 @@ if test "$gold_cv_stat_st_mtim" = "yes"; then [Define if struct stat has a field st_mtim with timespec for mtime]) fi -dnl Check if gcc supports the -gpubnames option. -dnl Use -Werror in case of compilers that make unknown -g options warnings. -dnl They would pass the test here, but fail in actual use when $WARN_CFLAGS -dnl gets set later by default Autoconf magic to include -Werror. (We are -dnl assuming here that there is no compiler that groks -gpubnames -dnl but does not grok -Werror.) -save_CXXFLAGS="$CXXFLAGS" -CXXFLAGS="$CXXFLAGS -Werror -gpubnames" -AC_COMPILE_IFELSE([int i;], [have_pubnames=yes], [have_pubnames=no]) -CXXFLAGS="$save_CXXFLAGS" -AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes") - AC_LANG_POP(C++) AC_CHECK_HEADERS(locale.h) diff --git a/binutils-2.25/gold/configure.tgt b/binutils-2.25/gold/configure.tgt index d61647e..9a75070 100644 --- a/binutils-2.25/gold/configure.tgt +++ b/binutils-2.25/gold/configure.tgt @@ -1,6 +1,6 @@ # configure.tgt -- target configuration for gold -*- sh -*- -# Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 2006-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. @@ -144,6 +144,28 @@ arm*-*-*) targ_big_endian=false targ_extra_big_endian=true ;; +aarch64*-*) + targ_obj=aarch64 + targ_machine=EM_AARCH64 + targ_size=64 + targ_extra_size=32 + targ_big_endian=false + targ_extra_big_endian=true + ;; +mips*el*-*-*|mips*le*-*-*) + targ_obj=mips + targ_machine=EM_MIPS_RS3_LE + targ_size=32 + targ_big_endian=false + targ_extra_big_endian=true + ;; +mips*-*-*) + targ_obj=mips + targ_machine=EM_MIPS + targ_size=32 + targ_big_endian=true + targ_extra_big_endian=false + ;; *) targ_obj=UNKNOWN ;; diff --git a/binutils-2.25/gold/copy-relocs.cc b/binutils-2.25/gold/copy-relocs.cc index 92c5aea..41b6563 100644 --- a/binutils-2.25/gold/copy-relocs.cc +++ b/binutils-2.25/gold/copy-relocs.cc @@ -1,6 +1,6 @@ // copy-relocs.cc -- handle COPY relocations for gold. -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -28,25 +28,6 @@ namespace gold { -// Copy_relocs::Copy_reloc_entry methods. - -// Emit the reloc if appropriate. - -template<int sh_type, int size, bool big_endian> -void -Copy_relocs<sh_type, size, big_endian>::Copy_reloc_entry::emit( - Output_data_reloc<sh_type, true, size, big_endian>* reloc_section) -{ - // If the symbol is no longer defined in a dynamic object, then we - // emitted a COPY relocation, and we do not want to emit this - // dynamic relocation. - if (this->sym_->is_from_dynobj()) - reloc_section->add_global_generic(this->sym_, this->reloc_type_, - this->output_section_, this->relobj_, - this->shndx_, this->address_, - this->addend_); -} - // Copy_relocs methods. // Handle a relocation against a symbol which may force us to generate @@ -215,7 +196,18 @@ Copy_relocs<sh_type, size, big_endian>::emit( for (typename Copy_reloc_entries::iterator p = this->entries_.begin(); p != this->entries_.end(); ++p) - p->emit(reloc_section); + { + Copy_reloc_entry& entry = *p; + + // If the symbol is no longer defined in a dynamic object, then we + // emitted a COPY relocation, and we do not want to emit this + // dynamic relocation. + if (entry.sym_->is_from_dynobj()) + reloc_section->add_global_generic(entry.sym_, entry.reloc_type_, + entry.output_section_, entry.relobj_, + entry.shndx_, entry.address_, + entry.addend_); + } // We no longer need the saved information. this->entries_.clear(); diff --git a/binutils-2.25/gold/copy-relocs.h b/binutils-2.25/gold/copy-relocs.h index d1e2323..800c0e7 100644 --- a/binutils-2.25/gold/copy-relocs.h +++ b/binutils-2.25/gold/copy-relocs.h @@ -1,6 +1,6 @@ // copy-relocs.h -- handle COPY relocations for gold -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -54,7 +54,7 @@ class Copy_relocs public: Copy_relocs(unsigned int copy_reloc_type) - : copy_reloc_type_(copy_reloc_type), dynbss_(NULL), entries_() + : entries_(), copy_reloc_type_(copy_reloc_type), dynbss_(NULL) { } // This is called while scanning relocs if we see a relocation @@ -87,16 +87,15 @@ class Copy_relocs Output_data*, off_t, Output_data_reloc<sh_type, true, size, big_endian>*); - private: + protected: typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; typedef typename elfcpp::Elf_types<size>::Elf_Addr Addend; // This POD class holds the relocations we are saving. We will emit // these relocations if it turns out that the symbol does not // require a COPY relocation. - class Copy_reloc_entry + struct Copy_reloc_entry { - public: Copy_reloc_entry(Symbol* sym, unsigned int reloc_type, Sized_relobj_file<size, big_endian>* relobj, unsigned int shndx, @@ -107,13 +106,6 @@ class Copy_relocs address_(address), addend_(addend) { } - // Emit this reloc if appropriate. This is called after we have - // scanned all the relocations, so we know whether we emitted a - // COPY relocation for SYM_. - void - emit(Output_data_reloc<sh_type, true, size, big_endian>*); - - private: Symbol* sym_; unsigned int reloc_type_; Sized_relobj_file<size, big_endian>* relobj_; @@ -123,20 +115,24 @@ class Copy_relocs Addend addend_; }; + // Make a new COPY reloc and emit it. + void + make_copy_reloc(Symbol_table*, Layout*, Sized_symbol<size>*, + Output_data_reloc<sh_type, true, size, big_endian>*); + // A list of relocs to be saved. typedef std::vector<Copy_reloc_entry> Copy_reloc_entries; + // The list of relocs we are saving. + Copy_reloc_entries entries_; + + private: // Return whether we need a COPY reloc. bool need_copy_reloc(Sized_symbol<size>* gsym, Sized_relobj_file<size, big_endian>* object, unsigned int shndx) const; - // Make a new COPY reloc and emit it. - void - make_copy_reloc(Symbol_table*, Layout*, Sized_symbol<size>*, - Output_data_reloc<sh_type, true, size, big_endian>*); - // Save a reloc against SYM for possible emission later. void save(Symbol*, Sized_relobj_file<size, big_endian>*, unsigned int shndx, @@ -147,8 +143,6 @@ class Copy_relocs // The dynamic BSS data which goes into the .bss section. This is // where variables which require COPY relocations are placed. Output_data_space* dynbss_; - // The list of relocs we are saving. - Copy_reloc_entries entries_; }; } // End namespace gold. diff --git a/binutils-2.25/gold/cref.cc b/binutils-2.25/gold/cref.cc index ebd48a9..ac6f1c8 100644 --- a/binutils-2.25/gold/cref.cc +++ b/binutils-2.25/gold/cref.cc @@ -1,6 +1,6 @@ // cref.cc -- cross reference for gold -// Copyright 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/cref.h b/binutils-2.25/gold/cref.h index a40a34a..0e72d16 100644 --- a/binutils-2.25/gold/cref.h +++ b/binutils-2.25/gold/cref.h @@ -1,6 +1,6 @@ // cref.h -- cross reference reports for gold -*- C++ -*- -// Copyright 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/debug.h b/binutils-2.25/gold/debug.h index 7fdbee7..63d3d8a 100644 --- a/binutils-2.25/gold/debug.h +++ b/binutils-2.25/gold/debug.h @@ -1,6 +1,6 @@ // debug.h -- gold internal debugging support -*- C++ -*- -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/defstd.cc b/binutils-2.25/gold/defstd.cc index a7a57e4..cee68a0 100644 --- a/binutils-2.25/gold/defstd.cc +++ b/binutils-2.25/gold/defstd.cc @@ -1,6 +1,6 @@ // defstd.cc -- define standard symbols for gold. -// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -141,6 +141,20 @@ const Define_symbol_in_segment in_segment[] = true // only_if_ref }, { + "__ehdr_start", // name + elfcpp::PT_LOAD, // segment_type + elfcpp::PF(0), // segment_flags_set + elfcpp::PF(0), // segment_flags_clear + 0, // value + 0, // size + elfcpp::STT_NOTYPE, // type + elfcpp::STB_GLOBAL, // binding + elfcpp::STV_HIDDEN, // visibility + 0, // nonvis + Symbol::SEGMENT_START, // offset_from_base + true // only_if_ref + }, + { "etext", // name elfcpp::PT_LOAD, // segment_type elfcpp::PF_X, // segment_flags_set diff --git a/binutils-2.25/gold/defstd.h b/binutils-2.25/gold/defstd.h index 2aea81c..853a1e8 100644 --- a/binutils-2.25/gold/defstd.h +++ b/binutils-2.25/gold/defstd.h @@ -1,6 +1,6 @@ // defstd.h -- define standard symbols for gold -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/descriptors.cc b/binutils-2.25/gold/descriptors.cc index b7fbaa6..2016b7f 100644 --- a/binutils-2.25/gold/descriptors.cc +++ b/binutils-2.25/gold/descriptors.cc @@ -1,6 +1,6 @@ // descriptors.cc -- manage file descriptors for gold -// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/descriptors.h b/binutils-2.25/gold/descriptors.h index 985f804..c14ac07 100644 --- a/binutils-2.25/gold/descriptors.h +++ b/binutils-2.25/gold/descriptors.h @@ -1,6 +1,6 @@ // descriptors.h -- manage file descriptors for gold -*- C++ -*- -// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/dirsearch.cc b/binutils-2.25/gold/dirsearch.cc index a6114a4..e9e2fa1 100644 --- a/binutils-2.25/gold/dirsearch.cc +++ b/binutils-2.25/gold/dirsearch.cc @@ -1,6 +1,6 @@ // dirsearch.cc -- directory searching for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/dirsearch.h b/binutils-2.25/gold/dirsearch.h index ebc0b5b..d020d94 100644 --- a/binutils-2.25/gold/dirsearch.h +++ b/binutils-2.25/gold/dirsearch.h @@ -1,6 +1,6 @@ // dirsearch.h -- directory searching for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/dwarf_reader.cc b/binutils-2.25/gold/dwarf_reader.cc index fb2a152..30aea10 100644 --- a/binutils-2.25/gold/dwarf_reader.cc +++ b/binutils-2.25/gold/dwarf_reader.cc @@ -1,6 +1,6 @@ // dwarf_reader.cc -- parse dwarf2/3 debug information -// Copyright 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -23,6 +23,7 @@ #include "gold.h" #include <algorithm> +#include <utility> #include <vector> #include "elfcpp_swap.h" @@ -180,7 +181,7 @@ Dwarf_abbrev_table::do_read_abbrevs( for (unsigned int i = 1; i < object->shnum(); ++i) { std::string name = object->section_name(i); - if (name == ".debug_abbrev") + if (name == ".debug_abbrev" || name == ".zdebug_abbrev") { abbrev_shndx = i; // Correct the offset. For incremental update links, we have a @@ -317,7 +318,7 @@ Dwarf_ranges_table::read_ranges_table( for (unsigned int i = 1; i < object->shnum(); ++i) { std::string name = object->section_name(i); - if (name == ".debug_ranges") + if (name == ".debug_ranges" || name == ".zdebug_ranges") { ranges_shndx = i; this->output_section_offset_ = object->output_section_offset(i); @@ -486,24 +487,36 @@ Dwarf_pubnames_table::read_section(Relobj* object, const unsigned char* symtab, { section_size_type buffer_size; unsigned int shndx = 0; + const char* name = this->is_pubtypes_ ? "pubtypes" : "pubnames"; + const char* gnu_name = (this->is_pubtypes_ + ? "gnu_pubtypes" + : "gnu_pubnames"); - // Find the .debug_pubnames/pubtypes section. - const char* name = (this->is_pubtypes_ - ? ".debug_pubtypes" - : ".debug_pubnames"); for (unsigned int i = 1; i < object->shnum(); ++i) { - if (object->section_name(i) == name) + std::string section_name = object->section_name(i); + const char* section_name_suffix = section_name.c_str(); + if (is_prefix_of(".debug_", section_name_suffix)) + section_name_suffix += 7; + else if (is_prefix_of(".zdebug_", section_name_suffix)) + section_name_suffix += 8; + else + continue; + if (strcmp(section_name_suffix, name) == 0) + { + shndx = i; + break; + } + else if (strcmp(section_name_suffix, gnu_name) == 0) { shndx = i; - this->output_section_offset_ = object->output_section_offset(i); + this->is_gnu_style_ = true; break; } } if (shndx == 0) return false; - this->buffer_ = object->decompressed_section_contents(shndx, &buffer_size, &this->owns_buffer_); @@ -545,11 +558,6 @@ Dwarf_pubnames_table::read_header(off_t offset) // Make sure we have actually read the section. gold_assert(this->buffer_ != NULL); - // Correct the offset. For incremental update links, we have a - // relocated offset that is relative to the output section, but - // here we need an offset relative to the input section. - offset -= this->output_section_offset_; - if (offset < 0 || offset + 14 >= this->buffer_end_ - this->buffer_) return false; @@ -570,6 +578,13 @@ Dwarf_pubnames_table::read_header(off_t offset) this->unit_length_ = unit_length + 4; this->offset_size_ = 4; } + this->end_of_table_ = pinfo + unit_length; + + // If unit_length is too big, maybe we should reject the whole table, + // but in cases we know about, it seems OK to assume that the table + // is valid through the actual end of the section. + if (this->end_of_table_ > this->buffer_end_) + this->end_of_table_ = this->buffer_end_; // Check the version. unsigned int version = this->dwinfo_->read_from_pointer<16>(pinfo); @@ -593,20 +608,27 @@ Dwarf_pubnames_table::read_header(off_t offset) // Read the next name from the set. const char* -Dwarf_pubnames_table::next_name() +Dwarf_pubnames_table::next_name(uint8_t* flag_byte) { const unsigned char* pinfo = this->pinfo_; - // Read the offset within the CU. If this is zero, we have reached - // the end of the list. - uint32_t offset; - if (this->offset_size_ == 4) - offset = this->dwinfo_->read_from_pointer<32>(&pinfo); - else - offset = this->dwinfo_->read_from_pointer<64>(&pinfo); - if (offset == 0) + // Check for end of list. The table should be terminated by an + // entry containing nothing but a DIE offset of 0. + if (pinfo + this->offset_size_ >= this->end_of_table_) return NULL; + // Skip the offset within the CU. If this is zero, but we're not + // at the end of the table, then we have a real pubnames entry + // whose DIE offset is 0 (likely to be a GCC bug). Since we + // don't actually use the DIE offset in building .gdb_index, + // it's harmless. + pinfo += this->offset_size_; + + if (this->is_gnu_style_) + *flag_byte = *pinfo++; + else + *flag_byte = 0; + // Return a pointer to the string at the current location, // and advance the pointer to the next entry. const char* ret = reinterpret_cast<const char*>(pinfo); @@ -1334,7 +1356,8 @@ Dwarf_info_reader::do_parse() // Visit the CU or TU. if (this->is_type_unit_) this->visit_type_unit(section_offset + this->cu_offset_, - type_offset, signature, &root_die); + cu_end - cu_start, type_offset, signature, + &root_die); else this->visit_compilation_unit(section_offset + this->cu_offset_, cu_end - cu_start, &root_die); @@ -1365,7 +1388,7 @@ Dwarf_info_reader::do_read_string_table(unsigned int string_shndx) for (unsigned int i = 1; i < this->object_->shnum(); ++i) { std::string name = object->section_name(i); - if (name == ".debug_str") + if (name == ".debug_str" || name == ".zdebug_str") { string_shndx = i; this->string_output_section_offset_ = @@ -1477,7 +1500,7 @@ Dwarf_info_reader::visit_compilation_unit(off_t, off_t, Dwarf_die*) // Process a type unit and parse its child DIE. void -Dwarf_info_reader::visit_type_unit(off_t, off_t, uint64_t, Dwarf_die*) +Dwarf_info_reader::visit_type_unit(off_t, off_t, off_t, uint64_t, Dwarf_die*) { } diff --git a/binutils-2.25/gold/dwarf_reader.h b/binutils-2.25/gold/dwarf_reader.h index 86d80bb..cac413b 100644 --- a/binutils-2.25/gold/dwarf_reader.h +++ b/binutils-2.25/gold/dwarf_reader.h @@ -1,7 +1,6 @@ // dwarf_reader.h -- parse dwarf2/3 debug information for gold -*- C++ -*- -// Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -400,8 +399,9 @@ class Dwarf_pubnames_table public: Dwarf_pubnames_table(Dwarf_info_reader* dwinfo, bool is_pubtypes) : dwinfo_(dwinfo), buffer_(NULL), buffer_end_(NULL), owns_buffer_(false), - offset_size_(0), pinfo_(NULL), is_pubtypes_(is_pubtypes), - output_section_offset_(0), unit_length_(0), cu_offset_(0) + offset_size_(0), pinfo_(NULL), end_of_table_(NULL), + is_pubtypes_(is_pubtypes), is_gnu_style_(false), + unit_length_(0), cu_offset_(0) { } ~Dwarf_pubnames_table() @@ -431,9 +431,10 @@ class Dwarf_pubnames_table subsection_size() { return this->unit_length_; } - // Read the next name from the set. + // Read the next name from the set. If the pubname table is gnu-style, + // FLAG_BYTE is set to the high-byte of a gdb_index version 7 cu_index. const char* - next_name(); + next_name(uint8_t* flag_byte); private: // The Dwarf_info_reader, for reading data. @@ -447,13 +448,13 @@ class Dwarf_pubnames_table unsigned int offset_size_; // The current position within the buffer. const unsigned char* pinfo_; + // The end of the current pubnames table. + const unsigned char* end_of_table_; // TRUE if this is a .debug_pubtypes section. bool is_pubtypes_; - // For incremental update links, this will hold the offset of the - // input section within the output section. Offsets read from - // relocated data will be relative to the output section, and need - // to be corrected before reading data from the input section. - uint64_t output_section_offset_; + // Gnu-style pubnames table. This style has an extra flag byte between the + // offset and the name, and is used for generating version 7 of gdb-index. + bool is_gnu_style_; // Fields read from the header. uint64_t unit_length_; off_t cu_offset_; @@ -803,8 +804,8 @@ class Dwarf_info_reader // Visit a type unit. virtual void - visit_type_unit(off_t tu_offset, off_t type_offset, uint64_t signature, - Dwarf_die* root_die); + visit_type_unit(off_t tu_offset, off_t tu_length, off_t type_offset, + uint64_t signature, Dwarf_die* root_die); // Read the range table. Dwarf_range_list* diff --git a/binutils-2.25/gold/dwp.cc b/binutils-2.25/gold/dwp.cc index 325aa6c..5401e0c 100644 --- a/binutils-2.25/gold/dwp.cc +++ b/binutils-2.25/gold/dwp.cc @@ -1,6 +1,6 @@ // dwp.cc -- DWARF packaging utility -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of dwp, the DWARF packaging utility. @@ -38,6 +38,7 @@ #include "elfcpp.h" #include "elfcpp_file.h" +#include "dwarf.h" #include "dirsearch.h" #include "fileread.h" #include "object.h" @@ -59,7 +60,44 @@ template <int size, bool big_endian> class Sized_relobj_dwo; // List of .dwo files to process. -typedef std::vector<std::string> File_list; +struct Dwo_file_entry +{ + Dwo_file_entry(uint64_t id, std::string name) + : dwo_id(id), dwo_name(name) + { } + uint64_t dwo_id; + std::string dwo_name; +}; +typedef std::vector<Dwo_file_entry> File_list; + +// Type to hold the offset and length of an input section +// within an output section. + +struct Section_bounds +{ + section_offset_type offset; + section_size_type size; + + Section_bounds() + : offset(0), size(0) + { } + + Section_bounds(section_offset_type o, section_size_type s) + : offset(o), size(s) + { } +}; + +// A set of sections for a compilation unit or type unit. + +struct Unit_set +{ + uint64_t signature; + Section_bounds sections[elfcpp::DW_SECT_MAX + 1]; + + Unit_set() + : signature(0), sections() + { } +}; // An input file. // This class may represent a .dwo file, a .dwp file @@ -71,7 +109,7 @@ class Dwo_file public: Dwo_file(const char* name) : name_(name), obj_(NULL), input_file_(NULL), is_compressed_(), - str_offset_map_() + sect_offsets_(), str_offset_map_() { } ~Dwo_file(); @@ -85,6 +123,12 @@ class Dwo_file void read(Dwp_output_file* output_file); + // Verify a .dwp file given a list of .dwo files referenced by the + // corresponding executable file. Returns true if no problems + // were found. + bool + verify(const File_list& files); + private: // Types for mapping input string offsets to output string offsets. typedef std::pair<section_offset_type, section_offset_type> @@ -133,32 +177,35 @@ class Dwo_file section_contents(unsigned int shndx, section_size_type* plen, bool* is_new) { return this->obj_->decompressed_section_contents(shndx, plen, is_new); } - // Read the .debug_cu_index section of a .dwp file, - // and process the CU sets. + // Read the .debug_cu_index or .debug_tu_index section of a .dwp file, + // and process the CU or TU sets. void - read_compunit_index(unsigned int, Dwp_output_file*); + read_unit_index(unsigned int, unsigned int *, Dwp_output_file*, + bool is_tu_index); template <bool big_endian> void - sized_read_compunit_index(unsigned int, Dwp_output_file*); + sized_read_unit_index(unsigned int, unsigned int *, Dwp_output_file*, + bool is_tu_index); - // Read the .debug_tu_index section of a .dwp file, - // and process the TU sets. - void - read_typeunit_index(unsigned int, Dwp_output_file*); + // Verify the .debug_cu_index section of a .dwp file, comparing it + // against the list of .dwo files referenced by the corresponding + // executable file. + bool + verify_dwo_list(unsigned int, const File_list& files); template <bool big_endian> - void - sized_read_typeunit_index(unsigned int, Dwp_output_file*); + bool + sized_verify_dwo_list(unsigned int, const File_list& files); // Merge the input string table section into the output file. void add_strings(Dwp_output_file*, unsigned int); // Copy a section from the input file to the output file. - unsigned int + Section_bounds copy_section(Dwp_output_file* output_file, unsigned int shndx, - const char* section_name, bool is_str_offsets); + elfcpp::DW_SECT section_id); // Remap the string offsets in the .debug_str_offsets.dwo section. const unsigned char* @@ -173,26 +220,11 @@ class Dwo_file unsigned int remap_str_offset(section_offset_type val); - // Add a set of .debug_info and related sections to OUTPUT_FILE. - void - add_cu_set(Dwp_output_file* output_file, - uint64_t dwo_id, - unsigned int debug_info, - unsigned int debug_abbrev, - unsigned int debug_line, - unsigned int debug_loc, - unsigned int debug_str_offsets, - unsigned int debug_macinfo, - unsigned int debug_macro); - - // Add a set of .debug_types and related sections to OUTPUT_FILE. + // Add a set of .debug_info.dwo or .debug_types.dwo and related sections + // to OUTPUT_FILE. void - add_tu_set(Dwp_output_file* output_file, - uint64_t type_sig, - unsigned int debug_types, - unsigned int debug_abbrev, - unsigned int debug_line, - unsigned int debug_str_offsets); + add_unit_set(Dwp_output_file* output_file, unsigned int *debug_shndx, + bool is_debug_types); // The filename. const char* name_; @@ -202,8 +234,8 @@ class Dwo_file Input_file* input_file_; // Flags indicating which sections are compressed. std::vector<bool> is_compressed_; - // Map input section index onto output section index. - std::vector<unsigned int> shndx_map_; + // Map input section index onto output section offset and size. + std::vector<Section_bounds> sect_offsets_; // Map input string offsets to output string offsets. Str_offset_map str_offset_map_; }; @@ -240,7 +272,7 @@ class Sized_relobj_dwo : public Sized_relobj<size, big_endian> // Get the name of a section. std::string - do_section_name(unsigned int shndx) + do_section_name(unsigned int shndx) const { return this->elf_file_.section_name(shndx); } // Get the size of a section. @@ -426,10 +458,11 @@ class Dwp_output_file Dwp_output_file(const char* name) : name_(name), machine_(0), size_(0), big_endian_(false), osabi_(0), abiversion_(0), fd_(NULL), next_file_offset_(0), shnum_(1), sections_(), - shoff_(0), shstrndx_(0), have_strings_(false), stringpool_(), - shstrtab_(), cu_index_(), tu_index_(), last_type_sig_(0), + section_id_map_(), shoff_(0), shstrndx_(0), have_strings_(false), + stringpool_(), shstrtab_(), cu_index_(), tu_index_(), last_type_sig_(0), last_tu_slot_(0) { + this->section_id_map_.resize(elfcpp::DW_SECT_MAX + 1); this->stringpool_.set_no_zero_null(); } @@ -442,17 +475,14 @@ class Dwp_output_file section_offset_type add_string(const char* str, size_t len); - // Add a section to the output file, and return the new section index. - unsigned int - add_section(const char* section_name, const unsigned char* contents, - section_size_type len, int align); + // Add a section to the output file, and return the new section offset. + section_offset_type + add_contribution(elfcpp::DW_SECT section_id, const unsigned char* contents, + section_size_type len, int align); // Add a set of .debug_info and related sections to the output file. void - add_cu_set(uint64_t dwo_id, unsigned int debug_info, - unsigned int debug_abbrev, unsigned int debug_line, - unsigned int debug_loc, unsigned int debug_str_offsets, - unsigned int debug_macinfo, unsigned int debug_macro); + add_cu_set(Unit_set* cu_set); // Lookup a type signature and return TRUE if we have already seen it. bool @@ -460,9 +490,7 @@ class Dwp_output_file // Add a set of .debug_types and related sections to the output file. void - add_tu_set(uint64_t type_sig, unsigned int debug_types, - unsigned int debug_abbrev, unsigned int debug_line, - unsigned int debug_str_offsets); + add_tu_set(Unit_set* tu_set); // Finalize the file, write the string tables and index sections, // and close the file. @@ -470,6 +498,14 @@ class Dwp_output_file finalize(); private: + // Contributions to output sections. + struct Contribution + { + section_offset_type output_offset; + section_size_type size; + const unsigned char* contents; + }; + // Sections in the output file. struct Section { @@ -477,30 +513,23 @@ class Dwp_output_file off_t offset; section_size_type size; int align; - }; + std::vector<Contribution> contributions; - // A set of sections for a compilation unit or type unit. - struct Cu_or_tu_set - { - uint64_t signature; - unsigned int debug_info_or_types; - unsigned int debug_abbrev; - unsigned int debug_line; - unsigned int debug_loc; - unsigned int debug_str_offsets; - unsigned int debug_macinfo; - unsigned int debug_macro; + Section(const char* n, int a) + : name(n), offset(0), size(0), align(a), contributions() + { } }; // The index sections defined by the DWARF Package File Format spec. class Dwp_index { public: - // Vector for the section index pool. - typedef std::vector<unsigned int> Shndx_pool; + // Vector for the section table. + typedef std::vector<const Unit_set*> Section_table; Dwp_index() - : capacity_(0), used_(0), hash_table_(NULL), shndx_pool_() + : capacity_(0), used_(0), hash_table_(NULL), section_table_(), + section_mask_(0) { } ~Dwp_index() @@ -513,7 +542,7 @@ class Dwp_output_file // Enter a CU or TU set at the given SLOT in the hash table. void - enter_set(unsigned int slot, const Cu_or_tu_set& set); + enter_set(unsigned int slot, const Unit_set* set); // Return the contents of the given SLOT in the hash table of signatures. uint64_t @@ -537,18 +566,24 @@ class Dwp_output_file { return this->used_; } // Return an iterator into the shndx pool. - Shndx_pool::const_iterator - shndx_pool() const - { return this->shndx_pool_.begin(); } + Section_table::const_iterator + section_table() const + { return this->section_table_.begin(); } - Shndx_pool::const_iterator - shndx_pool_end() const - { return this->shndx_pool_.end(); } + Section_table::const_iterator + section_table_end() const + { return this->section_table_.end(); } - // Return the number of entries in the shndx pool. + // Return the number of rows in the section table. unsigned int - shndx_pool_size() const - { return this->shndx_pool_.size(); } + section_table_rows() const + { return this->section_table_.size(); } + + // Return the mask indicating which columns will be used + // in the section table. + int + section_table_cols() const + { return this->section_mask_; } private: // Initialize the hash table. @@ -568,13 +603,20 @@ class Dwp_output_file uint64_t* hash_table_; // The storage for the parallel table of shndx pool indexes. uint32_t* index_table_; - // The pool of section indexes. - Shndx_pool shndx_pool_; + // The table of section offsets and sizes. + Section_table section_table_; + // Bit mask to indicate which debug sections are present in the file. + int section_mask_; }; // End class Dwp_output_file::Dwp_index. - // Initialize the output file. + // Add a new output section and return the section index. + unsigned int + add_output_section(const char* section_name, int align); + + // Write a new section to the output file. void - initialize(); + write_new_section(const char* section_name, const unsigned char* contents, + section_size_type len, int align); // Write the ELF header. void @@ -598,6 +640,10 @@ class Dwp_output_file unsigned int link, unsigned int info, unsigned int align, unsigned int ent_size); + // Write the contributions to an output section. + void + write_contributions(const Section& sect); + // Write a CU or TU index section. template<bool big_endian> void @@ -619,6 +665,8 @@ class Dwp_output_file unsigned int shnum_; // Section table. The first entry is shndx 1. std::vector<Section> sections_; + // Section id map. This maps a DW_SECT enum to an shndx. + std::vector<unsigned int> section_id_map_; // File offset of the section header table. off_t shoff_; // Section index of the section string table. @@ -671,43 +719,23 @@ class Dwo_name_info_reader : public Dwarf_info_reader File_list* files_; }; -// A specialization of Dwarf_info_reader, for reading dwo_ids and -// type signatures from DWARF CUs and TUs. +// A specialization of Dwarf_info_reader, for reading DWARF CUs and TUs +// and adding them to the output file. -class Dwo_id_info_reader : public Dwarf_info_reader +class Unit_reader : public Dwarf_info_reader { public: - Dwo_id_info_reader(bool is_type_unit, - Relobj* object, - unsigned int shndx) + Unit_reader(bool is_type_unit, Relobj* object, unsigned int shndx) : Dwarf_info_reader(is_type_unit, object, NULL, 0, shndx, 0, 0), - dwo_id_found_(false), dwo_id_(0), type_sig_found_(false), type_sig_(0) + output_file_(NULL), sections_(NULL) { } - ~Dwo_id_info_reader() + ~Unit_reader() { } - // Return the dwo_id from a DWARF compilation unit DIE in *DWO_ID. - bool - get_dwo_id(uint64_t* dwo_id) - { - this->parse(); - if (!this->dwo_id_found_) - return false; - *dwo_id = this->dwo_id_; - return true; - } - - // Return the type signature from a DWARF type unit DIE in *TYPE_SIG. - bool - get_type_sig(uint64_t* type_sig) - { - this->parse(); - if (!this->type_sig_found_) - return false; - *type_sig = this->type_sig_; - return true; - } + // Read the CUs or TUs and add them to the output file. + void + add_units(Dwp_output_file*, unsigned int debug_abbrev, Section_bounds*); protected: // Visit a compilation unit. @@ -716,20 +744,35 @@ class Dwo_id_info_reader : public Dwarf_info_reader // Visit a type unit. virtual void - visit_type_unit(off_t tu_offset, off_t type_offset, uint64_t signature, - Dwarf_die*); + visit_type_unit(off_t tu_offset, off_t tu_length, off_t type_offset, + uint64_t signature, Dwarf_die*); private: - // TRUE if we found a dwo_id. - bool dwo_id_found_; - // The dwo_id. - uint64_t dwo_id_; - // TRUE if we found a type signature. - bool type_sig_found_; - // The type signature. - uint64_t type_sig_; + Dwp_output_file* output_file_; + Section_bounds* sections_; }; +// Return the name of a DWARF .dwo section. + +static const char* +get_dwarf_section_name(elfcpp::DW_SECT section_id) +{ + static const char* dwarf_section_names[] = { + NULL, // unused + ".debug_info.dwo", // DW_SECT_INFO = 1 + ".debug_types.dwo", // DW_SECT_TYPES = 2 + ".debug_abbrev.dwo", // DW_SECT_ABBREV = 3 + ".debug_line.dwo", // DW_SECT_LINE = 4 + ".debug_loc.dwo", // DW_SECT_LOC = 5 + ".debug_str_offsets.dwo", // DW_SECT_STR_OFFSETS = 6 + ".debug_macinfo.dwo", // DW_SECT_MACINFO = 7 + ".debug_macro.dwo", // DW_SECT_MACRO = 8 + }; + + gold_assert(section_id > 0 && section_id <= elfcpp::DW_SECT_MAX); + return dwarf_section_names[section_id]; +} + // Class Sized_relobj_dwo. // Setup the section information. @@ -819,7 +862,7 @@ Dwo_file::read_executable(File_list* files) unsigned int shnum = this->shnum(); this->is_compressed_.resize(shnum); - this->shndx_map_.resize(shnum); + this->sect_offsets_.resize(shnum); unsigned int debug_info = 0; unsigned int debug_abbrev = 0; @@ -864,22 +907,18 @@ Dwo_file::read(Dwp_output_file* output_file) unsigned int shnum = this->shnum(); this->is_compressed_.resize(shnum); - this->shndx_map_.resize(shnum); + this->sect_offsets_.resize(shnum); typedef std::vector<unsigned int> Types_list; Types_list debug_types; - unsigned int debug_info = 0; - unsigned int debug_abbrev = 0; - unsigned int debug_line = 0; - unsigned int debug_loc = 0; + unsigned int debug_shndx[elfcpp::DW_SECT_MAX + 1]; + for (unsigned int i = 0; i <= elfcpp::DW_SECT_MAX; i++) + debug_shndx[i] = 0; unsigned int debug_str = 0; - unsigned int debug_str_offsets = 0; - unsigned int debug_macinfo = 0; - unsigned int debug_macro = 0; unsigned int debug_cu_index = 0; unsigned int debug_tu_index = 0; - // Scan the section table and look for .dwp index sections. + // Scan the section table and collect debug sections. // (Section index 0 is a dummy section; skip it.) for (unsigned int i = 1; i < shnum; i++) { @@ -896,12 +935,28 @@ Dwo_file::read(Dwp_output_file* output_file) } else continue; - if (strcmp(suffix, "cu_index") == 0) + if (strcmp(suffix, "info.dwo") == 0) + debug_shndx[elfcpp::DW_SECT_INFO] = i; + else if (strcmp(suffix, "types.dwo") == 0) + debug_types.push_back(i); + else if (strcmp(suffix, "abbrev.dwo") == 0) + debug_shndx[elfcpp::DW_SECT_ABBREV] = i; + else if (strcmp(suffix, "line.dwo") == 0) + debug_shndx[elfcpp::DW_SECT_LINE] = i; + else if (strcmp(suffix, "loc.dwo") == 0) + debug_shndx[elfcpp::DW_SECT_LOC] = i; + else if (strcmp(suffix, "str.dwo") == 0) + debug_str = i; + else if (strcmp(suffix, "str_offsets.dwo") == 0) + debug_shndx[elfcpp::DW_SECT_STR_OFFSETS] = i; + else if (strcmp(suffix, "macinfo.dwo") == 0) + debug_shndx[elfcpp::DW_SECT_MACINFO] = i; + else if (strcmp(suffix, "macro.dwo") == 0) + debug_shndx[elfcpp::DW_SECT_MACRO] = i; + else if (strcmp(suffix, "cu_index") == 0) debug_cu_index = i; else if (strcmp(suffix, "tu_index") == 0) debug_tu_index = i; - else if (strcmp(suffix, "str.dwo") == 0) - debug_str = i; } // Merge the input string table into the output string table. @@ -912,14 +967,52 @@ Dwo_file::read(Dwp_output_file* output_file) if (debug_cu_index > 0 || debug_tu_index > 0) { if (debug_cu_index > 0) - this->read_compunit_index(debug_cu_index, output_file); + this->read_unit_index(debug_cu_index, debug_shndx, output_file, false); if (debug_tu_index > 0) - this->read_typeunit_index(debug_tu_index, output_file); + { + if (debug_types.size() > 1) + gold_fatal(_("%s: .dwp file must have no more than one " + ".debug_types.dwo section"), this->name_); + if (debug_types.size() == 1) + debug_shndx[elfcpp::DW_SECT_TYPES] = debug_types[0]; + else + debug_shndx[elfcpp::DW_SECT_TYPES] = 0; + this->read_unit_index(debug_tu_index, debug_shndx, output_file, true); + } return; } // If we found no index sections, this is a .dwo file. - // Scan the section table and collect the debug sections. + if (debug_shndx[elfcpp::DW_SECT_INFO] > 0) + this->add_unit_set(output_file, debug_shndx, false); + + debug_shndx[elfcpp::DW_SECT_INFO] = 0; + for (Types_list::const_iterator tp = debug_types.begin(); + tp != debug_types.end(); + ++tp) + { + debug_shndx[elfcpp::DW_SECT_TYPES] = *tp; + this->add_unit_set(output_file, debug_shndx, true); + } +} + +// Verify a .dwp file given a list of .dwo files referenced by the +// corresponding executable file. Returns true if no problems +// were found. + +bool +Dwo_file::verify(const File_list& files) +{ + this->obj_ = this->make_object(NULL); + + unsigned int shnum = this->shnum(); + this->is_compressed_.resize(shnum); + this->sect_offsets_.resize(shnum); + + unsigned int debug_cu_index = 0; + + // Scan the section table and collect debug sections. + // (Section index 0 is a dummy section; skip it.) for (unsigned int i = 1; i < shnum; i++) { if (this->section_type(i) != elfcpp::SHT_PROGBITS) @@ -929,57 +1022,20 @@ Dwo_file::read(Dwp_output_file* output_file) if (is_prefix_of(".debug_", suffix)) suffix += 7; else if (is_prefix_of(".zdebug_", suffix)) - suffix += 8; + { + this->is_compressed_[i] = true; + suffix += 8; + } else continue; - // TODO: Check for one of each section (except .debug_types). - if (strcmp(suffix, "info.dwo") == 0) - debug_info = i; - else if (strcmp(suffix, "types.dwo") == 0) - debug_types.push_back(i); - else if (strcmp(suffix, "abbrev.dwo") == 0) - debug_abbrev = i; - else if (strcmp(suffix, "line.dwo") == 0) - debug_line = i; - else if (strcmp(suffix, "loc.dwo") == 0) - debug_loc = i; - else if (strcmp(suffix, "str_offsets.dwo") == 0) - debug_str_offsets = i; - else if (strcmp(suffix, "macinfo.dwo") == 0) - debug_macinfo = i; - else if (strcmp(suffix, "macro.dwo") == 0) - debug_macro = i; + if (strcmp(suffix, "cu_index") == 0) + debug_cu_index = i; } - if (debug_info > 0) - { - // Extract the dwo_id from .debug_info.dwo section. - uint64_t dwo_id; - Dwo_id_info_reader dwarf_reader(false, this->obj_, debug_info); - dwarf_reader.set_abbrev_shndx(debug_abbrev); - if (!dwarf_reader.get_dwo_id(&dwo_id)) - gold_fatal(_("%s: .debug_info.dwo section does not have DW_AT_GNU_dwo_id " - "attribute"), this->name_); - this->add_cu_set(output_file, dwo_id, debug_info, debug_abbrev, - debug_line, debug_loc, debug_str_offsets, - debug_macinfo, debug_macro); - } + if (debug_cu_index == 0) + gold_fatal(_("%s: no .debug_cu_index section found"), this->name_); - for (Types_list::const_iterator tp = debug_types.begin(); - tp != debug_types.end(); - ++tp) - { - // Extract the type signature from .debug_types.dwo section. - uint64_t type_sig; - gold_assert(*tp > 0); - Dwo_id_info_reader dwarf_reader(true, this->obj_, *tp); - dwarf_reader.set_abbrev_shndx(debug_abbrev); - if (!dwarf_reader.get_type_sig(&type_sig)) - gold_fatal(_("%s: .debug_types.dwo section does not have type signature"), - this->name_); - this->add_tu_set(output_file, type_sig, *tp, debug_abbrev, debug_line, - debug_str_offsets); - } + return this->verify_dwo_list(debug_cu_index, files); } // Create a Sized_relobj_dwo of the given size and endianness, @@ -1074,152 +1130,200 @@ Dwo_file::sized_make_object(const unsigned char* p, Input_file* input_file, return obj; } -// Read the .debug_cu_index section of a .dwp file, -// and process the CU sets. +// Read the .debug_cu_index or .debug_tu_index section of a .dwp file, +// and process the CU or TU sets. void -Dwo_file::read_compunit_index(unsigned int shndx, Dwp_output_file* output_file) +Dwo_file::read_unit_index(unsigned int shndx, unsigned int *debug_shndx, + Dwp_output_file* output_file, bool is_tu_index) { if (this->obj_->is_big_endian()) - this->sized_read_compunit_index<true>(shndx, output_file); + this->sized_read_unit_index<true>(shndx, debug_shndx, output_file, + is_tu_index); else - this->sized_read_compunit_index<false>(shndx, output_file); + this->sized_read_unit_index<false>(shndx, debug_shndx, output_file, + is_tu_index); } template <bool big_endian> void -Dwo_file::sized_read_compunit_index(unsigned int shndx, - Dwp_output_file* output_file) +Dwo_file::sized_read_unit_index(unsigned int shndx, + unsigned int *debug_shndx, + Dwp_output_file* output_file, + bool is_tu_index) { - section_size_type len; - bool is_new; - const unsigned char* contents = this->section_contents(shndx, &len, &is_new); + elfcpp::DW_SECT info_sect = (is_tu_index + ? elfcpp::DW_SECT_TYPES + : elfcpp::DW_SECT_INFO); + unsigned int info_shndx = debug_shndx[info_sect]; + + gold_assert(shndx > 0); + + section_size_type index_len; + bool index_is_new; + const unsigned char* contents = + this->section_contents(shndx, &index_len, &index_is_new); unsigned int version = elfcpp::Swap_unaligned<32, big_endian>::readval(contents); - if (version != 1) - gold_fatal(_("%s: .debug_cu_index has unsupported version number %d"), - this->name_, version); + // We don't support version 1 anymore because it was experimental + // and because in normal use, dwp is not expected to read .dwp files + // produced by an earlier version of the tool. + if (version != 2) + gold_fatal(_("%s: section %s has unsupported version number %d"), + this->name_, this->section_name(shndx).c_str(), version); + + unsigned int ncols = + elfcpp::Swap_unaligned<32, big_endian>::readval(contents + + sizeof(uint32_t)); unsigned int nused = elfcpp::Swap_unaligned<32, big_endian>::readval(contents + 2 * sizeof(uint32_t)); - if (nused == 0) + if (ncols == 0 || nused == 0) return; + gold_assert(info_shndx > 0); + unsigned int nslots = elfcpp::Swap_unaligned<32, big_endian>::readval(contents + 3 * sizeof(uint32_t)); const unsigned char* phash = contents + 4 * sizeof(uint32_t); const unsigned char* pindex = phash + nslots * sizeof(uint64_t); - const unsigned char* shndx_pool = pindex + nslots * sizeof(uint32_t); - const unsigned char* limit = contents + len; + const unsigned char* pcolhdrs = pindex + nslots * sizeof(uint32_t); + const unsigned char* poffsets = pcolhdrs + ncols * sizeof(uint32_t); + const unsigned char* psizes = poffsets + nused * ncols * sizeof(uint32_t); + const unsigned char* pend = psizes + nused * ncols * sizeof(uint32_t); + + if (pend > contents + index_len) + gold_fatal(_("%s: section %s is corrupt"), this->name_, + this->section_name(shndx).c_str()); + + // Copy the related sections and track the section offsets and sizes. + Section_bounds sections[elfcpp::DW_SECT_MAX + 1]; + for (int i = elfcpp::DW_SECT_ABBREV; i <= elfcpp::DW_SECT_MAX; ++i) + { + if (debug_shndx[i] > 0) + sections[i] = this->copy_section(output_file, debug_shndx[i], + static_cast<elfcpp::DW_SECT>(i)); + } - if (shndx_pool >= limit) - gold_fatal(_("%s: .debug_cu_index is corrupt"), this->name_); + // Get the contents of the .debug_info.dwo or .debug_types.dwo section. + section_size_type info_len; + bool info_is_new; + const unsigned char* info_contents = + this->section_contents(info_shndx, &info_len, &info_is_new); // Loop over the slots of the hash table. for (unsigned int i = 0; i < nslots; ++i) { - uint64_t dwo_id = + uint64_t signature = elfcpp::Swap_unaligned<64, big_endian>::readval(phash); - if (dwo_id != 0) + unsigned int index = + elfcpp::Swap_unaligned<32, big_endian>::readval(pindex); + if (index != 0 && (!is_tu_index || !output_file->lookup_tu(signature))) { - unsigned int index = - elfcpp::Swap_unaligned<32, big_endian>::readval(pindex); - const unsigned char* shndx_list = - shndx_pool + index * sizeof(uint32_t); - - // Collect the debug sections for this compilation unit set. - unsigned int debug_info = 0; - unsigned int debug_abbrev = 0; - unsigned int debug_line = 0; - unsigned int debug_loc = 0; - unsigned int debug_str_offsets = 0; - unsigned int debug_macinfo = 0; - unsigned int debug_macro = 0; - for (;;) + Unit_set* unit_set = new Unit_set(); + unit_set->signature = signature; + const unsigned char* pch = pcolhdrs; + const unsigned char* porow = + poffsets + (index - 1) * ncols * sizeof(uint32_t); + const unsigned char* psrow = + psizes + (index - 1) * ncols * sizeof(uint32_t); + + // Adjust the offset of each contribution within the input section + // by the offset of the input section within the output section. + for (unsigned int j = 0; j <= ncols; j++) { - if (shndx_list >= limit) - gold_fatal(_("%s: .debug_cu_index is corrupt"), - this->name_); - unsigned int shndx = - elfcpp::Swap_unaligned<32, big_endian>::readval(shndx_list); - if (shndx == 0) - break; - if (shndx > this->shnum()) - gold_fatal(_("%s: .debug_cu_index has bad shndx"), - this->name_); - std::string sect_name = this->section_name(shndx); - const char* suffix = sect_name.c_str(); - if (is_prefix_of(".debug_", suffix)) - suffix += 7; - else if (is_prefix_of(".zdebug_", suffix)) - suffix += 8; - else - gold_fatal(_("%s: .debug_cu_index refers to " - "non-debug section"), this->name_); - if (strcmp(suffix, "info.dwo") == 0) - debug_info = shndx; - else if (strcmp(suffix, "abbrev.dwo") == 0) - debug_abbrev = shndx; - else if (strcmp(suffix, "line.dwo") == 0) - debug_line = shndx; - else if (strcmp(suffix, "loc.dwo") == 0) - debug_loc = shndx; - else if (strcmp(suffix, "str_offsets.dwo") == 0) - debug_str_offsets = shndx; - else if (strcmp(suffix, "macinfo.dwo") == 0) - debug_macinfo = shndx; - else if (strcmp(suffix, "macro.dwo") == 0) - debug_macro = shndx; - shndx_list += sizeof(uint32_t); + unsigned int dw_sect = + elfcpp::Swap_unaligned<64, big_endian>::readval(pch); + unsigned int offset = + elfcpp::Swap_unaligned<64, big_endian>::readval(porow); + unsigned int size = + elfcpp::Swap_unaligned<64, big_endian>::readval(psrow); + unit_set->sections[dw_sect].offset = (sections[dw_sect].offset + + offset); + unit_set->sections[dw_sect].size = size; + pch += sizeof(uint32_t); + porow += sizeof(uint32_t); + psrow += sizeof(uint32_t); } - this->add_cu_set(output_file, dwo_id, debug_info, debug_abbrev, - debug_line, debug_loc, debug_str_offsets, - debug_macinfo, debug_macro); + + const unsigned char* unit_start = + info_contents + unit_set->sections[info_sect].offset; + section_size_type unit_length = unit_set->sections[info_sect].size; + + // Dwp_output_file::add_contribution writes the .debug_info.dwo + // section directly to the output file, so we only need to + // duplicate contributions for .debug_types.dwo section. + if (is_tu_index) + { + unsigned char *copy = new unsigned char[unit_length]; + memcpy(copy, unit_start, unit_length); + unit_start = copy; + } + section_offset_type off = + output_file->add_contribution(info_sect, unit_start, + unit_length, 1); + unit_set->sections[info_sect].offset = off; + if (is_tu_index) + output_file->add_tu_set(unit_set); + else + output_file->add_cu_set(unit_set); } phash += sizeof(uint64_t); pindex += sizeof(uint32_t); } - if (is_new) + if (index_is_new) delete[] contents; + if (info_is_new) + delete[] info_contents; } -// Read the .debug_tu_index section of a .dwp file, -// and process the TU sets. +// Verify the .debug_cu_index section of a .dwp file, comparing it +// against the list of .dwo files referenced by the corresponding +// executable file. -void -Dwo_file::read_typeunit_index(unsigned int shndx, Dwp_output_file* output_file) +bool +Dwo_file::verify_dwo_list(unsigned int shndx, const File_list& files) { if (this->obj_->is_big_endian()) - this->sized_read_typeunit_index<true>(shndx, output_file); + return this->sized_verify_dwo_list<true>(shndx, files); else - this->sized_read_typeunit_index<false>(shndx, output_file); + return this->sized_verify_dwo_list<false>(shndx, files); } template <bool big_endian> -void -Dwo_file::sized_read_typeunit_index(unsigned int shndx, - Dwp_output_file* output_file) +bool +Dwo_file::sized_verify_dwo_list(unsigned int shndx, const File_list& files) { - section_size_type len; - bool is_new; - const unsigned char* contents = this->section_contents(shndx, &len, &is_new); + gold_assert(shndx > 0); + + section_size_type index_len; + bool index_is_new; + const unsigned char* contents = + this->section_contents(shndx, &index_len, &index_is_new); unsigned int version = elfcpp::Swap_unaligned<32, big_endian>::readval(contents); - if (version != 1) - gold_fatal(_("%s: .debug_tu_index has unsupported version number %d"), - this->name_, version); + // We don't support version 1 anymore because it was experimental + // and because in normal use, dwp is not expected to read .dwp files + // produced by an earlier version of the tool. + if (version != 2) + gold_fatal(_("%s: section %s has unsupported version number %d"), + this->name_, this->section_name(shndx).c_str(), version); + + unsigned int ncols = + elfcpp::Swap_unaligned<32, big_endian>::readval(contents + + sizeof(uint32_t)); unsigned int nused = elfcpp::Swap_unaligned<32, big_endian>::readval(contents + 2 * sizeof(uint32_t)); - if (nused == 0) - return; + if (ncols == 0 || nused == 0) + return true; unsigned int nslots = elfcpp::Swap_unaligned<32, big_endian>::readval(contents @@ -1227,69 +1331,51 @@ Dwo_file::sized_read_typeunit_index(unsigned int shndx, const unsigned char* phash = contents + 4 * sizeof(uint32_t); const unsigned char* pindex = phash + nslots * sizeof(uint64_t); - const unsigned char* shndx_pool = pindex + nslots * sizeof(uint32_t); - const unsigned char* limit = contents + len; + const unsigned char* pcolhdrs = pindex + nslots * sizeof(uint32_t); + const unsigned char* poffsets = pcolhdrs + ncols * sizeof(uint32_t); + const unsigned char* psizes = poffsets + nused * ncols * sizeof(uint32_t); + const unsigned char* pend = psizes + nused * ncols * sizeof(uint32_t); - if (shndx_pool >= limit) - gold_fatal(_("%s: .debug_tu_index is corrupt"), this->name_); + if (pend > contents + index_len) + gold_fatal(_("%s: section %s is corrupt"), this->name_, + this->section_name(shndx).c_str()); - // Loop over the slots of the hash table. - for (unsigned int i = 0; i < nslots; ++i) + int nmissing = 0; + for (File_list::const_iterator f = files.begin(); f != files.end(); ++f) { - uint64_t type_sig = - elfcpp::Swap_unaligned<64, big_endian>::readval(phash); - if (type_sig != 0) + uint64_t dwo_id = f->dwo_id; + unsigned int slot = static_cast<unsigned int>(dwo_id) & (nslots - 1); + const unsigned char* ph = phash + slot * sizeof(uint64_t); + const unsigned char* pi = pindex + slot * sizeof(uint32_t); + uint64_t probe = elfcpp::Swap_unaligned<64, big_endian>::readval(ph); + uint32_t row_index = elfcpp::Swap_unaligned<32, big_endian>::readval(pi); + if (row_index != 0 && probe != dwo_id) { - unsigned int index = - elfcpp::Swap_unaligned<32, big_endian>::readval(pindex); - const unsigned char* shndx_list = - shndx_pool + index * sizeof(uint32_t); - - // Collect the debug sections for this type unit set. - unsigned int debug_types = 0; - unsigned int debug_abbrev = 0; - unsigned int debug_line = 0; - unsigned int debug_str_offsets = 0; - for (;;) + unsigned int h2 = ((static_cast<unsigned int>(dwo_id >> 32) + & (nslots - 1)) | 1); + do { - if (shndx_list >= limit) - gold_fatal(_("%s: .debug_tu_index is corrupt"), - this->name_); - unsigned int shndx = - elfcpp::Swap_unaligned<32, big_endian>::readval(shndx_list); - if (shndx == 0) - break; - if (shndx > this->shnum()) - gold_fatal(_("%s: .debug_tu_index has bad shndx"), - this->name_); - std::string sect_name = this->section_name(shndx); - const char* suffix = sect_name.c_str(); - if (is_prefix_of(".debug_", suffix)) - suffix += 7; - else if (is_prefix_of(".zdebug_", suffix)) - suffix += 8; - else - gold_fatal(_("%s: .debug_tu_index refers to " - "non-debug section"), this->name_); - if (strcmp(suffix, "types.dwo") == 0) - debug_types = shndx; - else if (strcmp(suffix, "abbrev.dwo") == 0) - debug_abbrev = shndx; - else if (strcmp(suffix, "line.dwo") == 0) - debug_line = shndx; - else if (strcmp(suffix, "str_offsets.dwo") == 0) - debug_str_offsets = shndx; - shndx_list += sizeof(uint32_t); - } - this->add_tu_set(output_file, type_sig, debug_types, debug_abbrev, - debug_line, debug_str_offsets); + slot = (slot + h2) & (nslots - 1); + ph = phash + slot * sizeof(uint64_t); + pi = pindex + slot * sizeof(uint32_t); + probe = elfcpp::Swap_unaligned<64, big_endian>::readval(ph); + row_index = elfcpp::Swap_unaligned<32, big_endian>::readval(pi); + } while (row_index != 0 && probe != dwo_id); + } + if (row_index == 0) + { + printf(_("missing .dwo file: %016llx %s\n"), + static_cast<long long>(dwo_id), f->dwo_name.c_str()); + ++nmissing; } - phash += sizeof(uint64_t); - pindex += sizeof(uint32_t); } - if (is_new) + gold_info(_("Found %d missing .dwo files"), nmissing); + + if (index_is_new) delete[] contents; + + return nmissing == 0; } // Merge the input string table section into the output file. @@ -1335,37 +1421,51 @@ Dwo_file::add_strings(Dwp_output_file* output_file, unsigned int debug_str) } // Copy a section from the input file to the output file. -// If IS_STR_OFFSETS is true, remap the string offsets for the -// output string table. +// Return the offset and length of this input section's contribution +// in the output section. If copying .debug_str_offsets.dwo, remap +// the string offsets for the output string table. -unsigned int +Section_bounds Dwo_file::copy_section(Dwp_output_file* output_file, unsigned int shndx, - const char* section_name, bool is_str_offsets) + elfcpp::DW_SECT section_id) { // Some sections may be referenced from more than one set. // Don't copy a section more than once. - if (this->shndx_map_[shndx] > 0) - return this->shndx_map_[shndx]; + if (this->sect_offsets_[shndx].size > 0) + return this->sect_offsets_[shndx]; + // Get the section contents. Upon return, if IS_NEW is true, the memory + // has been allocated via new; if false, the memory is part of the mapped + // input file, and we will need to duplicate it so that it will persist + // after we close the input file. section_size_type len; bool is_new; const unsigned char* contents = this->section_contents(shndx, &len, &is_new); - if (is_str_offsets) + if (section_id == elfcpp::DW_SECT_STR_OFFSETS) { const unsigned char* remapped = this->remap_str_offsets(contents, len); if (is_new) delete[] contents; contents = remapped; - is_new = true; + } + else if (!is_new) + { + unsigned char* copy = new unsigned char[len]; + memcpy(copy, contents, len); + contents = copy; } - this->shndx_map_[shndx] = output_file->add_section(section_name, contents, - len, 1); - if (is_new) - delete[] contents; + // Add the contents of the input section to the output section. + // The output file takes ownership of the memory pointed to by CONTENTS. + section_offset_type off = output_file->add_contribution(section_id, contents, + len, 1); - return this->shndx_map_[shndx]; + // Store the output section bounds. + Section_bounds bounds(off, len); + this->sect_offsets_[shndx] = bounds; + + return bounds; } // Remap the @@ -1425,85 +1525,36 @@ Dwo_file::remap_str_offset(section_offset_type val) return p->second + (val - p->first); } -// Add a set of .debug_info and related sections to OUTPUT_FILE. +// Add a set of .debug_info.dwo or .debug_types.dwo and related sections +// to OUTPUT_FILE. void -Dwo_file::add_cu_set(Dwp_output_file* output_file, - uint64_t dwo_id, - unsigned int debug_info, - unsigned int debug_abbrev, - unsigned int debug_line, - unsigned int debug_loc, - unsigned int debug_str_offsets, - unsigned int debug_macinfo, - unsigned int debug_macro) +Dwo_file::add_unit_set(Dwp_output_file* output_file, unsigned int *debug_shndx, + bool is_debug_types) { - if (debug_info == 0) - gold_fatal(_("%s: no .debug_info.dwo section found"), this->name_); - if (debug_abbrev == 0) - gold_fatal(_("%s: no .debug_abbrev.dwo section found"), this->name_); - - debug_abbrev = this->copy_section(output_file, debug_abbrev, - ".debug_abbrev.dwo", false); - if (debug_line > 0) - debug_line = this->copy_section(output_file, debug_line, - ".debug_line.dwo", false); - if (debug_loc > 0) - debug_loc = this->copy_section(output_file, debug_loc, ".debug_loc.dwo", - false); - if (debug_macinfo > 0) - debug_macinfo = this->copy_section(output_file, debug_macinfo, - ".debug_macinfo.dwo", false); - if (debug_macro > 0) - debug_macro = this->copy_section(output_file, debug_macro, - ".debug_macro.dwo", false); - - if (debug_str_offsets > 0) - debug_str_offsets = this->copy_section(output_file, debug_str_offsets, - ".debug_str_offsets.dwo", true); - - debug_info = this->copy_section(output_file, debug_info, ".debug_info.dwo", - false); - - output_file->add_cu_set(dwo_id, debug_info, debug_abbrev, debug_line, - debug_loc, debug_str_offsets, debug_macinfo, - debug_macro); -} + unsigned int shndx = (is_debug_types + ? debug_shndx[elfcpp::DW_SECT_TYPES] + : debug_shndx[elfcpp::DW_SECT_INFO]); -// Add a set of .debug_types and related sections to OUTPUT_FILE. + gold_assert(shndx != 0); -void -Dwo_file::add_tu_set(Dwp_output_file* output_file, - uint64_t type_sig, - unsigned int debug_types, - unsigned int debug_abbrev, - unsigned int debug_line, - unsigned int debug_str_offsets) -{ - if (debug_types == 0) - gold_fatal(_("%s: no .debug_types.dwo section found"), this->name_); - if (debug_abbrev == 0) + if (debug_shndx[elfcpp::DW_SECT_ABBREV] == 0) gold_fatal(_("%s: no .debug_abbrev.dwo section found"), this->name_); - // Ignore duplicate type signatures. - if (output_file->lookup_tu(type_sig)) - return; - - debug_abbrev = this->copy_section(output_file, debug_abbrev, - ".debug_abbrev.dwo", false); - if (debug_line > 0) - debug_line = this->copy_section(output_file, debug_line, - ".debug_line.dwo", false); - - if (debug_str_offsets > 0) - debug_str_offsets = this->copy_section(output_file, debug_str_offsets, - ".debug_str_offsets.dwo", true); - - debug_types = this->copy_section(output_file, debug_types, - ".debug_types.dwo", false); + // Copy the related sections and track the section offsets and sizes. + Section_bounds sections[elfcpp::DW_SECT_MAX + 1]; + for (int i = elfcpp::DW_SECT_ABBREV; i <= elfcpp::DW_SECT_MAX; ++i) + { + if (debug_shndx[i] > 0) + sections[i] = this->copy_section(output_file, debug_shndx[i], + static_cast<elfcpp::DW_SECT>(i)); + } - output_file->add_tu_set(type_sig, debug_types, debug_abbrev, debug_line, - debug_str_offsets); + // Parse the .debug_info or .debug_types section and add each compilation + // or type unit to the output file, along with the contributions to the + // related sections. + Unit_reader reader(is_debug_types, this->obj_, shndx); + reader.add_units(output_file, debug_shndx[elfcpp::DW_SECT_ABBREV], sections); } // Class Dwp_output_file. @@ -1568,48 +1619,99 @@ align_offset(off_t off, int align) return (off + align - 1) & ~(align - 1); } -// Add a section to the output file, and return the new section index. +// Add a new output section and return the section index. unsigned int -Dwp_output_file::add_section(const char* section_name, - const unsigned char* contents, - section_size_type len, - int align) +Dwp_output_file::add_output_section(const char* section_name, int align) { - off_t file_offset = this->next_file_offset_; - gold_assert(this->size_ > 0 && file_offset > 0); + Section sect(section_name, align); + this->sections_.push_back(sect); + return this->shnum_++; +} - file_offset = align_offset(file_offset, align); +// Add a contribution to a section in the output file, and return the offset +// of the contribution within the output section. The .debug_info.dwo section +// is expected to be the largest one, so we will write the contents of this +// section directly to the output file as we receive contributions, allowing +// us to free that memory as soon as possible. We will save the remaining +// contributions until we finalize the layout of the output file. - ::fseek(this->fd_, file_offset, SEEK_SET); - if (::fwrite(contents, 1, len, this->fd_) < len) - gold_fatal(_("%s: error writing section '%s'"), this->name_, section_name); +section_offset_type +Dwp_output_file::add_contribution(elfcpp::DW_SECT section_id, + const unsigned char* contents, + section_size_type len, + int align) +{ + const char* section_name = get_dwarf_section_name(section_id); + gold_assert(static_cast<size_t>(section_id) < this->section_id_map_.size()); + unsigned int shndx = this->section_id_map_[section_id]; - section_name = this->shstrtab_.add_with_length(section_name, - strlen(section_name), - false, NULL); - Section sect = { section_name, file_offset, len, align }; - this->sections_.push_back(sect); + // Create the section if necessary. + if (shndx == 0) + { + section_name = this->shstrtab_.add_with_length(section_name, + strlen(section_name), + false, NULL); + shndx = this->add_output_section(section_name, align); + this->section_id_map_[section_id] = shndx; + } - this->next_file_offset_ = file_offset + len; - return this->shnum_++; + Section& section = this->sections_[shndx - 1]; + + section_offset_type section_offset; + + if (section_id == elfcpp::DW_SECT_INFO) + { + // Write the .debug_info.dwo section directly. + // We do not need to free the memory in this case. + off_t file_offset = this->next_file_offset_; + gold_assert(this->size_ > 0 && file_offset > 0); + + file_offset = align_offset(file_offset, align); + if (section.offset == 0) + section.offset = file_offset; + + if (align > section.align) + { + // Since we've already committed to the layout for this + // section, an unexpected large alignment boundary may + // be impossible to honor. + if (align_offset(section.offset, align) != section.offset) + gold_fatal(_("%s: alignment (%d) for section '%s' " + "cannot be honored"), + this->name_, align, section_name); + section.align = align; + } + + section_offset = file_offset - section.offset; + section.size = file_offset + len - section.offset; + + ::fseek(this->fd_, file_offset, SEEK_SET); + if (::fwrite(contents, 1, len, this->fd_) < len) + gold_fatal(_("%s: error writing section '%s'"), this->name_, + section_name); + this->next_file_offset_ = file_offset + len; + } + else + { + // Collect the contributions and keep track of the total size. + if (align > section.align) + section.align = align; + section_offset = align_offset(section.size, align); + section.size = section_offset + len; + Contribution contrib = { section_offset, len, contents }; + section.contributions.push_back(contrib); + } + + return section_offset; } // Add a set of .debug_info and related sections to the output file. void -Dwp_output_file::add_cu_set(uint64_t dwo_id, - unsigned int debug_info, - unsigned int debug_abbrev, - unsigned int debug_line, - unsigned int debug_loc, - unsigned int debug_str_offsets, - unsigned int debug_macinfo, - unsigned int debug_macro) +Dwp_output_file::add_cu_set(Unit_set* cu_set) { - Cu_or_tu_set cu_set = { dwo_id, debug_info, debug_abbrev, debug_line, - debug_loc, debug_str_offsets, debug_macinfo, - debug_macro }; + uint64_t dwo_id = cu_set->signature; unsigned int slot; if (!this->cu_index_.find_or_add(dwo_id, &slot)) this->cu_index_.enter_set(slot, cu_set); @@ -1629,14 +1731,9 @@ Dwp_output_file::lookup_tu(uint64_t type_sig) // Add a set of .debug_types and related sections to the output file. void -Dwp_output_file::add_tu_set(uint64_t type_sig, - unsigned int debug_types, - unsigned int debug_abbrev, - unsigned int debug_line, - unsigned int debug_str_offsets) +Dwp_output_file::add_tu_set(Unit_set* tu_set) { - Cu_or_tu_set tu_set = { type_sig, debug_types, debug_abbrev, debug_line, - 0, debug_str_offsets, 0, 0 }; + uint64_t type_sig = tu_set->signature; unsigned int slot; if (type_sig == this->last_type_sig_) slot = this->last_tu_slot_; @@ -1658,7 +1755,8 @@ Dwp_output_file::Dwp_index::find_or_add(uint64_t signature, static_cast<unsigned int>(signature) & (this->capacity_ - 1); unsigned int secondary_hash; uint64_t probe = this->hash_table_[slot]; - if (probe != 0 && probe != signature) + uint32_t row_index = this->index_table_[slot]; + if (row_index != 0 && probe != signature) { secondary_hash = (static_cast<unsigned int>(signature >> 32) & (this->capacity_ - 1)) | 1; @@ -1666,42 +1764,34 @@ Dwp_output_file::Dwp_index::find_or_add(uint64_t signature, { slot = (slot + secondary_hash) & (this->capacity_ - 1); probe = this->hash_table_[slot]; - } while (probe != 0 && probe != signature); + row_index = this->index_table_[slot]; + } while (row_index != 0 && probe != signature); } *slotp = slot; - return (probe != 0); + return (row_index != 0); } // Enter a CU or TU set at the given SLOT in the hash table. void Dwp_output_file::Dwp_index::enter_set(unsigned int slot, - const Cu_or_tu_set& set) + const Unit_set* set) { gold_assert(slot < this->capacity_); - gold_assert(set.debug_info_or_types > 0); - gold_assert(set.debug_abbrev > 0); - - // Add the section indexes to the pool. - uint32_t pool_index = this->shndx_pool_.size(); - this->shndx_pool_.push_back(set.debug_info_or_types); - this->shndx_pool_.push_back(set.debug_abbrev); - if (set.debug_line > 0) - this->shndx_pool_.push_back(set.debug_line); - if (set.debug_loc > 0) - this->shndx_pool_.push_back(set.debug_loc); - if (set.debug_str_offsets > 0) - this->shndx_pool_.push_back(set.debug_str_offsets); - if (set.debug_macinfo > 0) - this->shndx_pool_.push_back(set.debug_macinfo); - if (set.debug_macro > 0) - this->shndx_pool_.push_back(set.debug_macro); - this->shndx_pool_.push_back(0); + + // Add a row to the offsets and sizes tables. + this->section_table_.push_back(set); + uint32_t row_index = this->section_table_rows(); + + // Mark the sections used in this set. + for (unsigned int i = 1; i <= elfcpp::DW_SECT_MAX; i++) + if (set->sections[i].size > 0) + this->section_mask_ |= 1 << i; // Enter the signature and pool index into the hash table. gold_assert(this->hash_table_[slot] == 0); - this->hash_table_[slot] = set.signature; - this->index_table_[slot] = pool_index; + this->hash_table_[slot] = set->signature; + this->index_table_[slot] = row_index; ++this->used_; // Grow the hash table when we exceed 2/3 capacity. @@ -1741,13 +1831,14 @@ Dwp_output_file::Dwp_index::grow() for (unsigned int i = 0; i < old_capacity; ++i) { uint64_t signature = old_hash_table[i]; - if (signature != 0) + uint32_t row_index = old_index_table[i]; + if (row_index != 0) { unsigned int slot; bool found = this->find_or_add(signature, &slot); gold_assert(!found); this->hash_table_[slot] = signature; - this->index_table_[slot] = old_index_table[i]; + this->index_table_[slot] = row_index; ++this->used_; } } @@ -1757,16 +1848,6 @@ Dwp_output_file::Dwp_index::grow() delete[] old_index_table; } -// Initialize the output file. - -void -Dwp_output_file::initialize() -{ - // We can't initialize the output file until we've recorded the - // target info from the first input file. - gold_assert(this->size_ > 0); -} - // Finalize the file, write the string tables and index sections, // and close the file. @@ -1775,6 +1856,20 @@ Dwp_output_file::finalize() { unsigned char* buf; + // Write the accumulated output sections. + for (unsigned int i = 0; i < this->sections_.size(); i++) + { + Section& sect = this->sections_[i]; + // If the offset has already been assigned, the section has been written. + if (sect.offset > 0 || sect.size == 0) + continue; + off_t file_offset = this->next_file_offset_; + file_offset = align_offset(file_offset, sect.align); + sect.offset = file_offset; + this->write_contributions(sect); + this->next_file_offset_ = file_offset + sect.size; + } + // Write the debug string table. if (this->have_strings_) { @@ -1782,7 +1877,7 @@ Dwp_output_file::finalize() section_size_type len = this->stringpool_.get_strtab_size(); buf = new unsigned char[len]; this->stringpool_.write_to_buffer(buf, len); - this->add_section(".debug_str.dwo", buf, len, 1); + this->write_new_section(".debug_str.dwo", buf, len, 1); delete[] buf; } @@ -1803,9 +1898,8 @@ Dwp_output_file::finalize() // Write the section string table. this->shstrndx_ = this->shnum_++; const char* shstrtab_name = - this->shstrtab_.add_with_length(".shstrtab", - sizeof(".shstrtab") - 1, - false, NULL); + this->shstrtab_.add_with_length(".shstrtab", sizeof(".shstrtab") - 1, + false, NULL); this->shstrtab_.set_string_offsets(); section_size_type shstrtab_len = this->shstrtab_.get_strtab_size(); buf = new unsigned char[shstrtab_len]; @@ -1851,18 +1945,64 @@ Dwp_output_file::finalize() this->fd_ = NULL; } +// Write the contributions to an output section. + +void +Dwp_output_file::write_contributions(const Section& sect) +{ + for (unsigned int i = 0; i < sect.contributions.size(); ++i) + { + const Contribution& c = sect.contributions[i]; + ::fseek(this->fd_, sect.offset + c.output_offset, SEEK_SET); + if (::fwrite(c.contents, 1, c.size, this->fd_) < c.size) + gold_fatal(_("%s: error writing section '%s'"), this->name_, sect.name); + delete[] c.contents; + } +} + +// Write a new section to the output file. + +void +Dwp_output_file::write_new_section(const char* section_name, + const unsigned char* contents, + section_size_type len, int align) +{ + section_name = this->shstrtab_.add_with_length(section_name, + strlen(section_name), + false, NULL); + unsigned int shndx = this->add_output_section(section_name, align); + Section& section = this->sections_[shndx - 1]; + off_t file_offset = this->next_file_offset_; + file_offset = align_offset(file_offset, align); + section.offset = file_offset; + section.size = len; + ::fseek(this->fd_, file_offset, SEEK_SET); + if (::fwrite(contents, 1, len, this->fd_) < len) + gold_fatal(_("%s: error writing section '%s'"), this->name_, section_name); + this->next_file_offset_ = file_offset + len; +} + // Write a CU or TU index section. + template<bool big_endian> void Dwp_output_file::write_index(const char* sect_name, const Dwp_index& index) { const unsigned int nslots = index.hash_table_total_slots(); const unsigned int nused = index.hash_table_used_slots(); - const unsigned int npool = index.shndx_pool_size(); + const unsigned int nrows = index.section_table_rows(); + + int column_mask = index.section_table_cols(); + unsigned int ncols = 0; + for (unsigned int c = 1; c <= elfcpp::DW_SECT_MAX; ++c) + if (column_mask & (1 << c)) + ncols++; + const unsigned int ntable = (nrows * 2 + 1) * ncols; + const section_size_type index_size = (4 * sizeof(uint32_t) + nslots * sizeof(uint64_t) + nslots * sizeof(uint32_t) - + npool * sizeof(uint32_t)); + + ntable * sizeof(uint32_t)); // Allocate a buffer for the section contents. unsigned char* buf = new unsigned char[index_size]; @@ -1870,9 +2010,9 @@ Dwp_output_file::write_index(const char* sect_name, const Dwp_index& index) // Write the section header: version number, padding, // number of used slots and total number of slots. - elfcpp::Swap_unaligned<32, big_endian>::writeval(p, 1); + elfcpp::Swap_unaligned<32, big_endian>::writeval(p, 2); p += sizeof(uint32_t); - elfcpp::Swap_unaligned<32, big_endian>::writeval(p, 0); + elfcpp::Swap_unaligned<32, big_endian>::writeval(p, ncols); p += sizeof(uint32_t); elfcpp::Swap_unaligned<32, big_endian>::writeval(p, nused); p += sizeof(uint32_t); @@ -1893,19 +2033,59 @@ Dwp_output_file::write_index(const char* sect_name, const Dwp_index& index) p += sizeof(uint32_t); } - // Write the section index pool. - Dwp_index::Shndx_pool::const_iterator pool = index.shndx_pool(); - for (unsigned int i = 0; i < npool; ++i) + // Write the first row of the table of section offsets. + for (unsigned int c = 1; c <= elfcpp::DW_SECT_MAX; ++c) { - gold_assert(pool != index.shndx_pool_end()); - elfcpp::Swap_unaligned<32, big_endian>::writeval(p, *pool); - p += sizeof(uint32_t); - ++pool; + if (column_mask & (1 << c)) + { + elfcpp::Swap_unaligned<32, big_endian>::writeval(p, c); + p += sizeof(uint32_t); + } + } + + // Write the table of section offsets. + Dwp_index::Section_table::const_iterator tbl = index.section_table(); + for (unsigned int r = 0; r < nrows; ++r) + { + gold_assert(tbl != index.section_table_end()); + const Section_bounds* sects = (*tbl)->sections; + for (unsigned int c = 1; c <= elfcpp::DW_SECT_MAX; ++c) + { + if (column_mask & (1 << c)) + { + section_offset_type offset = sects[c].offset; + elfcpp::Swap_unaligned<32, big_endian>::writeval(p, offset); + p += sizeof(uint32_t); + } + else + gold_assert(sects[c].size == 0); + } + ++tbl; + } + + // Write the table of section sizes. + tbl = index.section_table(); + for (unsigned int r = 0; r < nrows; ++r) + { + gold_assert(tbl != index.section_table_end()); + const Section_bounds* sects = (*tbl)->sections; + for (unsigned int c = 1; c <= elfcpp::DW_SECT_MAX; ++c) + { + if (column_mask & (1 << c)) + { + section_size_type size = sects[c].size; + elfcpp::Swap_unaligned<32, big_endian>::writeval(p, size); + p += sizeof(uint32_t); + } + else + gold_assert(sects[c].size == 0); + } + ++tbl; } gold_assert(p == buf + index_size); - this->add_section(sect_name, buf, index_size, sizeof(uint64_t)); + this->write_new_section(sect_name, buf, index_size, sizeof(uint64_t)); delete[] buf; } @@ -2050,29 +2230,76 @@ Dwo_name_info_reader::visit_compilation_unit(off_t, off_t, Dwarf_die* die) { const char* dwo_name = die->string_attribute(elfcpp::DW_AT_GNU_dwo_name); if (dwo_name != NULL) - this->files_->push_back(dwo_name); + { + uint64_t dwo_id = die->uint_attribute(elfcpp::DW_AT_GNU_dwo_id); + this->files_->push_back(Dwo_file_entry(dwo_id, dwo_name)); + } } -// Class Dwo_id_info_reader. +// Class Unit_reader. + +// Read the CUs or TUs and add them to the output file. + +void +Unit_reader::add_units(Dwp_output_file* output_file, + unsigned int debug_abbrev, + Section_bounds* sections) +{ + this->output_file_ = output_file; + this->sections_ = sections; + this->set_abbrev_shndx(debug_abbrev); + this->parse(); +} // Visit a compilation unit. void -Dwo_id_info_reader::visit_compilation_unit(off_t, off_t, Dwarf_die* die) +Unit_reader::visit_compilation_unit(off_t, off_t cu_length, Dwarf_die* die) { - this->dwo_id_ = die->uint_attribute(elfcpp::DW_AT_GNU_dwo_id); - if (this->dwo_id_ != 0) - this->dwo_id_found_ = true; + if (cu_length == 0) + return; + + Unit_set* unit_set = new Unit_set(); + unit_set->signature = die->uint_attribute(elfcpp::DW_AT_GNU_dwo_id); + for (unsigned int i = elfcpp::DW_SECT_ABBREV; i <= elfcpp::DW_SECT_MAX; ++i) + unit_set->sections[i] = this->sections_[i]; + + // Dwp_output_file::add_contribution writes the .debug_info.dwo section + // directly to the output file, so we do not need to duplicate the + // section contents, and add_contribution does not need to free the memory. + section_offset_type off = + this->output_file_->add_contribution(elfcpp::DW_SECT_INFO, + this->buffer_at_offset(0), + cu_length, 1); + Section_bounds bounds(off, cu_length); + unit_set->sections[elfcpp::DW_SECT_INFO] = bounds; + this->output_file_->add_cu_set(unit_set); } // Visit a type unit. void -Dwo_id_info_reader::visit_type_unit(off_t, off_t, uint64_t signature, - Dwarf_die*) +Unit_reader::visit_type_unit(off_t, off_t tu_length, off_t, + uint64_t signature, Dwarf_die*) { - this->type_sig_ = signature; - this->type_sig_found_ = true; + if (tu_length == 0) + return; + if (this->output_file_->lookup_tu(signature)) + return; + + Unit_set* unit_set = new Unit_set(); + unit_set->signature = signature; + for (unsigned int i = elfcpp::DW_SECT_ABBREV; i <= elfcpp::DW_SECT_MAX; ++i) + unit_set->sections[i] = this->sections_[i]; + + unsigned char* contents = new unsigned char[tu_length]; + memcpy(contents, this->buffer_at_offset(0), tu_length); + section_offset_type off = + this->output_file_->add_contribution(elfcpp::DW_SECT_TYPES, contents, + tu_length, 1); + Section_bounds bounds(off, tu_length); + unit_set->sections[elfcpp::DW_SECT_TYPES] = bounds; + this->output_file_->add_tu_set(unit_set); } }; // End namespace gold @@ -2081,12 +2308,17 @@ using namespace gold; // Options. +enum Dwp_options { + VERIFY_ONLY = 0x101, +}; + struct option dwp_options[] = { { "exec", required_argument, NULL, 'e' }, { "help", no_argument, NULL, 'h' }, { "output", required_argument, NULL, 'o' }, { "verbose", no_argument, NULL, 'v' }, + { "verify-only", no_argument, NULL, VERIFY_ONLY }, { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0 } }; @@ -2099,9 +2331,11 @@ usage(FILE* fd, int exit_status) fprintf(fd, _("Usage: %s [options] [file...]\n"), program_name); fprintf(fd, _(" -h, --help Print this help message\n")); fprintf(fd, _(" -e EXE, --exec EXE Get list of dwo files from EXE" - " (defaults output to EXE.dwp)\n")); + " (defaults output to EXE.dwp)\n")); fprintf(fd, _(" -o FILE, --output FILE Set output dwp file name\n")); fprintf(fd, _(" -v, --verbose Verbose output\n")); + fprintf(fd, _(" --verify-only Verify output file against" + " exec file\n")); fprintf(fd, _(" -V, --version Print version number\n")); // REPORT_BUGS_TO is defined in bfd/bfdver.h. @@ -2118,7 +2352,7 @@ print_version() { // This output is intended to follow the GNU standards. printf("GNU dwp %s\n", BFD_VERSION_STRING); - printf(_("Copyright 2012 Free Software Foundation, Inc.\n")); + printf(_("Copyright (C) 2014 Free Software Foundation, Inc.\n")); printf(_("\ This program is free software; you may redistribute it under the terms of\n\ the GNU General Public License version 3 or (at your option) any later version.\n\ @@ -2161,6 +2395,7 @@ main(int argc, char** argv) std::string output_filename; const char* exe_filename = NULL; bool verbose = false; + bool verify_only = false; int c; while ((c = getopt_long(argc, argv, "e:ho:vV", dwp_options, NULL)) != -1) { @@ -2177,6 +2412,9 @@ main(int argc, char** argv) case 'v': verbose = true; break; + case VERIFY_ONLY: + verify_only = true; + break; case 'V': print_version(); case '?': @@ -2193,8 +2431,6 @@ main(int argc, char** argv) output_filename.append(".dwp"); } - Dwp_output_file output_file(output_filename.c_str()); - // Get list of .dwo files from the executable. if (exe_filename != NULL) { @@ -2204,20 +2440,29 @@ main(int argc, char** argv) // Add any additional files listed on command line. for (int i = optind; i < argc; ++i) - files.push_back(argv[i]); + files.push_back(Dwo_file_entry(0, argv[i])); if (exe_filename == NULL && files.empty()) gold_fatal(_("no input files and no executable specified")); + if (verify_only) + { + // Get list of DWO files in the DWP file and compare with + // references found in the EXE file. + Dwo_file dwp_file(output_filename.c_str()); + bool ok = dwp_file.verify(files); + return ok ? EXIT_SUCCESS : EXIT_FAILURE; + } + // Process each file, adding its contents to the output file. + Dwp_output_file output_file(output_filename.c_str()); for (File_list::const_iterator f = files.begin(); f != files.end(); ++f) { if (verbose) - fprintf(stderr, "%s\n", f->c_str()); - Dwo_file dwo_file(f->c_str()); + fprintf(stderr, "%s\n", f->dwo_name.c_str()); + Dwo_file dwo_file(f->dwo_name.c_str()); dwo_file.read(&output_file); } - output_file.finalize(); return EXIT_SUCCESS; diff --git a/binutils-2.25/gold/dwp.h b/binutils-2.25/gold/dwp.h index 25d4f68..6b57eaa 100644 --- a/binutils-2.25/gold/dwp.h +++ b/binutils-2.25/gold/dwp.h @@ -1,6 +1,6 @@ // dwp.h -- general definitions for dwp. -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of dwp, the DWARF packaging utility. @@ -88,6 +88,10 @@ gold_fatal(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1; extern void gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1; +// This function is called to print an informational message. +extern void +gold_info(const char* msg, ...) ATTRIBUTE_PRINTF_1; + #define gold_unreachable() \ (gold::do_gold_unreachable(__FILE__, __LINE__, \ static_cast<const char*>(__FUNCTION__))) diff --git a/binutils-2.25/gold/dynobj.cc b/binutils-2.25/gold/dynobj.cc index ac0c321..baf8489 100644 --- a/binutils-2.25/gold/dynobj.cc +++ b/binutils-2.25/gold/dynobj.cc @@ -1,6 +1,6 @@ // dynobj.cc -- dynamic object support for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -336,6 +336,17 @@ template<int size, bool big_endian> void Sized_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd) { + this->base_read_symbols(sd); +} + +// Read the symbols and sections from a dynamic object. We read the +// dynamic symbols, not the normal symbols. This is common code for +// all target-specific overrides of do_read_symbols(). + +template<int size, bool big_endian> +void +Sized_dynobj<size, big_endian>::base_read_symbols(Read_symbols_data* sd) +{ this->read_section_data(&this->elf_file_, sd); const unsigned char* const pshdrs = sd->section_headers->data(); diff --git a/binutils-2.25/gold/dynobj.h b/binutils-2.25/gold/dynobj.h index e027485..c20ed20 100644 --- a/binutils-2.25/gold/dynobj.h +++ b/binutils-2.25/gold/dynobj.h @@ -1,6 +1,6 @@ // dynobj.h -- dynamic object support for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -203,7 +203,7 @@ class Sized_dynobj : public Dynobj // Get the name of a section. std::string - do_section_name(unsigned int shndx) + do_section_name(unsigned int shndx) const { return this->elf_file_.section_name(shndx); } // Return a view of the contents of a section. Set *PLEN to the @@ -270,6 +270,12 @@ class Sized_dynobj : public Dynobj do_get_global_symbols() const { return this->symbols_; } + protected: + // Read the symbols. This is common code for all target-specific + // overrides of do_read_symbols(). + void + base_read_symbols(Read_symbols_data*); + private: // For convenience. typedef Sized_dynobj<size, big_endian> This; diff --git a/binutils-2.25/gold/ehframe.cc b/binutils-2.25/gold/ehframe.cc index 08a9ec6..c711bac 100644 --- a/binutils-2.25/gold/ehframe.cc +++ b/binutils-2.25/gold/ehframe.cc @@ -1,6 +1,6 @@ // ehframe.cc -- handle exception frame sections for gold -// Copyright 2006, 2007, 2008, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -326,15 +326,16 @@ Eh_frame_hdr::get_fde_addresses(Output_file* of, // Class Fde. // Write the FDE to OVIEW starting at OFFSET. CIE_OFFSET is the -// offset of the CIE in OVIEW. FDE_ENCODING is the encoding, from the -// CIE. ADDRALIGN is the required alignment. ADDRESS is the virtual -// address of OVIEW. Record the FDE pc for EH_FRAME_HDR. Return the -// new offset. +// offset of the CIE in OVIEW. OUTPUT_OFFSET is the offset of the +// Eh_frame section within the output section. FDE_ENCODING is the +// encoding, from the CIE. ADDRALIGN is the required alignment. +// ADDRESS is the virtual address of OVIEW. Record the FDE pc for +// EH_FRAME_HDR. Return the new offset. template<int size, bool big_endian> section_offset_type -Fde::write(unsigned char* oview, section_offset_type offset, - uint64_t address, unsigned int addralign, +Fde::write(unsigned char* oview, section_offset_type output_offset, + section_offset_type offset, uint64_t address, unsigned int addralign, section_offset_type cie_offset, unsigned char fde_encoding, Eh_frame_hdr* eh_frame_hdr) { @@ -389,7 +390,7 @@ Fde::write(unsigned char* oview, section_offset_type offset, // Tell the exception frame header about this FDE. if (eh_frame_hdr != NULL) - eh_frame_hdr->record_fde(offset, fde_encoding); + eh_frame_hdr->record_fde(output_offset + offset, fde_encoding); return offset + aligned_full_length; } @@ -441,17 +442,19 @@ Cie::set_output_offset(section_offset_type output_offset, return output_offset + length; } -// Write the CIE to OVIEW starting at OFFSET. Round up the bytes to -// ADDRALIGN. ADDRESS is the virtual address of OVIEW. +// Write the CIE to OVIEW starting at OFFSET. OUTPUT_OFFSET is the +// offset of the Eh_frame section within the output section. Round up +// the bytes to ADDRALIGN. ADDRESS is the virtual address of OVIEW. // EH_FRAME_HDR is the exception frame header for FDE recording. // POST_FDES stashes FDEs created after mappings were done, for later // writing. Return the new offset. template<int size, bool big_endian> section_offset_type -Cie::write(unsigned char* oview, section_offset_type offset, - uint64_t address, unsigned int addralign, - Eh_frame_hdr* eh_frame_hdr, Post_fdes* post_fdes) +Cie::write(unsigned char* oview, section_offset_type output_offset, + section_offset_type offset, uint64_t address, + unsigned int addralign, Eh_frame_hdr* eh_frame_hdr, + Post_fdes* post_fdes) { gold_assert((offset & (addralign - 1)) == 0); @@ -488,8 +491,8 @@ Cie::write(unsigned char* oview, section_offset_type offset, if ((*p)->post_map()) post_fdes->push_back(Post_fde(*p, cie_offset, fde_encoding)); else - offset = (*p)->write<size, big_endian>(oview, offset, address, - addralign, cie_offset, + offset = (*p)->write<size, big_endian>(oview, output_offset, offset, + address, addralign, cie_offset, fde_encoding, eh_frame_hdr); } @@ -1093,7 +1096,10 @@ Eh_frame::set_final_data_size() return; } - section_offset_type output_offset = 0; + section_offset_type output_start = 0; + if (this->is_offset_valid()) + output_start = this->offset() - this->output_section()->offset(); + section_offset_type output_offset = output_start; for (Unmergeable_cie_offsets::iterator p = this->unmergeable_cie_offsets_.begin(); @@ -1111,10 +1117,10 @@ Eh_frame::set_final_data_size() &this->merge_map_); this->mappings_are_done_ = true; - this->final_data_size_ = output_offset; + this->final_data_size_ = output_offset - output_start; gold_assert((output_offset & (this->addralign() - 1)) == 0); - this->set_data_size(output_offset); + this->set_data_size(this->final_data_size_); } // Return an output offset for an input offset. @@ -1183,23 +1189,26 @@ Eh_frame::do_sized_write(unsigned char* oview) uint64_t address = this->address(); unsigned int addralign = this->addralign(); section_offset_type o = 0; + const off_t output_offset = this->offset() - this->output_section()->offset(); Post_fdes post_fdes; for (Unmergeable_cie_offsets::iterator p = this->unmergeable_cie_offsets_.begin(); p != this->unmergeable_cie_offsets_.end(); ++p) - o = (*p)->write<size, big_endian>(oview, o, address, addralign, - this->eh_frame_hdr_, &post_fdes); + o = (*p)->write<size, big_endian>(oview, output_offset, o, address, + addralign, this->eh_frame_hdr_, + &post_fdes); for (Cie_offsets::iterator p = this->cie_offsets_.begin(); p != this->cie_offsets_.end(); ++p) - o = (*p)->write<size, big_endian>(oview, o, address, addralign, - this->eh_frame_hdr_, &post_fdes); + o = (*p)->write<size, big_endian>(oview, output_offset, o, address, + addralign, this->eh_frame_hdr_, + &post_fdes); for (Post_fdes::iterator p = post_fdes.begin(); p != post_fdes.end(); ++p) - o = (*p).fde->write<size, big_endian>(oview, o, address, addralign, - (*p).cie_offset, + o = (*p).fde->write<size, big_endian>(oview, output_offset, o, address, + addralign, (*p).cie_offset, (*p).fde_encoding, this->eh_frame_hdr_); } diff --git a/binutils-2.25/gold/ehframe.h b/binutils-2.25/gold/ehframe.h index 8aab8b8..2ae12e0 100644 --- a/binutils-2.25/gold/ehframe.h +++ b/binutils-2.25/gold/ehframe.h @@ -1,6 +1,6 @@ // ehframe.h -- handle exception frame sections for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -211,8 +211,8 @@ class Fde // FDE in EH_FRAME_HDR. Return the new offset. template<int size, bool big_endian> section_offset_type - write(unsigned char* oview, section_offset_type offset, - uint64_t address, unsigned int addralign, + write(unsigned char* oview, section_offset_type output_section_offset, + section_offset_type offset, uint64_t address, unsigned int addralign, section_offset_type cie_offset, unsigned char fde_encoding, Eh_frame_hdr* eh_frame_hdr); @@ -317,7 +317,8 @@ class Cie // writing. Return the new offset. template<int size, bool big_endian> section_offset_type - write(unsigned char* oview, section_offset_type offset, uint64_t address, + write(unsigned char* oview, section_offset_type output_section_offset, + section_offset_type offset, uint64_t address, unsigned int addralign, Eh_frame_hdr* eh_frame_hdr, Post_fdes* post_fdes); diff --git a/binutils-2.25/gold/errors.cc b/binutils-2.25/gold/errors.cc index b79764b..8339742 100644 --- a/binutils-2.25/gold/errors.cc +++ b/binutils-2.25/gold/errors.cc @@ -1,6 +1,6 @@ // errors.cc -- handle errors for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -193,6 +193,11 @@ Errors::undefined_symbol(const Symbol* sym, const std::string& location) fprintf(stderr, _("%s: %s: undefined reference to '%s', version '%s'\n"), location.c_str(), zmsg, sym->demangled_name().c_str(), version); + + if (sym->is_cxx_vtable()) + gold_info(_("%s: the vtable symbol may be undefined because " + "the class is missing its key function"), + program_name); } // Issue a debugging message. diff --git a/binutils-2.25/gold/errors.h b/binutils-2.25/gold/errors.h index 1e61c8d..ea8f992 100644 --- a/binutils-2.25/gold/errors.h +++ b/binutils-2.25/gold/errors.h @@ -1,6 +1,6 @@ // errors.h -- handle errors for gold -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/expression.cc b/binutils-2.25/gold/expression.cc index e31c151..61a3eaf 100644 --- a/binutils-2.25/gold/expression.cc +++ b/binutils-2.25/gold/expression.cc @@ -1,6 +1,6 @@ // expression.cc -- expressions in linker scripts for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -68,6 +68,12 @@ struct Expression::Expression_eval_info Output_section** result_section_pointer; // Pointer to where the alignment of the result should be stored. uint64_t* result_alignment_pointer; + // Pointer to where the type of the symbol on the RHS should be stored. + elfcpp::STT* type_pointer; + // Pointer to where the visibility of the symbol on the RHS should be stored. + elfcpp::STV* vis_pointer; + // Pointer to where the rest of the symbol's st_other field should be stored. + unsigned char* nonvis_pointer; }; // Evaluate an expression. @@ -76,8 +82,8 @@ uint64_t Expression::eval(const Symbol_table* symtab, const Layout* layout, bool check_assertions) { - return this->eval_maybe_dot(symtab, layout, check_assertions, - false, 0, NULL, NULL, NULL, false); + return this->eval_maybe_dot(symtab, layout, check_assertions, false, 0, + NULL, NULL, NULL, NULL, NULL, NULL, false); } // Evaluate an expression which may refer to the dot symbol. @@ -92,7 +98,7 @@ Expression::eval_with_dot(const Symbol_table* symtab, const Layout* layout, { return this->eval_maybe_dot(symtab, layout, check_assertions, true, dot_value, dot_section, result_section_pointer, - result_alignment_pointer, + result_alignment_pointer, NULL, NULL, NULL, is_section_dot_assignment); } @@ -105,6 +111,9 @@ Expression::eval_maybe_dot(const Symbol_table* symtab, const Layout* layout, uint64_t dot_value, Output_section* dot_section, Output_section** result_section_pointer, uint64_t* result_alignment_pointer, + elfcpp::STT* type_pointer, + elfcpp::STV* vis_pointer, + unsigned char* nonvis_pointer, bool is_section_dot_assignment) { Expression_eval_info eei; @@ -121,6 +130,12 @@ Expression::eval_maybe_dot(const Symbol_table* symtab, const Layout* layout, *result_section_pointer = NULL; eei.result_section_pointer = result_section_pointer; + // For symbol=symbol assignments, we need to track the type, visibility, + // and remaining st_other bits. + eei.type_pointer = type_pointer; + eei.vis_pointer = vis_pointer; + eei.nonvis_pointer = nonvis_pointer; + eei.result_alignment_pointer = result_alignment_pointer; uint64_t val = this->value(&eei); @@ -196,6 +211,12 @@ Symbol_expression::value(const Expression_eval_info* eei) if (eei->result_section_pointer != NULL) *eei->result_section_pointer = sym->output_section(); + if (eei->type_pointer != NULL) + *eei->type_pointer = sym->type(); + if (eei->vis_pointer != NULL) + *eei->vis_pointer = sym->visibility(); + if (eei->nonvis_pointer != NULL) + *eei->nonvis_pointer = sym->nonvis(); if (parameters->target().get_size() == 32) return eei->symtab->get_sized_symbol<32>(sym)->value(); @@ -271,6 +292,9 @@ class Unary_expression : public Expression eei->dot_section, arg_section_pointer, eei->result_alignment_pointer, + NULL, + NULL, + NULL, false); } @@ -351,6 +375,9 @@ class Binary_expression : public Expression eei->dot_section, section_pointer, alignment_pointer, + NULL, + NULL, + NULL, false); } @@ -366,6 +393,9 @@ class Binary_expression : public Expression eei->dot_section, section_pointer, alignment_pointer, + NULL, + NULL, + NULL, false); } @@ -517,6 +547,9 @@ class Trinary_expression : public Expression eei->dot_section, section_pointer, NULL, + NULL, + NULL, + NULL, false); } @@ -532,6 +565,9 @@ class Trinary_expression : public Expression eei->dot_section, section_pointer, alignment_pointer, + NULL, + NULL, + NULL, false); } @@ -547,6 +583,9 @@ class Trinary_expression : public Expression eei->dot_section, section_pointer, alignment_pointer, + NULL, + NULL, + NULL, false); } diff --git a/binutils-2.25/gold/ffsll.c b/binutils-2.25/gold/ffsll.c index b247bc3..292ad80 100644 --- a/binutils-2.25/gold/ffsll.c +++ b/binutils-2.25/gold/ffsll.c @@ -1,6 +1,6 @@ /* ffsll.c -- version of ffsll for gold. */ -/* Copyright 2009 Free Software Foundation, Inc. +/* Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/fileread.cc b/binutils-2.25/gold/fileread.cc index 743a1cd..8c46a1f 100644 --- a/binutils-2.25/gold/fileread.cc +++ b/binutils-2.25/gold/fileread.cc @@ -1,7 +1,6 @@ // fileread.cc -- read files for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/fileread.h b/binutils-2.25/gold/fileread.h index 74aeec9..d64f18a 100644 --- a/binutils-2.25/gold/fileread.h +++ b/binutils-2.25/gold/fileread.h @@ -1,6 +1,6 @@ // fileread.h -- read files for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/freebsd.h b/binutils-2.25/gold/freebsd.h index 3bdedce..737da90 100644 --- a/binutils-2.25/gold/freebsd.h +++ b/binutils-2.25/gold/freebsd.h @@ -1,6 +1,6 @@ // freebsd.h -- FreeBSD support for gold -*- C++ -*- -// Copyright 2009, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/ftruncate.c b/binutils-2.25/gold/ftruncate.c index 102fcd1..00f357f 100644 --- a/binutils-2.25/gold/ftruncate.c +++ b/binutils-2.25/gold/ftruncate.c @@ -1,7 +1,7 @@ /* ftruncate emulations that work on some System V's. This file is in the public domain. */ -/* Copyright 2012 Free Software Foundation, Inc. +/* Copyright (C) 2012-2014 Free Software Foundation, Inc. This file is part of gold. diff --git a/binutils-2.25/gold/gc.cc b/binutils-2.25/gold/gc.cc index 7a594a5..4759c00 100644 --- a/binutils-2.25/gold/gc.cc +++ b/binutils-2.25/gold/gc.cc @@ -1,6 +1,6 @@ // gc.cc -- garbage collection of unused sections -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/gc.h b/binutils-2.25/gold/gc.h index 4224a66..2f79a24 100644 --- a/binutils-2.25/gold/gc.h +++ b/binutils-2.25/gold/gc.h @@ -1,6 +1,6 @@ // gc.h -- garbage collection of unused sections -// Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/gdb-index.cc b/binutils-2.25/gold/gdb-index.cc index 3b70068..f768827 100644 --- a/binutils-2.25/gold/gdb-index.cc +++ b/binutils-2.25/gold/gdb-index.cc @@ -1,6 +1,6 @@ // gdb-index.cc -- generate .gdb_index section for fast debug lookup -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. @@ -32,7 +32,7 @@ namespace gold { -const int gdb_index_version = 5; +const int gdb_index_version = 7; // Sizes of various records in the .gdb_index section. const int gdb_index_offset_size = 4; @@ -203,8 +203,8 @@ class Gdb_index_info_reader : public Dwarf_info_reader // Visit a type unit. virtual void - visit_type_unit(off_t tu_offset, off_t type_offset, uint64_t signature, - Dwarf_die*); + visit_type_unit(off_t tu_offset, off_t tu_length, off_t type_offset, + uint64_t signature, Dwarf_die*); private: // A map for recording DIEs we've seen that may be referred to be @@ -329,8 +329,9 @@ Gdb_index_info_reader::visit_compilation_unit(off_t cu_offset, off_t cu_length, // Process a type unit and parse its child DIE. void -Gdb_index_info_reader::visit_type_unit(off_t tu_offset, off_t type_offset, - uint64_t signature, Dwarf_die* root_die) +Gdb_index_info_reader::visit_type_unit(off_t tu_offset, off_t, + off_t type_offset, uint64_t signature, + Dwarf_die* root_die) { ++Gdb_index_info_reader::dwarf_tu_count; // Use a negative index to flag this as a TU instead of a CU. @@ -356,20 +357,6 @@ Gdb_index_info_reader::visit_top_die(Dwarf_die* die) case elfcpp::DW_TAG_compile_unit: case elfcpp::DW_TAG_type_unit: this->cu_language_ = die->int_attribute(elfcpp::DW_AT_language); - // Check for languages that require specialized knowledge to - // construct fully-qualified names, that we don't yet support. - if (this->cu_language_ == elfcpp::DW_LANG_Ada83 - || this->cu_language_ == elfcpp::DW_LANG_Fortran77 - || this->cu_language_ == elfcpp::DW_LANG_Fortran90 - || this->cu_language_ == elfcpp::DW_LANG_Java - || this->cu_language_ == elfcpp::DW_LANG_Ada95 - || this->cu_language_ == elfcpp::DW_LANG_Fortran95) - { - gold_warning(_("%s: --gdb-index currently supports " - "only C and C++ languages"), - this->object()->name().c_str()); - return; - } if (die->tag() == elfcpp::DW_TAG_compile_unit) this->record_cu_ranges(die); // If there is a pubnames and/or pubtypes section for this @@ -377,6 +364,20 @@ Gdb_index_info_reader::visit_top_die(Dwarf_die* die) // info to extract the names. if (!this->read_pubnames_and_pubtypes(die)) { + // Check for languages that require specialized knowledge to + // construct fully-qualified names, that we don't yet support. + if (this->cu_language_ == elfcpp::DW_LANG_Ada83 + || this->cu_language_ == elfcpp::DW_LANG_Fortran77 + || this->cu_language_ == elfcpp::DW_LANG_Fortran90 + || this->cu_language_ == elfcpp::DW_LANG_Java + || this->cu_language_ == elfcpp::DW_LANG_Ada95 + || this->cu_language_ == elfcpp::DW_LANG_Fortran95) + { + gold_warning(_("%s: --gdb-index currently supports " + "only C and C++ languages"), + this->object()->name().c_str()); + return; + } if (die->tag() == elfcpp::DW_TAG_compile_unit) ++Gdb_index_info_reader::dwarf_cu_nopubnames_count; else @@ -391,7 +392,6 @@ Gdb_index_info_reader::visit_top_die(Dwarf_die* die) this->object()->name().c_str()); return; } - } // Visit the children of PARENT, looking for symbols to add to the index. @@ -435,7 +435,8 @@ Gdb_index_info_reader::visit_die(Dwarf_die* die, Dwarf_die* context) // If the DIE is not a declaration, add it to the index. std::string full_name = this->get_qualified_name(die, context); if (!full_name.empty()) - this->gdb_index_->add_symbol(this->cu_index_, full_name.c_str()); + this->gdb_index_->add_symbol(this->cu_index_, + full_name.c_str(), 0); } break; case elfcpp::DW_TAG_typedef: @@ -475,7 +476,7 @@ Gdb_index_info_reader::visit_die(Dwarf_die* die, Dwarf_die* context) full_name = this->get_qualified_name(die, context); if (!full_name.empty()) this->gdb_index_->add_symbol(this->cu_index_, - full_name.c_str()); + full_name.c_str(), 0); } // We're interested in the children only for namespaces and @@ -869,11 +870,12 @@ Gdb_index_info_reader::read_pubtable(Dwarf_pubnames_table* table, off_t offset) return false; while (true) { - const char* name = table->next_name(); + uint8_t flag_byte; + const char* name = table->next_name(&flag_byte); if (name == NULL) break; - this->gdb_index_->add_symbol(this->cu_index_, name); + this->gdb_index_->add_symbol(this->cu_index_, name, flag_byte); } return true; } @@ -884,6 +886,14 @@ Gdb_index_info_reader::read_pubtable(Dwarf_pubnames_table* table, off_t offset) bool Gdb_index_info_reader::read_pubnames_and_pubtypes(Dwarf_die* die) { + // If this is a skeleton debug-type die (generated via + // -gsplit-dwarf), then the associated pubnames should have been + // read along with the corresponding CU. In any case, there isn't + // enough info inside to build a gdb index entry. + if (die->tag() == elfcpp::DW_TAG_type_unit + && die->string_attribute(elfcpp::DW_AT_GNU_dwo_name)) + return true; + // We use stmt_list_off as a unique identifier for the // compilation unit and its associated type units. unsigned int shndx; @@ -1111,7 +1121,7 @@ Gdb_index::scan_debug_info(bool is_type_unit, // Add a symbol. void -Gdb_index::add_symbol(int cu_index, const char* sym_name) +Gdb_index::add_symbol(int cu_index, const char* sym_name, uint8_t flags) { unsigned int hash = mapped_index_string_hash( reinterpret_cast<const unsigned char*>(sym_name)); @@ -1138,8 +1148,10 @@ Gdb_index::add_symbol(int cu_index, const char* sym_name) // if it's not already on the list. We only need to // check the last added entry. Cu_vector* cu_vec = this->cu_vector_list_[found->cu_vector_index]; - if (cu_vec->size() == 0 || cu_vec->back() != cu_index) - cu_vec->push_back(cu_index); + if (cu_vec->size() == 0 + || cu_vec->back().first != cu_index + || cu_vec->back().second != flags) + cu_vec->push_back(std::make_pair(cu_index, flags)); } // Return TRUE if we have already processed the pubnames associated @@ -1316,9 +1328,11 @@ Gdb_index::do_write(Output_file* of) pov += 4; for (unsigned int j = 0; j < cu_vec->size(); ++j) { - int cu_index = (*cu_vec)[j]; + int cu_index = (*cu_vec)[j].first; + uint8_t flags = (*cu_vec)[j].second; if (cu_index < 0) cu_index = comp_units_count + (-1 - cu_index); + cu_index |= flags << 24; elfcpp::Swap<32, false>::writeval(pov, cu_index); pov += 4; } diff --git a/binutils-2.25/gold/gdb-index.h b/binutils-2.25/gold/gdb-index.h index 5d9fe47..97dfc8f 100644 --- a/binutils-2.25/gold/gdb-index.h +++ b/binutils-2.25/gold/gdb-index.h @@ -1,6 +1,6 @@ // gdb-index.h -- generate .gdb_index section for fast debug lookup -*- C++ -*- -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. @@ -89,9 +89,10 @@ class Gdb_index : public Output_section_data this->ranges_.push_back(Per_cu_range_list(object, cu_index, ranges)); } - // Add a symbol. + // Add a symbol. FLAGS are the gdb_index version 7 flags to be stored in + // the high-byte of the cu_index field. void - add_symbol(int cu_index, const char* sym_name); + add_symbol(int cu_index, const char* sym_name, uint8_t flags); // Return the offset into the pubnames table for the cu at the given // offset. @@ -213,7 +214,7 @@ class Gdb_index : public Output_section_data { return this->name_key == symbol->name_key; } }; - typedef std::vector<int> Cu_vector; + typedef std::vector<std::pair<int, uint8_t> > Cu_vector; typedef Unordered_map<off_t, off_t> Pubname_offset_map; Pubname_offset_map cu_pubname_map_; diff --git a/binutils-2.25/gold/gold-threads.cc b/binutils-2.25/gold/gold-threads.cc index 2cb293e..ebd9c1f 100644 --- a/binutils-2.25/gold/gold-threads.cc +++ b/binutils-2.25/gold/gold-threads.cc @@ -1,6 +1,6 @@ // gold-threads.cc -- thread support for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2013 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/gold-threads.h b/binutils-2.25/gold/gold-threads.h index 5751f62..571cb94 100644 --- a/binutils-2.25/gold/gold-threads.h +++ b/binutils-2.25/gold/gold-threads.h @@ -1,6 +1,6 @@ // gold-threads.h -- thread support for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2013 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/gold.cc b/binutils-2.25/gold/gold.cc index 4de9289..bdfb33d 100644 --- a/binutils-2.25/gold/gold.cc +++ b/binutils-2.25/gold/gold.cc @@ -1,7 +1,6 @@ // gold.cc -- main linker functions -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -809,6 +808,8 @@ queue_final_tasks(const General_options& options, if (!any_postprocessing_sections) { input_sections_blocker = new Task_token(true); + // Write_symbols_task, Relocate_tasks. + input_sections_blocker->add_blocker(); input_sections_blocker->add_blockers(input_objects->number_of_relobjs()); } @@ -837,6 +838,7 @@ queue_final_tasks(const General_options& options, // Queue a task to write out the output sections. workqueue->queue(new Write_sections_task(layout, of, output_sections_blocker, + input_sections_blocker, final_blocker)); // Queue a task to write out everything else. diff --git a/binutils-2.25/gold/gold.h b/binutils-2.25/gold/gold.h index ef95f53..b78a165 100644 --- a/binutils-2.25/gold/gold.h +++ b/binutils-2.25/gold/gold.h @@ -1,6 +1,6 @@ // gold.h -- general definitions for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/i386.cc b/binutils-2.25/gold/i386.cc index 6a3280d..d28c444 100644 --- a/binutils-2.25/gold/i386.cc +++ b/binutils-2.25/gold/i386.cc @@ -1,7 +1,6 @@ // i386.cc -- i386 target support for gold. -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -48,6 +47,32 @@ namespace using namespace gold; +// A class to handle the .got.plt section. + +class Output_data_got_plt_i386 : public Output_section_data_build +{ + public: + Output_data_got_plt_i386(Layout* layout) + : Output_section_data_build(4), + layout_(layout) + { } + + protected: + // Write out the PLT data. + void + do_write(Output_file*); + + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, "** GOT PLT"); } + + private: + // A pointer to the Layout class, so that we can find the .dynamic + // section when we write out the GOT PLT section. + Layout* layout_; +}; + // A class to handle the PLT data. // This is an abstract base class that handles most of the linker details // but does not know the actual contents of PLT entries. The derived @@ -59,7 +84,7 @@ class Output_data_plt_i386 : public Output_section_data typedef Output_data_reloc<elfcpp::SHT_REL, true, 32, false> Reloc_section; Output_data_plt_i386(Layout*, uint64_t addralign, - Output_data_space*, Output_data_space*); + Output_data_got_plt_i386*, Output_data_space*); // Add an entry to the PLT. void @@ -202,9 +227,6 @@ class Output_data_plt_i386 : public Output_section_data unsigned int got_offset; }; - // A pointer to the Layout class, so that we can find the .dynamic - // section when we write out the GOT PLT section. - Layout* layout_; // The reloc section. Reloc_section* rel_; // The TLS_DESC relocations, if necessary. These must follow the @@ -214,7 +236,7 @@ class Output_data_plt_i386 : public Output_section_data // regular relocatoins and the TLS_DESC relocations. Reloc_section* irelative_rel_; // The .got.plt section. - Output_data_space* got_plt_; + Output_data_got_plt_i386* got_plt_; // The part of the .got.plt section used for IRELATIVE relocs. Output_data_space* got_irelative_; // The number of PLT entries. @@ -237,7 +259,7 @@ class Output_data_plt_i386_standard : public Output_data_plt_i386 { public: Output_data_plt_i386_standard(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative) : Output_data_plt_i386(layout, plt_entry_size, got_plt, got_irelative) { } @@ -268,7 +290,7 @@ class Output_data_plt_i386_exec : public Output_data_plt_i386_standard { public: Output_data_plt_i386_exec(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative) : Output_data_plt_i386_standard(layout, got_plt, got_irelative) { } @@ -299,7 +321,7 @@ class Output_data_plt_i386_dyn : public Output_data_plt_i386_standard { public: Output_data_plt_i386_dyn(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative) : Output_data_plt_i386_standard(layout, got_plt, got_irelative) { } @@ -507,14 +529,14 @@ class Target_i386 : public Sized_target<32, false> // This chooses the right PLT flavor for an executable or a shared object. Output_data_plt_i386* make_data_plt(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative, bool dyn) { return this->do_make_data_plt(layout, got_plt, got_irelative, dyn); } virtual Output_data_plt_i386* do_make_data_plt(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative, bool dyn) { @@ -721,7 +743,7 @@ class Target_i386 : public Sized_target<32, false> got_section(Symbol_table*, Layout*); // Get the GOT PLT section. - Output_data_space* + Output_data_got_plt_i386* got_plt_section() const { gold_assert(this->got_plt_ != NULL); @@ -814,7 +836,7 @@ class Target_i386 : public Sized_target<32, false> // The PLT section. Output_data_plt_i386* plt_; // The GOT PLT section. - Output_data_space* got_plt_; + Output_data_got_plt_i386* got_plt_; // The GOT section for IRELATIVE relocations. Output_data_space* got_irelative_; // The GOT section for TLSDESC relocations. @@ -886,7 +908,7 @@ Target_i386::got_section(Symbol_table* symtab, Layout* layout) | elfcpp::SHF_WRITE), this->got_, got_order, true); - this->got_plt_ = new Output_data_space(4, "** GOT PLT"); + this->got_plt_ = new Output_data_got_plt_i386(layout); layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS, (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), @@ -973,18 +995,39 @@ Target_i386::rel_irelative_section(Layout* layout) return this->rel_irelative_; } +// Write the first three reserved words of the .got.plt section. +// The remainder of the section is written while writing the PLT +// in Output_data_plt_i386::do_write. + +void +Output_data_got_plt_i386::do_write(Output_file* of) +{ + // The first entry in the GOT is the address of the .dynamic section + // aka the PT_DYNAMIC segment. The next two entries are reserved. + // We saved space for them when we created the section in + // Target_i386::got_section. + const off_t got_file_offset = this->offset(); + gold_assert(this->data_size() >= 12); + unsigned char* const got_view = of->get_output_view(got_file_offset, 12); + Output_section* dynamic = this->layout_->dynamic_section(); + uint32_t dynamic_addr = dynamic == NULL ? 0 : dynamic->address(); + elfcpp::Swap<32, false>::writeval(got_view, dynamic_addr); + memset(got_view + 4, 0, 8); + of->write_output_view(got_file_offset, 12, got_view); +} + // Create the PLT section. The ordinary .got section is an argument, // since we need to refer to the start. We also create our own .got // section just for PLT entries. Output_data_plt_i386::Output_data_plt_i386(Layout* layout, uint64_t addralign, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative) : Output_section_data(addralign), - layout_(layout), tls_desc_rel_(NULL), - irelative_rel_(NULL), got_plt_(got_plt), got_irelative_(got_irelative), - count_(0), irelative_count_(0), global_ifuncs_(), local_ifuncs_() + tls_desc_rel_(NULL), irelative_rel_(NULL), got_plt_(got_plt), + got_irelative_(got_irelative), count_(0), irelative_count_(0), + global_ifuncs_(), local_ifuncs_() { this->rel_ = new Reloc_section(false); layout->add_output_section_data(".rel.plt", elfcpp::SHT_REL, @@ -1324,6 +1367,7 @@ Output_data_plt_i386::do_write(Output_file* of) const section_size_type got_size = convert_to_section_size_type(this->got_plt_->data_size() + this->got_irelative_->data_size()); + unsigned char* const got_view = of->get_output_view(got_file_offset, got_size); @@ -1335,18 +1379,9 @@ Output_data_plt_i386::do_write(Output_file* of) this->fill_first_plt_entry(pov, got_address); pov += this->get_plt_entry_size(); - unsigned char* got_pov = got_view; - - // The first entry in the GOT is the address of the .dynamic section - // aka the PT_DYNAMIC segment. The next two entries are reserved. - // We saved space for them when we created the section in - // Target_i386::got_section. - Output_section* dynamic = this->layout_->dynamic_section(); - uint32_t dynamic_addr = dynamic == NULL ? 0 : dynamic->address(); - elfcpp::Swap<32, false>::writeval(got_pov, dynamic_addr); - got_pov += 4; - memset(got_pov, 0, 8); - got_pov += 8; + // The first three entries in the GOT are reserved, and are written + // by Output_data_got_plt_i386::do_write. + unsigned char* got_pov = got_view + 12; const int rel_size = elfcpp::Elf_sizes<32>::rel_size; @@ -2114,7 +2149,8 @@ Target_i386::Scan::global(Symbol_table* symtab, // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (gsym->may_need_copy_reloc()) + if (!parameters->options().output_is_position_independent() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); @@ -2175,7 +2211,8 @@ Target_i386::Scan::global(Symbol_table* symtab, // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (gsym->may_need_copy_reloc()) + if (parameters->options().output_is_executable() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); @@ -3835,7 +3872,7 @@ class Output_data_plt_i386_nacl : public Output_data_plt_i386 { public: Output_data_plt_i386_nacl(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative) : Output_data_plt_i386(layout, plt_entry_size, got_plt, got_irelative) { } @@ -3864,7 +3901,7 @@ class Output_data_plt_i386_nacl_exec : public Output_data_plt_i386_nacl { public: Output_data_plt_i386_nacl_exec(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative) : Output_data_plt_i386_nacl(layout, got_plt, got_irelative) { } @@ -3893,7 +3930,7 @@ class Output_data_plt_i386_nacl_dyn : public Output_data_plt_i386_nacl { public: Output_data_plt_i386_nacl_dyn(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative) : Output_data_plt_i386_nacl(layout, got_plt, got_irelative) { } @@ -3927,7 +3964,7 @@ class Target_i386_nacl : public Target_i386 protected: virtual Output_data_plt_i386* do_make_data_plt(Layout* layout, - Output_data_space* got_plt, + Output_data_got_plt_i386* got_plt, Output_data_space* got_irelative, bool dyn) { diff --git a/binutils-2.25/gold/icf.cc b/binutils-2.25/gold/icf.cc index a58e34f..ad88715 100644 --- a/binutils-2.25/gold/icf.cc +++ b/binutils-2.25/gold/icf.cc @@ -1,6 +1,6 @@ // icf.cc -- Identical Code Folding. // -// Copyright 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. @@ -269,21 +269,21 @@ get_section_contents(bool first_iteration, if (it_reloc_info_list != reloc_info_list.end()) { - Icf::Sections_reachable_info v = + Icf::Sections_reachable_info &v = (it_reloc_info_list->second).section_info; // Stores the information of the symbol pointed to by the reloc. - Icf::Symbol_info s = (it_reloc_info_list->second).symbol_info; + const Icf::Symbol_info &s = (it_reloc_info_list->second).symbol_info; // Stores the addend and the symbol value. - Icf::Addend_info a = (it_reloc_info_list->second).addend_info; + Icf::Addend_info &a = (it_reloc_info_list->second).addend_info; // Stores the offset of the reloc. - Icf::Offset_info o = (it_reloc_info_list->second).offset_info; - Icf::Reloc_addend_size_info reloc_addend_size_info = + const Icf::Offset_info &o = (it_reloc_info_list->second).offset_info; + const Icf::Reloc_addend_size_info &reloc_addend_size_info = (it_reloc_info_list->second).reloc_addend_size_info; Icf::Sections_reachable_info::iterator it_v = v.begin(); - Icf::Symbol_info::iterator it_s = s.begin(); + Icf::Symbol_info::const_iterator it_s = s.begin(); Icf::Addend_info::iterator it_a = a.begin(); - Icf::Offset_info::iterator it_o = o.begin(); - Icf::Reloc_addend_size_info::iterator it_addend_size = + Icf::Offset_info::const_iterator it_o = o.begin(); + Icf::Reloc_addend_size_info::const_iterator it_addend_size = reloc_addend_size_info.begin(); for (; it_v != v.end(); ++it_v, ++it_s, ++it_a, ++it_o, ++it_addend_size) diff --git a/binutils-2.25/gold/icf.h b/binutils-2.25/gold/icf.h index df6bc01..3118642 100644 --- a/binutils-2.25/gold/icf.h +++ b/binutils-2.25/gold/icf.h @@ -1,6 +1,6 @@ // icf.h -- Identical Code Folding -// Copyright 2009, 2010, 2013 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/incremental-dump.cc b/binutils-2.25/gold/incremental-dump.cc index 5365265..8ef16cf 100644 --- a/binutils-2.25/gold/incremental-dump.cc +++ b/binutils-2.25/gold/incremental-dump.cc @@ -1,6 +1,6 @@ // incremental.cc -- incremental linking test/debug tool -// Copyright 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Rafael Avila de Espindola <rafael.espindola@gmail.com> // This file is part of gold. diff --git a/binutils-2.25/gold/incremental.cc b/binutils-2.25/gold/incremental.cc index 714b198..bbc055c 100644 --- a/binutils-2.25/gold/incremental.cc +++ b/binutils-2.25/gold/incremental.cc @@ -1,6 +1,6 @@ // inremental.cc -- incremental linking support for gold -// Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Mikolaj Zalewski <mikolajz@google.com>. // This file is part of gold. @@ -2270,10 +2270,10 @@ Sized_relobj_incr<size, big_endian>::do_section_size(unsigned int) template<int size, bool big_endian> std::string -Sized_relobj_incr<size, big_endian>::do_section_name(unsigned int shndx) +Sized_relobj_incr<size, big_endian>::do_section_name(unsigned int shndx) const { - Output_sections& out_sections(this->output_sections()); - Output_section* os = out_sections[shndx]; + const Output_sections& out_sections(this->output_sections()); + const Output_section* os = out_sections[shndx]; if (os == NULL) return NULL; return os->name(); @@ -2858,7 +2858,7 @@ Sized_incr_dynobj<size, big_endian>::do_section_size(unsigned int) template<int size, bool big_endian> std::string -Sized_incr_dynobj<size, big_endian>::do_section_name(unsigned int) +Sized_incr_dynobj<size, big_endian>::do_section_name(unsigned int) const { gold_unreachable(); } diff --git a/binutils-2.25/gold/incremental.h b/binutils-2.25/gold/incremental.h index 77803fc..5440c86 100644 --- a/binutils-2.25/gold/incremental.h +++ b/binutils-2.25/gold/incremental.h @@ -1,6 +1,6 @@ // inremental.h -- incremental linking support for gold -*- C++ -*- -// Copyright 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Mikolaj Zalewski <mikolajz@google.com>. // This file is part of gold. @@ -1901,7 +1901,7 @@ class Sized_relobj_incr : public Sized_relobj<size, big_endian> // Get the name of a section. std::string - do_section_name(unsigned int shndx); + do_section_name(unsigned int shndx) const; // Return a view of the contents of a section. const unsigned char* @@ -2112,7 +2112,7 @@ class Sized_incr_dynobj : public Dynobj // Get the name of a section. std::string - do_section_name(unsigned int shndx); + do_section_name(unsigned int shndx) const; // Return a view of the contents of a section. const unsigned char* diff --git a/binutils-2.25/gold/int_encoding.cc b/binutils-2.25/gold/int_encoding.cc index 7887477..f949d9a 100644 --- a/binutils-2.25/gold/int_encoding.cc +++ b/binutils-2.25/gold/int_encoding.cc @@ -1,6 +1,6 @@ // int_encoding.cc -- variable length and unaligned integer encoding support. -// Copyright 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com> by refactoring scattered // contents from other files in gold. Original code written by Ian // Lance Taylor <iant@google.com> and Caleb Howe <cshowe@google.com>. diff --git a/binutils-2.25/gold/int_encoding.h b/binutils-2.25/gold/int_encoding.h index 467d224..da4a2da 100644 --- a/binutils-2.25/gold/int_encoding.h +++ b/binutils-2.25/gold/int_encoding.h @@ -1,6 +1,6 @@ // int_encoding.h -- variable length and unaligned integers -*- C++ -*- -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com> by refactoring scattered // contents from other files in gold. Original code written by Ian // Lance Taylor <iant@google.com> and Caleb Howe <cshowe@google.com>. diff --git a/binutils-2.25/gold/layout.cc b/binutils-2.25/gold/layout.cc index 38fd272..7cbbe39 100644 --- a/binutils-2.25/gold/layout.cc +++ b/binutils-2.25/gold/layout.cc @@ -1,7 +1,6 @@ // layout.cc -- lay out output file sections for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -564,7 +563,9 @@ static const char* gdb_fast_lookup_sections[] = { "aranges", "pubnames", + "gnu_pubnames", "pubtypes", + "gnu_pubtypes", }; // Returns whether the given debug section is in the list of @@ -645,7 +646,13 @@ Layout::include_section(Sized_relobj_file<size, big_endian>*, const char* name, && (shdr.get_sh_flags() & elfcpp::SHF_EXCLUDE)) return false; - switch (shdr.get_sh_type()) + elfcpp::Elf_Word sh_type = shdr.get_sh_type(); + + if ((sh_type >= elfcpp::SHT_LOOS && sh_type <= elfcpp::SHT_HIOS) + || (sh_type >= elfcpp::SHT_LOPROC && sh_type <= elfcpp::SHT_HIPROC)) + return parameters->target().should_include_section(sh_type); + + switch (sh_type) { case elfcpp::SHT_NULL: case elfcpp::SHT_SYMTAB: @@ -2744,12 +2751,14 @@ Layout::finalize(const Input_objects* input_objects, Symbol_table* symtab, // If there is a load segment that contains the file and program headers, // provide a symbol __ehdr_start pointing there. // A program can use this to examine itself robustly. - if (load_seg != NULL) - symtab->define_in_output_segment("__ehdr_start", NULL, - Symbol_table::PREDEFINED, load_seg, 0, 0, - elfcpp::STT_NOTYPE, elfcpp::STB_GLOBAL, - elfcpp::STV_HIDDEN, 0, - Symbol::SEGMENT_START, true); + Symbol *ehdr_start = symtab->lookup("__ehdr_start"); + if (ehdr_start != NULL && ehdr_start->is_predefined()) + { + if (load_seg != NULL) + ehdr_start->set_output_segment(load_seg, Symbol::SEGMENT_START); + else + ehdr_start->set_undefined(); + } // Set the file offsets of all the non-data sections we've seen so // far which don't have to wait for the input sections. We need @@ -4299,18 +4308,20 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects, } } - // Create the hash tables. + // Create the hash tables. The Gnu-style hash table must be + // built first, because it changes the order of the symbols + // in the dynamic symbol table. - if (strcmp(parameters->options().hash_style(), "sysv") == 0 + if (strcmp(parameters->options().hash_style(), "gnu") == 0 || strcmp(parameters->options().hash_style(), "both") == 0) { unsigned char* phash; unsigned int hashlen; - Dynobj::create_elf_hash_table(*pdynamic_symbols, local_symcount, + Dynobj::create_gnu_hash_table(*pdynamic_symbols, local_symcount, &phash, &hashlen); Output_section* hashsec = - this->choose_output_section(NULL, ".hash", elfcpp::SHT_HASH, + this->choose_output_section(NULL, ".gnu.hash", elfcpp::SHT_GNU_HASH, elfcpp::SHF_ALLOC, false, ORDER_DYNAMIC_LINKER, false); @@ -4325,23 +4336,28 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects, { if (dynsym != NULL) hashsec->set_link_section(dynsym); - hashsec->set_entsize(4); - } - if (odyn != NULL) - odyn->add_section_address(elfcpp::DT_HASH, hashsec); + // For a 64-bit target, the entries in .gnu.hash do not have + // a uniform size, so we only set the entry size for a + // 32-bit target. + if (parameters->target().get_size() == 32) + hashsec->set_entsize(4); + + if (odyn != NULL) + odyn->add_section_address(elfcpp::DT_GNU_HASH, hashsec); + } } - if (strcmp(parameters->options().hash_style(), "gnu") == 0 + if (strcmp(parameters->options().hash_style(), "sysv") == 0 || strcmp(parameters->options().hash_style(), "both") == 0) { unsigned char* phash; unsigned int hashlen; - Dynobj::create_gnu_hash_table(*pdynamic_symbols, local_symcount, + Dynobj::create_elf_hash_table(*pdynamic_symbols, local_symcount, &phash, &hashlen); Output_section* hashsec = - this->choose_output_section(NULL, ".gnu.hash", elfcpp::SHT_GNU_HASH, + this->choose_output_section(NULL, ".hash", elfcpp::SHT_HASH, elfcpp::SHF_ALLOC, false, ORDER_DYNAMIC_LINKER, false); @@ -4356,16 +4372,11 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects, { if (dynsym != NULL) hashsec->set_link_section(dynsym); - - // For a 64-bit target, the entries in .gnu.hash do not have - // a uniform size, so we only set the entry size for a - // 32-bit target. - if (parameters->target().get_size() == 32) - hashsec->set_entsize(4); - - if (odyn != NULL) - odyn->add_section_address(elfcpp::DT_GNU_HASH, hashsec); + hashsec->set_entsize(4); } + + if (odyn != NULL) + odyn->add_section_address(elfcpp::DT_HASH, hashsec); } } @@ -5485,6 +5496,10 @@ Layout::print_to_mapfile(Mapfile* mapfile) const p != this->segment_list_.end(); ++p) (*p)->print_sections_to_mapfile(mapfile); + for (Section_list::const_iterator p = this->unattached_section_list_.begin(); + p != this->unattached_section_list_.end(); + ++p) + (*p)->print_to_mapfile(mapfile); } // Print statistical information to stderr. This is used for --stats. @@ -5519,6 +5534,8 @@ void Write_sections_task::locks(Task_locker* tl) { tl->add(this, this->output_sections_blocker_); + if (this->input_sections_blocker_ != NULL) + tl->add(this, this->input_sections_blocker_); tl->add(this, this->final_blocker_); } diff --git a/binutils-2.25/gold/layout.h b/binutils-2.25/gold/layout.h index 792b748..032f5f3 100644 --- a/binutils-2.25/gold/layout.h +++ b/binutils-2.25/gold/layout.h @@ -1,7 +1,6 @@ // layout.h -- lay out output file sections for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -1455,9 +1454,11 @@ class Write_sections_task : public Task public: Write_sections_task(const Layout* layout, Output_file* of, Task_token* output_sections_blocker, + Task_token* input_sections_blocker, Task_token* final_blocker) : layout_(layout), of_(of), output_sections_blocker_(output_sections_blocker), + input_sections_blocker_(input_sections_blocker), final_blocker_(final_blocker) { } @@ -1482,6 +1483,7 @@ class Write_sections_task : public Task const Layout* layout_; Output_file* of_; Task_token* output_sections_blocker_; + Task_token* input_sections_blocker_; Task_token* final_blocker_; }; diff --git a/binutils-2.25/gold/main.cc b/binutils-2.25/gold/main.cc index d329298..bb86613 100644 --- a/binutils-2.25/gold/main.cc +++ b/binutils-2.25/gold/main.cc @@ -1,6 +1,6 @@ // main.cc -- gold main function. -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/mapfile.cc b/binutils-2.25/gold/mapfile.cc index 2062ae4..dc995e9 100644 --- a/binutils-2.25/gold/mapfile.cc +++ b/binutils-2.25/gold/mapfile.cc @@ -1,6 +1,6 @@ // mapfile.cc -- map file generation for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/mapfile.h b/binutils-2.25/gold/mapfile.h index 808fc66..da158db 100644 --- a/binutils-2.25/gold/mapfile.h +++ b/binutils-2.25/gold/mapfile.h @@ -1,6 +1,6 @@ // mapfile.h -- map file generation for gold -*- C++ -*- -// Copyright 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/merge.cc b/binutils-2.25/gold/merge.cc index f370c9c..6d444e6 100644 --- a/binutils-2.25/gold/merge.cc +++ b/binutils-2.25/gold/merge.cc @@ -1,6 +1,6 @@ // merge.cc -- handle section merging for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/merge.h b/binutils-2.25/gold/merge.h index 92c634a..b4fd8e1 100644 --- a/binutils-2.25/gold/merge.h +++ b/binutils-2.25/gold/merge.h @@ -1,6 +1,6 @@ // merge.h -- handle section merging for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/mips.cc b/binutils-2.25/gold/mips.cc new file mode 100644 index 0000000..92e1201 --- /dev/null +++ b/binutils-2.25/gold/mips.cc @@ -0,0 +1,10571 @@ +// mips.cc -- mips target support for gold. + +// Copyright (C) 2011-2014 Free Software Foundation, Inc. +// Written by Sasa Stankovic <sasa.stankovic@imgtec.com> +// and Aleksandar Simeonov <aleksandar.simeonov@rt-rk.com>. +// This file contains borrowed and adapted code from bfd/elfxx-mips.c. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +#include "gold.h" + +#include <algorithm> +#include <set> +#include <sstream> +#include "demangle.h" + +#include "elfcpp.h" +#include "parameters.h" +#include "reloc.h" +#include "mips.h" +#include "object.h" +#include "symtab.h" +#include "layout.h" +#include "output.h" +#include "copy-relocs.h" +#include "target.h" +#include "target-reloc.h" +#include "target-select.h" +#include "tls.h" +#include "errors.h" +#include "gc.h" +#include "nacl.h" + +namespace +{ +using namespace gold; + +template<int size, bool big_endian> +class Mips_output_data_plt; + +template<int size, bool big_endian> +class Mips_output_data_got; + +template<int size, bool big_endian> +class Target_mips; + +template<int size, bool big_endian> +class Mips_output_section_reginfo; + +template<int size, bool big_endian> +class Mips_output_data_la25_stub; + +template<int size, bool big_endian> +class Mips_output_data_mips_stubs; + +template<int size> +class Mips_symbol; + +template<int size, bool big_endian> +class Mips_got_info; + +template<int size, bool big_endian> +class Mips_relobj; + +class Mips16_stub_section_base; + +template<int size, bool big_endian> +class Mips16_stub_section; + +// The ABI says that every symbol used by dynamic relocations must have +// a global GOT entry. Among other things, this provides the dynamic +// linker with a free, directly-indexed cache. The GOT can therefore +// contain symbols that are not referenced by GOT relocations themselves +// (in other words, it may have symbols that are not referenced by things +// like R_MIPS_GOT16 and R_MIPS_GOT_PAGE). + +// GOT relocations are less likely to overflow if we put the associated +// GOT entries towards the beginning. We therefore divide the global +// GOT entries into two areas: "normal" and "reloc-only". Entries in +// the first area can be used for both dynamic relocations and GP-relative +// accesses, while those in the "reloc-only" area are for dynamic +// relocations only. + +// These GGA_* ("Global GOT Area") values are organised so that lower +// values are more general than higher values. Also, non-GGA_NONE +// values are ordered by the position of the area in the GOT. + +enum Global_got_area +{ + GGA_NORMAL = 0, + GGA_RELOC_ONLY = 1, + GGA_NONE = 2 +}; + +// The types of GOT entries needed for this platform. +// These values are exposed to the ABI in an incremental link. +// Do not renumber existing values without changing the version +// number of the .gnu_incremental_inputs section. +enum Got_type +{ + GOT_TYPE_STANDARD = 0, // GOT entry for a regular symbol + GOT_TYPE_TLS_OFFSET = 1, // GOT entry for TLS offset + GOT_TYPE_TLS_PAIR = 2, // GOT entry for TLS module/offset pair + + // GOT entries for multi-GOT. We support up to 1024 GOTs in multi-GOT links. + GOT_TYPE_STANDARD_MULTIGOT = 3, + GOT_TYPE_TLS_OFFSET_MULTIGOT = GOT_TYPE_STANDARD_MULTIGOT + 1024, + GOT_TYPE_TLS_PAIR_MULTIGOT = GOT_TYPE_TLS_OFFSET_MULTIGOT + 1024 +}; + +// TLS type of GOT entry. +enum Got_tls_type +{ + GOT_TLS_NONE = 0, + GOT_TLS_GD = 1, + GOT_TLS_LDM = 2, + GOT_TLS_IE = 4 +}; + +// Return TRUE if a relocation of type R_TYPE from OBJECT might +// require an la25 stub. See also local_pic_function, which determines +// whether the destination function ever requires a stub. +template<int size, bool big_endian> +static inline bool +relocation_needs_la25_stub(Mips_relobj<size, big_endian>* object, + unsigned int r_type, bool target_is_16_bit_code) +{ + // We specifically ignore branches and jumps from EF_PIC objects, + // where the onus is on the compiler or programmer to perform any + // necessary initialization of $25. Sometimes such initialization + // is unnecessary; for example, -mno-shared functions do not use + // the incoming value of $25, and may therefore be called directly. + if (object->is_pic()) + return false; + + switch (r_type) + { + case elfcpp::R_MIPS_26: + case elfcpp::R_MIPS_PC16: + case elfcpp::R_MICROMIPS_26_S1: + case elfcpp::R_MICROMIPS_PC7_S1: + case elfcpp::R_MICROMIPS_PC10_S1: + case elfcpp::R_MICROMIPS_PC16_S1: + case elfcpp::R_MICROMIPS_PC23_S2: + return true; + + case elfcpp::R_MIPS16_26: + return !target_is_16_bit_code; + + default: + return false; + } +} + +// Return true if SYM is a locally-defined PIC function, in the sense +// that it or its fn_stub might need $25 to be valid on entry. +// Note that MIPS16 functions set up $gp using PC-relative instructions, +// so they themselves never need $25 to be valid. Only non-MIPS16 +// entry points are of interest here. +template<int size, bool big_endian> +static inline bool +local_pic_function(Mips_symbol<size>* sym) +{ + bool def_regular = (sym->source() == Symbol::FROM_OBJECT + && !sym->object()->is_dynamic() + && !sym->is_undefined()); + + if (sym->is_defined() && def_regular) + { + Mips_relobj<size, big_endian>* object = + static_cast<Mips_relobj<size, big_endian>*>(sym->object()); + + if ((object->is_pic() || sym->is_pic()) + && (!sym->is_mips16() + || (sym->has_mips16_fn_stub() && sym->need_fn_stub()))) + return true; + } + return false; +} + +static inline bool +hi16_reloc(int r_type) +{ + return (r_type == elfcpp::R_MIPS_HI16 + || r_type == elfcpp::R_MIPS16_HI16 + || r_type == elfcpp::R_MICROMIPS_HI16); +} + +static inline bool +lo16_reloc(int r_type) +{ + return (r_type == elfcpp::R_MIPS_LO16 + || r_type == elfcpp::R_MIPS16_LO16 + || r_type == elfcpp::R_MICROMIPS_LO16); +} + +static inline bool +got16_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_GOT16 + || r_type == elfcpp::R_MIPS16_GOT16 + || r_type == elfcpp::R_MICROMIPS_GOT16); +} + +static inline bool +call_lo16_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_CALL_LO16 + || r_type == elfcpp::R_MICROMIPS_CALL_LO16); +} + +static inline bool +got_lo16_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_GOT_LO16 + || r_type == elfcpp::R_MICROMIPS_GOT_LO16); +} + +static inline bool +got_disp_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_GOT_DISP + || r_type == elfcpp::R_MICROMIPS_GOT_DISP); +} + +static inline bool +got_page_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_GOT_PAGE + || r_type == elfcpp::R_MICROMIPS_GOT_PAGE); +} + +static inline bool +tls_gd_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_TLS_GD + || r_type == elfcpp::R_MIPS16_TLS_GD + || r_type == elfcpp::R_MICROMIPS_TLS_GD); +} + +static inline bool +tls_gottprel_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_TLS_GOTTPREL + || r_type == elfcpp::R_MIPS16_TLS_GOTTPREL + || r_type == elfcpp::R_MICROMIPS_TLS_GOTTPREL); +} + +static inline bool +tls_ldm_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_TLS_LDM + || r_type == elfcpp::R_MIPS16_TLS_LDM + || r_type == elfcpp::R_MICROMIPS_TLS_LDM); +} + +static inline bool +mips16_call_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS16_26 + || r_type == elfcpp::R_MIPS16_CALL16); +} + +static inline bool +jal_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MIPS_26 + || r_type == elfcpp::R_MIPS16_26 + || r_type == elfcpp::R_MICROMIPS_26_S1); +} + +static inline bool +micromips_branch_reloc(unsigned int r_type) +{ + return (r_type == elfcpp::R_MICROMIPS_26_S1 + || r_type == elfcpp::R_MICROMIPS_PC16_S1 + || r_type == elfcpp::R_MICROMIPS_PC10_S1 + || r_type == elfcpp::R_MICROMIPS_PC7_S1); +} + +// Check if R_TYPE is a MIPS16 reloc. +static inline bool +mips16_reloc(unsigned int r_type) +{ + switch (r_type) + { + case elfcpp::R_MIPS16_26: + case elfcpp::R_MIPS16_GPREL: + case elfcpp::R_MIPS16_GOT16: + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MIPS16_HI16: + case elfcpp::R_MIPS16_LO16: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MIPS16_TLS_LDM: + case elfcpp::R_MIPS16_TLS_DTPREL_HI16: + case elfcpp::R_MIPS16_TLS_DTPREL_LO16: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MIPS16_TLS_TPREL_HI16: + case elfcpp::R_MIPS16_TLS_TPREL_LO16: + return true; + + default: + return false; + } +} + +// Check if R_TYPE is a microMIPS reloc. +static inline bool +micromips_reloc(unsigned int r_type) +{ + switch (r_type) + { + case elfcpp::R_MICROMIPS_26_S1: + case elfcpp::R_MICROMIPS_HI16: + case elfcpp::R_MICROMIPS_LO16: + case elfcpp::R_MICROMIPS_GPREL16: + case elfcpp::R_MICROMIPS_LITERAL: + case elfcpp::R_MICROMIPS_GOT16: + case elfcpp::R_MICROMIPS_PC7_S1: + case elfcpp::R_MICROMIPS_PC10_S1: + case elfcpp::R_MICROMIPS_PC16_S1: + case elfcpp::R_MICROMIPS_CALL16: + case elfcpp::R_MICROMIPS_GOT_DISP: + case elfcpp::R_MICROMIPS_GOT_PAGE: + case elfcpp::R_MICROMIPS_GOT_OFST: + case elfcpp::R_MICROMIPS_GOT_HI16: + case elfcpp::R_MICROMIPS_GOT_LO16: + case elfcpp::R_MICROMIPS_SUB: + case elfcpp::R_MICROMIPS_HIGHER: + case elfcpp::R_MICROMIPS_HIGHEST: + case elfcpp::R_MICROMIPS_CALL_HI16: + case elfcpp::R_MICROMIPS_CALL_LO16: + case elfcpp::R_MICROMIPS_SCN_DISP: + case elfcpp::R_MICROMIPS_JALR: + case elfcpp::R_MICROMIPS_HI0_LO16: + case elfcpp::R_MICROMIPS_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_LDM: + case elfcpp::R_MICROMIPS_TLS_DTPREL_HI16: + case elfcpp::R_MICROMIPS_TLS_DTPREL_LO16: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_TPREL_HI16: + case elfcpp::R_MICROMIPS_TLS_TPREL_LO16: + case elfcpp::R_MICROMIPS_GPREL7_S2: + case elfcpp::R_MICROMIPS_PC23_S2: + return true; + + default: + return false; + } +} + +static inline bool +is_matching_lo16_reloc(unsigned int high_reloc, unsigned int lo16_reloc) +{ + switch (high_reloc) + { + case elfcpp::R_MIPS_HI16: + case elfcpp::R_MIPS_GOT16: + return lo16_reloc == elfcpp::R_MIPS_LO16; + case elfcpp::R_MIPS16_HI16: + case elfcpp::R_MIPS16_GOT16: + return lo16_reloc == elfcpp::R_MIPS16_LO16; + case elfcpp::R_MICROMIPS_HI16: + case elfcpp::R_MICROMIPS_GOT16: + return lo16_reloc == elfcpp::R_MICROMIPS_LO16; + default: + return false; + } +} + +// This class is used to hold information about one GOT entry. +// There are three types of entry: +// +// (1) a SYMBOL + OFFSET address, where SYMBOL is local to an input object +// (object != NULL, symndx >= 0, tls_type != GOT_TLS_LDM) +// (2) a SYMBOL address, where SYMBOL is not local to an input object +// (object != NULL, symndx == -1) +// (3) a TLS LDM slot +// (object != NULL, symndx == 0, tls_type == GOT_TLS_LDM) + +template<int size, bool big_endian> +class Mips_got_entry +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + + public: + Mips_got_entry(Mips_relobj<size, big_endian>* object, unsigned int symndx, + Mips_address addend, unsigned char tls_type, + unsigned int shndx) + : object_(object), symndx_(symndx), tls_type_(tls_type), shndx_(shndx) + { this->d.addend = addend; } + + Mips_got_entry(Mips_relobj<size, big_endian>* object, Mips_symbol<size>* sym, + unsigned char tls_type) + : object_(object), symndx_(-1U), tls_type_(tls_type), shndx_(-1U) + { this->d.sym = sym; } + + // Return whether this entry is for a local symbol. + bool + is_for_local_symbol() const + { return this->symndx_ != -1U; } + + // Return whether this entry is for a global symbol. + bool + is_for_global_symbol() const + { return this->symndx_ == -1U; } + + // Return the hash of this entry. + size_t + hash() const + { + if (this->tls_type_ == GOT_TLS_LDM) + return this->symndx_ + (1 << 18); + if (this->symndx_ != -1U) + { + uintptr_t object_id = reinterpret_cast<uintptr_t>(this->object()); + return this->symndx_ + object_id + this->d.addend; + } + else + { + uintptr_t sym_id = reinterpret_cast<uintptr_t>(this->d.sym); + return this->symndx_ + sym_id; + } + } + + // Return whether this entry is equal to OTHER. + bool + equals(Mips_got_entry<size, big_endian>* other) const + { + if (this->symndx_ != other->symndx_ + || this->tls_type_ != other->tls_type_) + return false; + if (this->tls_type_ == GOT_TLS_LDM) + return true; + if (this->symndx_ != -1U) + return (this->object() == other->object() + && this->d.addend == other->d.addend); + else + return this->d.sym == other->d.sym; + } + + // Return input object that needs this GOT entry. + Mips_relobj<size, big_endian>* + object() const + { + gold_assert(this->object_ != NULL); + return this->object_; + } + + // Return local symbol index for local GOT entries. + unsigned int + symndx() const + { + gold_assert(this->symndx_ != -1U); + return this->symndx_; + } + + // Return the relocation addend for local GOT entries. + Mips_address + addend() const + { + gold_assert(this->symndx_ != -1U); + return this->d.addend; + } + + // Return global symbol for global GOT entries. + Mips_symbol<size>* + sym() const + { + gold_assert(this->symndx_ == -1U); + return this->d.sym; + } + + // Return whether this is a TLS GOT entry. + bool + is_tls_entry() const + { return this->tls_type_ != GOT_TLS_NONE; } + + // Return TLS type of this GOT entry. + unsigned char + tls_type() const + { return this->tls_type_; } + + // Return section index of the local symbol for local GOT entries. + unsigned int + shndx() const + { return this->shndx_; } + + private: + // The input object that needs the GOT entry. + Mips_relobj<size, big_endian>* object_; + // The index of the symbol if we have a local symbol; -1 otherwise. + unsigned int symndx_; + + union + { + // If symndx != -1, the addend of the relocation that should be added to the + // symbol value. + Mips_address addend; + // If symndx == -1, the global symbol corresponding to this GOT entry. The + // symbol's entry is in the local area if mips_sym->global_got_area is + // GGA_NONE, otherwise it is in the global area. + Mips_symbol<size>* sym; + } d; + + // The TLS type of this GOT entry. An LDM GOT entry will be a local + // symbol entry with r_symndx == 0. + unsigned char tls_type_; + + // For local GOT entries, section index of the local symbol. + unsigned int shndx_; +}; + +// Hash for Mips_got_entry. + +template<int size, bool big_endian> +class Mips_got_entry_hash +{ + public: + size_t + operator()(Mips_got_entry<size, big_endian>* entry) const + { return entry->hash(); } +}; + +// Equality for Mips_got_entry. + +template<int size, bool big_endian> +class Mips_got_entry_eq +{ + public: + bool + operator()(Mips_got_entry<size, big_endian>* e1, + Mips_got_entry<size, big_endian>* e2) const + { return e1->equals(e2); } +}; + +// Got_page_range. This class describes a range of addends: [MIN_ADDEND, +// MAX_ADDEND]. The instances form a non-overlapping list that is sorted by +// increasing MIN_ADDEND. + +struct Got_page_range +{ + Got_page_range() + : next(NULL), min_addend(0), max_addend(0) + { } + + Got_page_range* next; + int min_addend; + int max_addend; + + // Return the maximum number of GOT page entries required. + int + get_max_pages() + { return (this->max_addend - this->min_addend + 0x1ffff) >> 16; } +}; + +// Got_page_entry. This class describes the range of addends that are applied +// to page relocations against a given symbol. + +struct Got_page_entry +{ + Got_page_entry() + : object(NULL), symndx(-1U), ranges(NULL), num_pages(0) + { } + + Got_page_entry(Object* object_, unsigned int symndx_) + : object(object_), symndx(symndx_), ranges(NULL), num_pages(0) + { } + + // The input object that needs the GOT page entry. + Object* object; + // The index of the symbol, as stored in the relocation r_info. + unsigned int symndx; + // The ranges for this page entry. + Got_page_range* ranges; + // The maximum number of page entries needed for RANGES. + unsigned int num_pages; +}; + +// Hash for Got_page_entry. + +struct Got_page_entry_hash +{ + size_t + operator()(Got_page_entry* entry) const + { return reinterpret_cast<uintptr_t>(entry->object) + entry->symndx; } +}; + +// Equality for Got_page_entry. + +struct Got_page_entry_eq +{ + bool + operator()(Got_page_entry* entry1, Got_page_entry* entry2) const + { + return entry1->object == entry2->object && entry1->symndx == entry2->symndx; + } +}; + +// This class is used to hold .got information when linking. + +template<int size, bool big_endian> +class Mips_got_info +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + typedef Output_data_reloc<elfcpp::SHT_REL, true, size, big_endian> + Reloc_section; + typedef Unordered_map<unsigned int, unsigned int> Got_page_offsets; + + // Unordered set of GOT entries. + typedef Unordered_set<Mips_got_entry<size, big_endian>*, + Mips_got_entry_hash<size, big_endian>, + Mips_got_entry_eq<size, big_endian> > Got_entry_set; + + // Unordered set of GOT page entries. + typedef Unordered_set<Got_page_entry*, + Got_page_entry_hash, Got_page_entry_eq> Got_page_entry_set; + + public: + Mips_got_info() + : local_gotno_(0), page_gotno_(0), global_gotno_(0), reloc_only_gotno_(0), + tls_gotno_(0), tls_ldm_offset_(-1U), global_got_symbols_(), + got_entries_(), got_page_entries_(), got_page_offset_start_(0), + got_page_offset_next_(0), got_page_offsets_(), next_(NULL), index_(-1U), + offset_(0) + { } + + // Reserve GOT entry for a GOT relocation of type R_TYPE against symbol + // SYMNDX + ADDEND, where SYMNDX is a local symbol in section SHNDX in OBJECT. + void + record_local_got_symbol(Mips_relobj<size, big_endian>* object, + unsigned int symndx, Mips_address addend, + unsigned int r_type, unsigned int shndx); + + // Reserve GOT entry for a GOT relocation of type R_TYPE against MIPS_SYM, + // in OBJECT. FOR_CALL is true if the caller is only interested in + // using the GOT entry for calls. DYN_RELOC is true if R_TYPE is a dynamic + // relocation. + void + record_global_got_symbol(Mips_symbol<size>* mips_sym, + Mips_relobj<size, big_endian>* object, + unsigned int r_type, bool dyn_reloc, bool for_call); + + // Add ENTRY to master GOT and to OBJECT's GOT. + void + record_got_entry(Mips_got_entry<size, big_endian>* entry, + Mips_relobj<size, big_endian>* object); + + // Record that OBJECT has a page relocation against symbol SYMNDX and + // that ADDEND is the addend for that relocation. + void + record_got_page_entry(Mips_relobj<size, big_endian>* object, + unsigned int symndx, int addend); + + // Create all entries that should be in the local part of the GOT. + void + add_local_entries(Target_mips<size, big_endian>* target, Layout* layout); + + // Create GOT page entries. + void + add_page_entries(Target_mips<size, big_endian>* target, Layout* layout); + + // Create global GOT entries, both GGA_NORMAL and GGA_RELOC_ONLY. + void + add_global_entries(Target_mips<size, big_endian>* target, Layout* layout, + unsigned int non_reloc_only_global_gotno); + + // Create global GOT entries that should be in the GGA_RELOC_ONLY area. + void + add_reloc_only_entries(Mips_output_data_got<size, big_endian>* got); + + // Create TLS GOT entries. + void + add_tls_entries(Target_mips<size, big_endian>* target, Layout* layout); + + // Decide whether the symbol needs an entry in the global part of the primary + // GOT, setting global_got_area accordingly. Count the number of global + // symbols that are in the primary GOT only because they have dynamic + // relocations R_MIPS_REL32 against them (reloc_only_gotno). + void + count_got_symbols(Symbol_table* symtab); + + // Return the offset of GOT page entry for VALUE. + unsigned int + get_got_page_offset(Mips_address value, + Mips_output_data_got<size, big_endian>* got); + + // Count the number of GOT entries required. + void + count_got_entries(); + + // Count the number of GOT entries required by ENTRY. Accumulate the result. + void + count_got_entry(Mips_got_entry<size, big_endian>* entry); + + // Add FROM's GOT entries. + void + add_got_entries(Mips_got_info<size, big_endian>* from); + + // Add FROM's GOT page entries. + void + add_got_page_entries(Mips_got_info<size, big_endian>* from); + + // Return GOT size. + unsigned int + got_size() const + { return ((2 + this->local_gotno_ + this->page_gotno_ + this->global_gotno_ + + this->tls_gotno_) * size/8); + } + + // Return the number of local GOT entries. + unsigned int + local_gotno() const + { return this->local_gotno_; } + + // Return the maximum number of page GOT entries needed. + unsigned int + page_gotno() const + { return this->page_gotno_; } + + // Return the number of global GOT entries. + unsigned int + global_gotno() const + { return this->global_gotno_; } + + // Set the number of global GOT entries. + void + set_global_gotno(unsigned int global_gotno) + { this->global_gotno_ = global_gotno; } + + // Return the number of GGA_RELOC_ONLY global GOT entries. + unsigned int + reloc_only_gotno() const + { return this->reloc_only_gotno_; } + + // Return the number of TLS GOT entries. + unsigned int + tls_gotno() const + { return this->tls_gotno_; } + + // Return the GOT type for this GOT. Used for multi-GOT links only. + unsigned int + multigot_got_type(unsigned int got_type) const + { + switch (got_type) + { + case GOT_TYPE_STANDARD: + return GOT_TYPE_STANDARD_MULTIGOT + this->index_; + case GOT_TYPE_TLS_OFFSET: + return GOT_TYPE_TLS_OFFSET_MULTIGOT + this->index_; + case GOT_TYPE_TLS_PAIR: + return GOT_TYPE_TLS_PAIR_MULTIGOT + this->index_; + default: + gold_unreachable(); + } + } + + // Remove lazy-binding stubs for global symbols in this GOT. + void + remove_lazy_stubs(Target_mips<size, big_endian>* target); + + // Return offset of this GOT from the start of .got section. + unsigned int + offset() const + { return this->offset_; } + + // Set offset of this GOT from the start of .got section. + void + set_offset(unsigned int offset) + { this->offset_ = offset; } + + // Set index of this GOT in multi-GOT links. + void + set_index(unsigned int index) + { this->index_ = index; } + + // Return next GOT in multi-GOT links. + Mips_got_info<size, big_endian>* + next() const + { return this->next_; } + + // Set next GOT in multi-GOT links. + void + set_next(Mips_got_info<size, big_endian>* next) + { this->next_ = next; } + + // Return the offset of TLS LDM entry for this GOT. + unsigned int + tls_ldm_offset() const + { return this->tls_ldm_offset_; } + + // Set the offset of TLS LDM entry for this GOT. + void + set_tls_ldm_offset(unsigned int tls_ldm_offset) + { this->tls_ldm_offset_ = tls_ldm_offset; } + + Unordered_set<Mips_symbol<size>*>& + global_got_symbols() + { return this->global_got_symbols_; } + + // Return the GOT_TLS_* type required by relocation type R_TYPE. + static int + mips_elf_reloc_tls_type(unsigned int r_type) + { + if (tls_gd_reloc(r_type)) + return GOT_TLS_GD; + + if (tls_ldm_reloc(r_type)) + return GOT_TLS_LDM; + + if (tls_gottprel_reloc(r_type)) + return GOT_TLS_IE; + + return GOT_TLS_NONE; + } + + // Return the number of GOT slots needed for GOT TLS type TYPE. + static int + mips_tls_got_entries(unsigned int type) + { + switch (type) + { + case GOT_TLS_GD: + case GOT_TLS_LDM: + return 2; + + case GOT_TLS_IE: + return 1; + + case GOT_TLS_NONE: + return 0; + + default: + gold_unreachable(); + } + } + + private: + // The number of local GOT entries. + unsigned int local_gotno_; + // The maximum number of page GOT entries needed. + unsigned int page_gotno_; + // The number of global GOT entries. + unsigned int global_gotno_; + // The number of global GOT entries that are in the GGA_RELOC_ONLY area. + unsigned int reloc_only_gotno_; + // The number of TLS GOT entries. + unsigned int tls_gotno_; + // The offset of TLS LDM entry for this GOT. + unsigned int tls_ldm_offset_; + // All symbols that have global GOT entry. + Unordered_set<Mips_symbol<size>*> global_got_symbols_; + // A hash table holding GOT entries. + Got_entry_set got_entries_; + // A hash table of GOT page entries. + Got_page_entry_set got_page_entries_; + // The offset of first GOT page entry for this GOT. + unsigned int got_page_offset_start_; + // The offset of next available GOT page entry for this GOT. + unsigned int got_page_offset_next_; + // A hash table that maps GOT page entry value to the GOT offset where + // the entry is located. + Got_page_offsets got_page_offsets_; + // In multi-GOT links, a pointer to the next GOT. + Mips_got_info<size, big_endian>* next_; + // Index of this GOT in multi-GOT links. + unsigned int index_; + // The offset of this GOT in multi-GOT links. + unsigned int offset_; +}; + +// This is a helper class used during relocation scan. It records GOT16 addend. + +template<int size, bool big_endian> +struct got16_addend +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + + got16_addend(const Sized_relobj_file<size, big_endian>* _object, + unsigned int _shndx, unsigned int _r_type, unsigned int _r_sym, + Mips_address _addend) + : object(_object), shndx(_shndx), r_type(_r_type), r_sym(_r_sym), + addend(_addend) + { } + + const Sized_relobj_file<size, big_endian>* object; + unsigned int shndx; + unsigned int r_type; + unsigned int r_sym; + Mips_address addend; +}; + +// Mips_symbol class. Holds additional symbol information needed for Mips. + +template<int size> +class Mips_symbol : public Sized_symbol<size> +{ + public: + Mips_symbol() + : need_fn_stub_(false), has_nonpic_branches_(false), la25_stub_offset_(-1U), + has_static_relocs_(false), no_lazy_stub_(false), lazy_stub_offset_(0), + pointer_equality_needed_(false), global_got_area_(GGA_NONE), + global_gotoffset_(-1U), got_only_for_calls_(true), has_lazy_stub_(false), + needs_mips_plt_(false), needs_comp_plt_(false), mips_plt_offset_(-1U), + comp_plt_offset_(-1U), mips16_fn_stub_(NULL), mips16_call_stub_(NULL), + mips16_call_fp_stub_(NULL), applied_secondary_got_fixup_(false) + { } + + // Return whether this is a MIPS16 symbol. + bool + is_mips16() const + { + // (st_other & STO_MIPS16) == STO_MIPS16 + return ((this->nonvis() & (elfcpp::STO_MIPS16 >> 2)) + == elfcpp::STO_MIPS16 >> 2); + } + + // Return whether this is a microMIPS symbol. + bool + is_micromips() const + { + // (st_other & STO_MIPS_ISA) == STO_MICROMIPS + return ((this->nonvis() & (elfcpp::STO_MIPS_ISA >> 2)) + == elfcpp::STO_MICROMIPS >> 2); + } + + // Return whether the symbol needs MIPS16 fn_stub. + bool + need_fn_stub() const + { return this->need_fn_stub_; } + + // Set that the symbol needs MIPS16 fn_stub. + void + set_need_fn_stub() + { this->need_fn_stub_ = true; } + + // Return whether this symbol is referenced by branch relocations from + // any non-PIC input file. + bool + has_nonpic_branches() const + { return this->has_nonpic_branches_; } + + // Set that this symbol is referenced by branch relocations from + // any non-PIC input file. + void + set_has_nonpic_branches() + { this->has_nonpic_branches_ = true; } + + // Return the offset of the la25 stub for this symbol from the start of the + // la25 stub section. + unsigned int + la25_stub_offset() const + { return this->la25_stub_offset_; } + + // Set the offset of the la25 stub for this symbol from the start of the + // la25 stub section. + void + set_la25_stub_offset(unsigned int offset) + { this->la25_stub_offset_ = offset; } + + // Return whether the symbol has la25 stub. This is true if this symbol is + // for a PIC function, and there are non-PIC branches and jumps to it. + bool + has_la25_stub() const + { return this->la25_stub_offset_ != -1U; } + + // Return whether there is a relocation against this symbol that must be + // resolved by the static linker (that is, the relocation cannot possibly + // be made dynamic). + bool + has_static_relocs() const + { return this->has_static_relocs_; } + + // Set that there is a relocation against this symbol that must be resolved + // by the static linker (that is, the relocation cannot possibly be made + // dynamic). + void + set_has_static_relocs() + { this->has_static_relocs_ = true; } + + // Return whether we must not create a lazy-binding stub for this symbol. + bool + no_lazy_stub() const + { return this->no_lazy_stub_; } + + // Set that we must not create a lazy-binding stub for this symbol. + void + set_no_lazy_stub() + { this->no_lazy_stub_ = true; } + + // Return the offset of the lazy-binding stub for this symbol from the start + // of .MIPS.stubs section. + unsigned int + lazy_stub_offset() const + { return this->lazy_stub_offset_; } + + // Set the offset of the lazy-binding stub for this symbol from the start + // of .MIPS.stubs section. + void + set_lazy_stub_offset(unsigned int offset) + { this->lazy_stub_offset_ = offset; } + + // Return whether there are any relocations for this symbol where + // pointer equality matters. + bool + pointer_equality_needed() const + { return this->pointer_equality_needed_; } + + // Set that there are relocations for this symbol where pointer equality + // matters. + void + set_pointer_equality_needed() + { this->pointer_equality_needed_ = true; } + + // Return global GOT area where this symbol in located. + Global_got_area + global_got_area() const + { return this->global_got_area_; } + + // Set global GOT area where this symbol in located. + void + set_global_got_area(Global_got_area global_got_area) + { this->global_got_area_ = global_got_area; } + + // Return the global GOT offset for this symbol. For multi-GOT links, this + // returns the offset from the start of .got section to the first GOT entry + // for the symbol. Note that in multi-GOT links the symbol can have entry + // in more than one GOT. + unsigned int + global_gotoffset() const + { return this->global_gotoffset_; } + + // Set the global GOT offset for this symbol. Note that in multi-GOT links + // the symbol can have entry in more than one GOT. This method will set + // the offset only if it is less than current offset. + void + set_global_gotoffset(unsigned int offset) + { + if (this->global_gotoffset_ == -1U || offset < this->global_gotoffset_) + this->global_gotoffset_ = offset; + } + + // Return whether all GOT relocations for this symbol are for calls. + bool + got_only_for_calls() const + { return this->got_only_for_calls_; } + + // Set that there is a GOT relocation for this symbol that is not for call. + void + set_got_not_only_for_calls() + { this->got_only_for_calls_ = false; } + + // Return whether this is a PIC symbol. + bool + is_pic() const + { + // (st_other & STO_MIPS_FLAGS) == STO_MIPS_PIC + return ((this->nonvis() & (elfcpp::STO_MIPS_FLAGS >> 2)) + == (elfcpp::STO_MIPS_PIC >> 2)); + } + + // Set the flag in st_other field that marks this symbol as PIC. + void + set_pic() + { + if (this->is_mips16()) + // (st_other & ~(STO_MIPS16 | STO_MIPS_FLAGS)) | STO_MIPS_PIC + this->set_nonvis((this->nonvis() + & ~((elfcpp::STO_MIPS16 >> 2) + | (elfcpp::STO_MIPS_FLAGS >> 2))) + | (elfcpp::STO_MIPS_PIC >> 2)); + else + // (other & ~STO_MIPS_FLAGS) | STO_MIPS_PIC + this->set_nonvis((this->nonvis() & ~(elfcpp::STO_MIPS_FLAGS >> 2)) + | (elfcpp::STO_MIPS_PIC >> 2)); + } + + // Set the flag in st_other field that marks this symbol as PLT. + void + set_mips_plt() + { + if (this->is_mips16()) + // (st_other & (STO_MIPS16 | ~STO_MIPS_FLAGS)) | STO_MIPS_PLT + this->set_nonvis((this->nonvis() + & ((elfcpp::STO_MIPS16 >> 2) + | ~(elfcpp::STO_MIPS_FLAGS >> 2))) + | (elfcpp::STO_MIPS_PLT >> 2)); + + else + // (st_other & ~STO_MIPS_FLAGS) | STO_MIPS_PLT + this->set_nonvis((this->nonvis() & ~(elfcpp::STO_MIPS_FLAGS >> 2)) + | (elfcpp::STO_MIPS_PLT >> 2)); + } + + // Downcast a base pointer to a Mips_symbol pointer. + static Mips_symbol<size>* + as_mips_sym(Symbol* sym) + { return static_cast<Mips_symbol<size>*>(sym); } + + // Downcast a base pointer to a Mips_symbol pointer. + static const Mips_symbol<size>* + as_mips_sym(const Symbol* sym) + { return static_cast<const Mips_symbol<size>*>(sym); } + + // Return whether the symbol has lazy-binding stub. + bool + has_lazy_stub() const + { return this->has_lazy_stub_; } + + // Set whether the symbol has lazy-binding stub. + void + set_has_lazy_stub(bool has_lazy_stub) + { this->has_lazy_stub_ = has_lazy_stub; } + + // Return whether the symbol needs a standard PLT entry. + bool + needs_mips_plt() const + { return this->needs_mips_plt_; } + + // Set whether the symbol needs a standard PLT entry. + void + set_needs_mips_plt(bool needs_mips_plt) + { this->needs_mips_plt_ = needs_mips_plt; } + + // Return whether the symbol needs a compressed (MIPS16 or microMIPS) PLT + // entry. + bool + needs_comp_plt() const + { return this->needs_comp_plt_; } + + // Set whether the symbol needs a compressed (MIPS16 or microMIPS) PLT entry. + void + set_needs_comp_plt(bool needs_comp_plt) + { this->needs_comp_plt_ = needs_comp_plt; } + + // Return standard PLT entry offset, or -1 if none. + unsigned int + mips_plt_offset() const + { return this->mips_plt_offset_; } + + // Set standard PLT entry offset. + void + set_mips_plt_offset(unsigned int mips_plt_offset) + { this->mips_plt_offset_ = mips_plt_offset; } + + // Return whether the symbol has standard PLT entry. + bool + has_mips_plt_offset() const + { return this->mips_plt_offset_ != -1U; } + + // Return compressed (MIPS16 or microMIPS) PLT entry offset, or -1 if none. + unsigned int + comp_plt_offset() const + { return this->comp_plt_offset_; } + + // Set compressed (MIPS16 or microMIPS) PLT entry offset. + void + set_comp_plt_offset(unsigned int comp_plt_offset) + { this->comp_plt_offset_ = comp_plt_offset; } + + // Return whether the symbol has compressed (MIPS16 or microMIPS) PLT entry. + bool + has_comp_plt_offset() const + { return this->comp_plt_offset_ != -1U; } + + // Return MIPS16 fn stub for a symbol. + template<bool big_endian> + Mips16_stub_section<size, big_endian>* + get_mips16_fn_stub() const + { + return static_cast<Mips16_stub_section<size, big_endian>*>(mips16_fn_stub_); + } + + // Set MIPS16 fn stub for a symbol. + void + set_mips16_fn_stub(Mips16_stub_section_base* stub) + { this->mips16_fn_stub_ = stub; } + + // Return whether symbol has MIPS16 fn stub. + bool + has_mips16_fn_stub() const + { return this->mips16_fn_stub_ != NULL; } + + // Return MIPS16 call stub for a symbol. + template<bool big_endian> + Mips16_stub_section<size, big_endian>* + get_mips16_call_stub() const + { + return static_cast<Mips16_stub_section<size, big_endian>*>( + mips16_call_stub_); + } + + // Set MIPS16 call stub for a symbol. + void + set_mips16_call_stub(Mips16_stub_section_base* stub) + { this->mips16_call_stub_ = stub; } + + // Return whether symbol has MIPS16 call stub. + bool + has_mips16_call_stub() const + { return this->mips16_call_stub_ != NULL; } + + // Return MIPS16 call_fp stub for a symbol. + template<bool big_endian> + Mips16_stub_section<size, big_endian>* + get_mips16_call_fp_stub() const + { + return static_cast<Mips16_stub_section<size, big_endian>*>( + mips16_call_fp_stub_); + } + + // Set MIPS16 call_fp stub for a symbol. + void + set_mips16_call_fp_stub(Mips16_stub_section_base* stub) + { this->mips16_call_fp_stub_ = stub; } + + // Return whether symbol has MIPS16 call_fp stub. + bool + has_mips16_call_fp_stub() const + { return this->mips16_call_fp_stub_ != NULL; } + + bool + get_applied_secondary_got_fixup() const + { return applied_secondary_got_fixup_; } + + void + set_applied_secondary_got_fixup() + { this->applied_secondary_got_fixup_ = true; } + + private: + // Whether the symbol needs MIPS16 fn_stub. This is true if this symbol + // appears in any relocs other than a 16 bit call. + bool need_fn_stub_; + + // True if this symbol is referenced by branch relocations from + // any non-PIC input file. This is used to determine whether an + // la25 stub is required. + bool has_nonpic_branches_; + + // The offset of the la25 stub for this symbol from the start of the + // la25 stub section. + unsigned int la25_stub_offset_; + + // True if there is a relocation against this symbol that must be + // resolved by the static linker (that is, the relocation cannot + // possibly be made dynamic). + bool has_static_relocs_; + + // Whether we must not create a lazy-binding stub for this symbol. + // This is true if the symbol has relocations related to taking the + // function's address. + bool no_lazy_stub_; + + // The offset of the lazy-binding stub for this symbol from the start of + // .MIPS.stubs section. + unsigned int lazy_stub_offset_; + + // True if there are any relocations for this symbol where pointer equality + // matters. + bool pointer_equality_needed_; + + // Global GOT area where this symbol in located, or GGA_NONE if symbol is not + // in the global part of the GOT. + Global_got_area global_got_area_; + + // The global GOT offset for this symbol. For multi-GOT links, this is offset + // from the start of .got section to the first GOT entry for the symbol. + // Note that in multi-GOT links the symbol can have entry in more than one GOT. + unsigned int global_gotoffset_; + + // Whether all GOT relocations for this symbol are for calls. + bool got_only_for_calls_; + // Whether the symbol has lazy-binding stub. + bool has_lazy_stub_; + // Whether the symbol needs a standard PLT entry. + bool needs_mips_plt_; + // Whether the symbol needs a compressed (MIPS16 or microMIPS) PLT entry. + bool needs_comp_plt_; + // Standard PLT entry offset, or -1 if none. + unsigned int mips_plt_offset_; + // Compressed (MIPS16 or microMIPS) PLT entry offset, or -1 if none. + unsigned int comp_plt_offset_; + // MIPS16 fn stub for a symbol. + Mips16_stub_section_base* mips16_fn_stub_; + // MIPS16 call stub for a symbol. + Mips16_stub_section_base* mips16_call_stub_; + // MIPS16 call_fp stub for a symbol. + Mips16_stub_section_base* mips16_call_fp_stub_; + + bool applied_secondary_got_fixup_; +}; + +// Mips16_stub_section class. + +// The mips16 compiler uses a couple of special sections to handle +// floating point arguments. + +// Section names that look like .mips16.fn.FNNAME contain stubs that +// copy floating point arguments from the fp regs to the gp regs and +// then jump to FNNAME. If any 32 bit function calls FNNAME, the +// call should be redirected to the stub instead. If no 32 bit +// function calls FNNAME, the stub should be discarded. We need to +// consider any reference to the function, not just a call, because +// if the address of the function is taken we will need the stub, +// since the address might be passed to a 32 bit function. + +// Section names that look like .mips16.call.FNNAME contain stubs +// that copy floating point arguments from the gp regs to the fp +// regs and then jump to FNNAME. If FNNAME is a 32 bit function, +// then any 16 bit function that calls FNNAME should be redirected +// to the stub instead. If FNNAME is not a 32 bit function, the +// stub should be discarded. + +// .mips16.call.fp.FNNAME sections are similar, but contain stubs +// which call FNNAME and then copy the return value from the fp regs +// to the gp regs. These stubs store the return address in $18 while +// calling FNNAME; any function which might call one of these stubs +// must arrange to save $18 around the call. (This case is not +// needed for 32 bit functions that call 16 bit functions, because +// 16 bit functions always return floating point values in both +// $f0/$f1 and $2/$3.) + +// Note that in all cases FNNAME might be defined statically. +// Therefore, FNNAME is not used literally. Instead, the relocation +// information will indicate which symbol the section is for. + +// We record any stubs that we find in the symbol table. + +// TODO(sasa): All mips16 stub sections should be emitted in the .text section. + +class Mips16_stub_section_base { }; + +template<int size, bool big_endian> +class Mips16_stub_section : public Mips16_stub_section_base +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + + public: + Mips16_stub_section(Mips_relobj<size, big_endian>* object, unsigned int shndx) + : object_(object), shndx_(shndx), r_sym_(0), gsym_(NULL), + found_r_mips_none_(false) + { + gold_assert(object->is_mips16_fn_stub_section(shndx) + || object->is_mips16_call_stub_section(shndx) + || object->is_mips16_call_fp_stub_section(shndx)); + } + + // Return the object of this stub section. + Mips_relobj<size, big_endian>* + object() const + { return this->object_; } + + // Return the size of a section. + uint64_t + section_size() const + { return this->object_->section_size(this->shndx_); } + + // Return section index of this stub section. + unsigned int + shndx() const + { return this->shndx_; } + + // Return symbol index, if stub is for a local function. + unsigned int + r_sym() const + { return this->r_sym_; } + + // Return symbol, if stub is for a global function. + Mips_symbol<size>* + gsym() const + { return this->gsym_; } + + // Return whether stub is for a local function. + bool + is_for_local_function() const + { return this->gsym_ == NULL; } + + // This method is called when a new relocation R_TYPE for local symbol R_SYM + // is found in the stub section. Try to find stub target. + void + new_local_reloc_found(unsigned int r_type, unsigned int r_sym) + { + // To find target symbol for this stub, trust the first R_MIPS_NONE + // relocation, if any. Otherwise trust the first relocation, whatever + // its kind. + if (this->found_r_mips_none_) + return; + if (r_type == elfcpp::R_MIPS_NONE) + { + this->r_sym_ = r_sym; + this->gsym_ = NULL; + this->found_r_mips_none_ = true; + } + else if (!is_target_found()) + this->r_sym_ = r_sym; + } + + // This method is called when a new relocation R_TYPE for global symbol GSYM + // is found in the stub section. Try to find stub target. + void + new_global_reloc_found(unsigned int r_type, Mips_symbol<size>* gsym) + { + // To find target symbol for this stub, trust the first R_MIPS_NONE + // relocation, if any. Otherwise trust the first relocation, whatever + // its kind. + if (this->found_r_mips_none_) + return; + if (r_type == elfcpp::R_MIPS_NONE) + { + this->gsym_ = gsym; + this->r_sym_ = 0; + this->found_r_mips_none_ = true; + } + else if (!is_target_found()) + this->gsym_ = gsym; + } + + // Return whether we found the stub target. + bool + is_target_found() const + { return this->r_sym_ != 0 || this->gsym_ != NULL; } + + // Return whether this is a fn stub. + bool + is_fn_stub() const + { return this->object_->is_mips16_fn_stub_section(this->shndx_); } + + // Return whether this is a call stub. + bool + is_call_stub() const + { return this->object_->is_mips16_call_stub_section(this->shndx_); } + + // Return whether this is a call_fp stub. + bool + is_call_fp_stub() const + { return this->object_->is_mips16_call_fp_stub_section(this->shndx_); } + + // Return the output address. + Mips_address + output_address() const + { + return (this->object_->output_section(this->shndx_)->address() + + this->object_->output_section_offset(this->shndx_)); + } + + private: + // The object of this stub section. + Mips_relobj<size, big_endian>* object_; + // The section index of this stub section. + unsigned int shndx_; + // The symbol index, if stub is for a local function. + unsigned int r_sym_; + // The symbol, if stub is for a global function. + Mips_symbol<size>* gsym_; + // True if we found R_MIPS_NONE relocation in this stub. + bool found_r_mips_none_; +}; + +// Mips_relobj class. + +template<int size, bool big_endian> +class Mips_relobj : public Sized_relobj_file<size, big_endian> +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + typedef std::map<unsigned int, Mips16_stub_section<size, big_endian>*> + Mips16_stubs_int_map; + typedef typename elfcpp::Swap<size, big_endian>::Valtype Valtype; + + public: + Mips_relobj(const std::string& name, Input_file* input_file, off_t offset, + const typename elfcpp::Ehdr<size, big_endian>& ehdr) + : Sized_relobj_file<size, big_endian>(name, input_file, offset, ehdr), + processor_specific_flags_(0), local_symbol_is_mips16_(), + local_symbol_is_micromips_(), mips16_stub_sections_(), + local_non_16bit_calls_(), local_16bit_calls_(), local_mips16_fn_stubs_(), + local_mips16_call_stubs_(), gp_(0), got_info_(NULL), + section_is_mips16_fn_stub_(), section_is_mips16_call_stub_(), + section_is_mips16_call_fp_stub_(), pdr_shndx_(-1U), gprmask_(0), + cprmask1_(0), cprmask2_(0), cprmask3_(0), cprmask4_(0) + { + this->is_pic_ = (ehdr.get_e_flags() & elfcpp::EF_MIPS_PIC) != 0; + this->is_n32_ = elfcpp::abi_n32(ehdr.get_e_flags()); + this->is_n64_ = elfcpp::abi_64(ehdr.get_e_ident()[elfcpp::EI_CLASS]); + } + + ~Mips_relobj() + { } + + // Downcast a base pointer to a Mips_relobj pointer. This is + // not type-safe but we only use Mips_relobj not the base class. + static Mips_relobj<size, big_endian>* + as_mips_relobj(Relobj* relobj) + { return static_cast<Mips_relobj<size, big_endian>*>(relobj); } + + // Downcast a base pointer to a Mips_relobj pointer. This is + // not type-safe but we only use Mips_relobj not the base class. + static const Mips_relobj<size, big_endian>* + as_mips_relobj(const Relobj* relobj) + { return static_cast<const Mips_relobj<size, big_endian>*>(relobj); } + + // Processor-specific flags in ELF file header. This is valid only after + // reading symbols. + elfcpp::Elf_Word + processor_specific_flags() const + { return this->processor_specific_flags_; } + + // Whether a local symbol is MIPS16 symbol. R_SYM is the symbol table + // index. This is only valid after do_count_local_symbol is called. + bool + local_symbol_is_mips16(unsigned int r_sym) const + { + gold_assert(r_sym < this->local_symbol_is_mips16_.size()); + return this->local_symbol_is_mips16_[r_sym]; + } + + // Whether a local symbol is microMIPS symbol. R_SYM is the symbol table + // index. This is only valid after do_count_local_symbol is called. + bool + local_symbol_is_micromips(unsigned int r_sym) const + { + gold_assert(r_sym < this->local_symbol_is_micromips_.size()); + return this->local_symbol_is_micromips_[r_sym]; + } + + // Get or create MIPS16 stub section. + Mips16_stub_section<size, big_endian>* + get_mips16_stub_section(unsigned int shndx) + { + typename Mips16_stubs_int_map::const_iterator it = + this->mips16_stub_sections_.find(shndx); + if (it != this->mips16_stub_sections_.end()) + return (*it).second; + + Mips16_stub_section<size, big_endian>* stub_section = + new Mips16_stub_section<size, big_endian>(this, shndx); + this->mips16_stub_sections_.insert( + std::pair<unsigned int, Mips16_stub_section<size, big_endian>*>( + stub_section->shndx(), stub_section)); + return stub_section; + } + + // Return MIPS16 fn stub section for local symbol R_SYM, or NULL if this + // object doesn't have fn stub for R_SYM. + Mips16_stub_section<size, big_endian>* + get_local_mips16_fn_stub(unsigned int r_sym) const + { + typename Mips16_stubs_int_map::const_iterator it = + this->local_mips16_fn_stubs_.find(r_sym); + if (it != this->local_mips16_fn_stubs_.end()) + return (*it).second; + return NULL; + } + + // Record that this object has MIPS16 fn stub for local symbol. This method + // is only called if we decided not to discard the stub. + void + add_local_mips16_fn_stub(Mips16_stub_section<size, big_endian>* stub) + { + gold_assert(stub->is_for_local_function()); + unsigned int r_sym = stub->r_sym(); + this->local_mips16_fn_stubs_.insert( + std::pair<unsigned int, Mips16_stub_section<size, big_endian>*>( + r_sym, stub)); + } + + // Return MIPS16 call stub section for local symbol R_SYM, or NULL if this + // object doesn't have call stub for R_SYM. + Mips16_stub_section<size, big_endian>* + get_local_mips16_call_stub(unsigned int r_sym) const + { + typename Mips16_stubs_int_map::const_iterator it = + this->local_mips16_call_stubs_.find(r_sym); + if (it != this->local_mips16_call_stubs_.end()) + return (*it).second; + return NULL; + } + + // Record that this object has MIPS16 call stub for local symbol. This method + // is only called if we decided not to discard the stub. + void + add_local_mips16_call_stub(Mips16_stub_section<size, big_endian>* stub) + { + gold_assert(stub->is_for_local_function()); + unsigned int r_sym = stub->r_sym(); + this->local_mips16_call_stubs_.insert( + std::pair<unsigned int, Mips16_stub_section<size, big_endian>*>( + r_sym, stub)); + } + + // Record that we found "non 16-bit" call relocation against local symbol + // SYMNDX. This reloc would need to refer to a MIPS16 fn stub, if there + // is one. + void + add_local_non_16bit_call(unsigned int symndx) + { this->local_non_16bit_calls_.insert(symndx); } + + // Return true if there is any "non 16-bit" call relocation against local + // symbol SYMNDX in this object. + bool + has_local_non_16bit_call_relocs(unsigned int symndx) + { + return (this->local_non_16bit_calls_.find(symndx) + != this->local_non_16bit_calls_.end()); + } + + // Record that we found 16-bit call relocation R_MIPS16_26 against local + // symbol SYMNDX. Local MIPS16 call or call_fp stubs will only be needed + // if there is some R_MIPS16_26 relocation that refers to the stub symbol. + void + add_local_16bit_call(unsigned int symndx) + { this->local_16bit_calls_.insert(symndx); } + + // Return true if there is any 16-bit call relocation R_MIPS16_26 against local + // symbol SYMNDX in this object. + bool + has_local_16bit_call_relocs(unsigned int symndx) + { + return (this->local_16bit_calls_.find(symndx) + != this->local_16bit_calls_.end()); + } + + // Get gp value that was used to create this object. + Mips_address + gp_value() const + { return this->gp_; } + + // Return whether the object is a PIC object. + bool + is_pic() const + { return this->is_pic_; } + + // Return whether the object uses N32 ABI. + bool + is_n32() const + { return this->is_n32_; } + + // Return whether the object uses N64 ABI. + bool + is_n64() const + { return this->is_n64_; } + + // Return whether the object uses NewABI conventions. + bool + is_newabi() const + { return this->is_n32_ || this->is_n64_; } + + // Return Mips_got_info for this object. + Mips_got_info<size, big_endian>* + get_got_info() const + { return this->got_info_; } + + // Return Mips_got_info for this object. Create new info if it doesn't exist. + Mips_got_info<size, big_endian>* + get_or_create_got_info() + { + if (!this->got_info_) + this->got_info_ = new Mips_got_info<size, big_endian>(); + return this->got_info_; + } + + // Set Mips_got_info for this object. + void + set_got_info(Mips_got_info<size, big_endian>* got_info) + { this->got_info_ = got_info; } + + // Whether a section SHDNX is a MIPS16 stub section. This is only valid + // after do_read_symbols is called. + bool + is_mips16_stub_section(unsigned int shndx) + { + return (is_mips16_fn_stub_section(shndx) + || is_mips16_call_stub_section(shndx) + || is_mips16_call_fp_stub_section(shndx)); + } + + // Return TRUE if relocations in section SHNDX can refer directly to a + // MIPS16 function rather than to a hard-float stub. This is only valid + // after do_read_symbols is called. + bool + section_allows_mips16_refs(unsigned int shndx) + { + return (this->is_mips16_stub_section(shndx) || shndx == this->pdr_shndx_); + } + + // Whether a section SHDNX is a MIPS16 fn stub section. This is only valid + // after do_read_symbols is called. + bool + is_mips16_fn_stub_section(unsigned int shndx) + { + gold_assert(shndx < this->section_is_mips16_fn_stub_.size()); + return this->section_is_mips16_fn_stub_[shndx]; + } + + // Whether a section SHDNX is a MIPS16 call stub section. This is only valid + // after do_read_symbols is called. + bool + is_mips16_call_stub_section(unsigned int shndx) + { + gold_assert(shndx < this->section_is_mips16_call_stub_.size()); + return this->section_is_mips16_call_stub_[shndx]; + } + + // Whether a section SHDNX is a MIPS16 call_fp stub section. This is only + // valid after do_read_symbols is called. + bool + is_mips16_call_fp_stub_section(unsigned int shndx) + { + gold_assert(shndx < this->section_is_mips16_call_fp_stub_.size()); + return this->section_is_mips16_call_fp_stub_[shndx]; + } + + // Discard MIPS16 stub secions that are not needed. + void + discard_mips16_stub_sections(Symbol_table* symtab); + + // Return gprmask from the .reginfo section of this object. + Valtype + gprmask() const + { return this->gprmask_; } + + // Return cprmask1 from the .reginfo section of this object. + Valtype + cprmask1() const + { return this->cprmask1_; } + + // Return cprmask2 from the .reginfo section of this object. + Valtype + cprmask2() const + { return this->cprmask2_; } + + // Return cprmask3 from the .reginfo section of this object. + Valtype + cprmask3() const + { return this->cprmask3_; } + + // Return cprmask4 from the .reginfo section of this object. + Valtype + cprmask4() const + { return this->cprmask4_; } + + protected: + // Count the local symbols. + void + do_count_local_symbols(Stringpool_template<char>*, + Stringpool_template<char>*); + + // Read the symbol information. + void + do_read_symbols(Read_symbols_data* sd); + + private: + // processor-specific flags in ELF file header. + elfcpp::Elf_Word processor_specific_flags_; + + // Bit vector to tell if a local symbol is a MIPS16 symbol or not. + // This is only valid after do_count_local_symbol is called. + std::vector<bool> local_symbol_is_mips16_; + + // Bit vector to tell if a local symbol is a microMIPS symbol or not. + // This is only valid after do_count_local_symbol is called. + std::vector<bool> local_symbol_is_micromips_; + + // Map from section index to the MIPS16 stub for that section. This contains + // all stubs found in this object. + Mips16_stubs_int_map mips16_stub_sections_; + + // Local symbols that have "non 16-bit" call relocation. This relocation + // would need to refer to a MIPS16 fn stub, if there is one. + std::set<unsigned int> local_non_16bit_calls_; + + // Local symbols that have 16-bit call relocation R_MIPS16_26. Local MIPS16 + // call or call_fp stubs will only be needed if there is some R_MIPS16_26 + // relocation that refers to the stub symbol. + std::set<unsigned int> local_16bit_calls_; + + // Map from local symbol index to the MIPS16 fn stub for that symbol. + // This contains only the stubs that we decided not to discard. + Mips16_stubs_int_map local_mips16_fn_stubs_; + + // Map from local symbol index to the MIPS16 call stub for that symbol. + // This contains only the stubs that we decided not to discard. + Mips16_stubs_int_map local_mips16_call_stubs_; + + // gp value that was used to create this object. + Mips_address gp_; + // Whether the object is a PIC object. + bool is_pic_ : 1; + // Whether the object uses N32 ABI. + bool is_n32_ : 1; + // Whether the object uses N64 ABI. + bool is_n64_ : 1; + // The Mips_got_info for this object. + Mips_got_info<size, big_endian>* got_info_; + + // Bit vector to tell if a section is a MIPS16 fn stub section or not. + // This is only valid after do_read_symbols is called. + std::vector<bool> section_is_mips16_fn_stub_; + + // Bit vector to tell if a section is a MIPS16 call stub section or not. + // This is only valid after do_read_symbols is called. + std::vector<bool> section_is_mips16_call_stub_; + + // Bit vector to tell if a section is a MIPS16 call_fp stub section or not. + // This is only valid after do_read_symbols is called. + std::vector<bool> section_is_mips16_call_fp_stub_; + + // .pdr section index. + unsigned int pdr_shndx_; + + // gprmask from the .reginfo section of this object. + Valtype gprmask_; + // cprmask1 from the .reginfo section of this object. + Valtype cprmask1_; + // cprmask2 from the .reginfo section of this object. + Valtype cprmask2_; + // cprmask3 from the .reginfo section of this object. + Valtype cprmask3_; + // cprmask4 from the .reginfo section of this object. + Valtype cprmask4_; +}; + +// Mips_output_data_got class. + +template<int size, bool big_endian> +class Mips_output_data_got : public Output_data_got<size, big_endian> +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + typedef Output_data_reloc<elfcpp::SHT_REL, true, size, big_endian> + Reloc_section; + typedef typename elfcpp::Swap<size, big_endian>::Valtype Valtype; + + public: + Mips_output_data_got(Target_mips<size, big_endian>* target, + Symbol_table* symtab, Layout* layout) + : Output_data_got<size, big_endian>(), target_(target), + symbol_table_(symtab), layout_(layout), static_relocs_(), got_view_(NULL), + first_global_got_dynsym_index_(-1U), primary_got_(NULL), + secondary_got_relocs_() + { + this->master_got_info_ = new Mips_got_info<size, big_endian>(); + this->set_addralign(16); + } + + // Reserve GOT entry for a GOT relocation of type R_TYPE against symbol + // SYMNDX + ADDEND, where SYMNDX is a local symbol in section SHNDX in OBJECT. + void + record_local_got_symbol(Mips_relobj<size, big_endian>* object, + unsigned int symndx, Mips_address addend, + unsigned int r_type, unsigned int shndx) + { + this->master_got_info_->record_local_got_symbol(object, symndx, addend, + r_type, shndx); + } + + // Reserve GOT entry for a GOT relocation of type R_TYPE against MIPS_SYM, + // in OBJECT. FOR_CALL is true if the caller is only interested in + // using the GOT entry for calls. DYN_RELOC is true if R_TYPE is a dynamic + // relocation. + void + record_global_got_symbol(Mips_symbol<size>* mips_sym, + Mips_relobj<size, big_endian>* object, + unsigned int r_type, bool dyn_reloc, bool for_call) + { + this->master_got_info_->record_global_got_symbol(mips_sym, object, r_type, + dyn_reloc, for_call); + } + + // Record that OBJECT has a page relocation against symbol SYMNDX and + // that ADDEND is the addend for that relocation. + void + record_got_page_entry(Mips_relobj<size, big_endian>* object, + unsigned int symndx, int addend) + { this->master_got_info_->record_got_page_entry(object, symndx, addend); } + + // Add a static entry for the GOT entry at OFFSET. GSYM is a global + // symbol and R_TYPE is the code of a dynamic relocation that needs to be + // applied in a static link. + void + add_static_reloc(unsigned int got_offset, unsigned int r_type, + Mips_symbol<size>* gsym) + { this->static_relocs_.push_back(Static_reloc(got_offset, r_type, gsym)); } + + // Add a static reloc for the GOT entry at OFFSET. RELOBJ is an object + // defining a local symbol with INDEX. R_TYPE is the code of a dynamic + // relocation that needs to be applied in a static link. + void + add_static_reloc(unsigned int got_offset, unsigned int r_type, + Sized_relobj_file<size, big_endian>* relobj, + unsigned int index) + { + this->static_relocs_.push_back(Static_reloc(got_offset, r_type, relobj, + index)); + } + + // Record that global symbol GSYM has R_TYPE dynamic relocation in the + // secondary GOT at OFFSET. + void + add_secondary_got_reloc(unsigned int got_offset, unsigned int r_type, + Mips_symbol<size>* gsym) + { + this->secondary_got_relocs_.push_back(Static_reloc(got_offset, + r_type, gsym)); + } + + // Update GOT entry at OFFSET with VALUE. + void + update_got_entry(unsigned int offset, Mips_address value) + { + elfcpp::Swap<size, big_endian>::writeval(this->got_view_ + offset, value); + } + + // Return the number of entries in local part of the GOT. This includes + // local entries, page entries and 2 reserved entries. + unsigned int + get_local_gotno() const + { + if (!this->multi_got()) + { + return (2 + this->master_got_info_->local_gotno() + + this->master_got_info_->page_gotno()); + } + else + return 2 + this->primary_got_->local_gotno() + this->primary_got_->page_gotno(); + } + + // Return dynamic symbol table index of the first symbol with global GOT + // entry. + unsigned int + first_global_got_dynsym_index() const + { return this->first_global_got_dynsym_index_; } + + // Set dynamic symbol table index of the first symbol with global GOT entry. + void + set_first_global_got_dynsym_index(unsigned int index) + { this->first_global_got_dynsym_index_ = index; } + + // Lay out the GOT. Add local, global and TLS entries. If GOT is + // larger than 64K, create multi-GOT. + void + lay_out_got(Layout* layout, Symbol_table* symtab, + const Input_objects* input_objects); + + // Create multi-GOT. For every GOT, add local, global and TLS entries. + void + lay_out_multi_got(Layout* layout, const Input_objects* input_objects); + + // Attempt to merge GOTs of different input objects. + void + merge_gots(const Input_objects* input_objects); + + // Consider merging FROM, which is OBJECT's GOT, into TO. Return false if + // this would lead to overflow, true if they were merged successfully. + bool + merge_got_with(Mips_got_info<size, big_endian>* from, + Mips_relobj<size, big_endian>* object, + Mips_got_info<size, big_endian>* to); + + // Return the offset of GOT page entry for VALUE. For multi-GOT links, + // use OBJECT's GOT. + unsigned int + get_got_page_offset(Mips_address value, + const Mips_relobj<size, big_endian>* object) + { + Mips_got_info<size, big_endian>* g = (!this->multi_got() + ? this->master_got_info_ + : object->get_got_info()); + gold_assert(g != NULL); + return g->get_got_page_offset(value, this); + } + + // Return the GOT offset of type GOT_TYPE of the global symbol + // GSYM. For multi-GOT links, use OBJECT's GOT. + unsigned int got_offset(const Symbol* gsym, unsigned int got_type, + Mips_relobj<size, big_endian>* object) const + { + if (!this->multi_got()) + return gsym->got_offset(got_type); + else + { + Mips_got_info<size, big_endian>* g = object->get_got_info(); + gold_assert(g != NULL); + return gsym->got_offset(g->multigot_got_type(got_type)); + } + } + + // Return the GOT offset of type GOT_TYPE of the local symbol + // SYMNDX. + unsigned int + got_offset(unsigned int symndx, unsigned int got_type, + Sized_relobj_file<size, big_endian>* object) const + { return object->local_got_offset(symndx, got_type); } + + // Return the offset of TLS LDM entry. For multi-GOT links, use OBJECT's GOT. + unsigned int + tls_ldm_offset(Mips_relobj<size, big_endian>* object) const + { + Mips_got_info<size, big_endian>* g = (!this->multi_got() + ? this->master_got_info_ + : object->get_got_info()); + gold_assert(g != NULL); + return g->tls_ldm_offset(); + } + + // Set the offset of TLS LDM entry. For multi-GOT links, use OBJECT's GOT. + void + set_tls_ldm_offset(unsigned int tls_ldm_offset, + Mips_relobj<size, big_endian>* object) + { + Mips_got_info<size, big_endian>* g = (!this->multi_got() + ? this->master_got_info_ + : object->get_got_info()); + gold_assert(g != NULL); + g->set_tls_ldm_offset(tls_ldm_offset); + } + + // Return true for multi-GOT links. + bool + multi_got() const + { return this->primary_got_ != NULL; } + + // Return the offset of OBJECT's GOT from the start of .got section. + unsigned int + get_got_offset(const Mips_relobj<size, big_endian>* object) + { + if (!this->multi_got()) + return 0; + else + { + Mips_got_info<size, big_endian>* g = object->get_got_info(); + return g != NULL ? g->offset() : 0; + } + } + + // Create global GOT entries that should be in the GGA_RELOC_ONLY area. + void + add_reloc_only_entries() + { this->master_got_info_->add_reloc_only_entries(this); } + + // Return offset of the primary GOT's entry for global symbol. + unsigned int + get_primary_got_offset(const Mips_symbol<size>* sym) const + { + gold_assert(sym->global_got_area() != GGA_NONE); + return (this->get_local_gotno() + sym->dynsym_index() + - this->first_global_got_dynsym_index()) * size/8; + } + + // For the entry at offset GOT_OFFSET, return its offset from the gp. + // Input argument GOT_OFFSET is always global offset from the start of + // .got section, for both single and multi-GOT links. + // For single GOT links, this returns GOT_OFFSET - 0x7FF0. For multi-GOT + // links, the return value is object_got_offset - 0x7FF0, where + // object_got_offset is offset in the OBJECT's GOT. + int + gp_offset(unsigned int got_offset, + const Mips_relobj<size, big_endian>* object) const + { + return (this->address() + got_offset + - this->target_->adjusted_gp_value(object)); + } + + protected: + // Write out the GOT table. + void + do_write(Output_file*); + + private: + + // This class represent dynamic relocations that need to be applied by + // gold because we are using TLS relocations in a static link. + class Static_reloc + { + public: + Static_reloc(unsigned int got_offset, unsigned int r_type, + Mips_symbol<size>* gsym) + : got_offset_(got_offset), r_type_(r_type), symbol_is_global_(true) + { this->u_.global.symbol = gsym; } + + Static_reloc(unsigned int got_offset, unsigned int r_type, + Sized_relobj_file<size, big_endian>* relobj, unsigned int index) + : got_offset_(got_offset), r_type_(r_type), symbol_is_global_(false) + { + this->u_.local.relobj = relobj; + this->u_.local.index = index; + } + + // Return the GOT offset. + unsigned int + got_offset() const + { return this->got_offset_; } + + // Relocation type. + unsigned int + r_type() const + { return this->r_type_; } + + // Whether the symbol is global or not. + bool + symbol_is_global() const + { return this->symbol_is_global_; } + + // For a relocation against a global symbol, the global symbol. + Mips_symbol<size>* + symbol() const + { + gold_assert(this->symbol_is_global_); + return this->u_.global.symbol; + } + + // For a relocation against a local symbol, the defining object. + Sized_relobj_file<size, big_endian>* + relobj() const + { + gold_assert(!this->symbol_is_global_); + return this->u_.local.relobj; + } + + // For a relocation against a local symbol, the local symbol index. + unsigned int + index() const + { + gold_assert(!this->symbol_is_global_); + return this->u_.local.index; + } + + private: + // GOT offset of the entry to which this relocation is applied. + unsigned int got_offset_; + // Type of relocation. + unsigned int r_type_; + // Whether this relocation is against a global symbol. + bool symbol_is_global_; + // A global or local symbol. + union + { + struct + { + // For a global symbol, the symbol itself. + Mips_symbol<size>* symbol; + } global; + struct + { + // For a local symbol, the object defining object. + Sized_relobj_file<size, big_endian>* relobj; + // For a local symbol, the symbol index. + unsigned int index; + } local; + } u_; + }; + + // The target. + Target_mips<size, big_endian>* target_; + // The symbol table. + Symbol_table* symbol_table_; + // The layout. + Layout* layout_; + // Static relocs to be applied to the GOT. + std::vector<Static_reloc> static_relocs_; + // .got section view. + unsigned char* got_view_; + // The dynamic symbol table index of the first symbol with global GOT entry. + unsigned int first_global_got_dynsym_index_; + // The master GOT information. + Mips_got_info<size, big_endian>* master_got_info_; + // The primary GOT information. + Mips_got_info<size, big_endian>* primary_got_; + // Secondary GOT fixups. + std::vector<Static_reloc> secondary_got_relocs_; +}; + +// A class to handle LA25 stubs - non-PIC interface to a PIC function. There are +// two ways of creating these interfaces. The first is to add: +// +// lui $25,%hi(func) +// j func +// addiu $25,$25,%lo(func) +// +// to a separate trampoline section. The second is to add: +// +// lui $25,%hi(func) +// addiu $25,$25,%lo(func) +// +// immediately before a PIC function "func", but only if a function is at the +// beginning of the section, and the section is not too heavily aligned (i.e we +// would need to add no more than 2 nops before the stub.) +// +// We only create stubs of the first type. + +template<int size, bool big_endian> +class Mips_output_data_la25_stub : public Output_section_data +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + + public: + Mips_output_data_la25_stub() + : Output_section_data(size == 32 ? 4 : 8), symbols_() + { } + + // Create LA25 stub for a symbol. + void + create_la25_stub(Symbol_table* symtab, Target_mips<size, big_endian>* target, + Mips_symbol<size>* gsym); + + // Return output address of a stub. + Mips_address + stub_address(const Mips_symbol<size>* sym) const + { + gold_assert(sym->has_la25_stub()); + return this->address() + sym->la25_stub_offset(); + } + + protected: + void + do_adjust_output_section(Output_section* os) + { os->set_entsize(0); } + + private: + // Template for standard LA25 stub. + static const uint32_t la25_stub_entry[]; + // Template for microMIPS LA25 stub. + static const uint32_t la25_stub_micromips_entry[]; + + // Set the final size. + void + set_final_data_size() + { this->set_data_size(this->symbols_.size() * 16); } + + // Create a symbol for SYM stub's value and size, to help make the + // disassembly easier to read. + void + create_stub_symbol(Mips_symbol<size>* sym, Symbol_table* symtab, + Target_mips<size, big_endian>* target, uint64_t symsize); + + // Write out the LA25 stub section. + void + do_write(Output_file*); + + // Symbols that have LA25 stubs. + Unordered_set<Mips_symbol<size>*> symbols_; +}; + +// A class to handle the PLT data. + +template<int size, bool big_endian> +class Mips_output_data_plt : public Output_section_data +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + typedef Output_data_reloc<elfcpp::SHT_REL, true, + size, big_endian> Reloc_section; + + public: + // Create the PLT section. The ordinary .got section is an argument, + // since we need to refer to the start. + Mips_output_data_plt(Layout* layout, Output_data_space* got_plt, + Target_mips<size, big_endian>* target) + : Output_section_data(size == 32 ? 4 : 8), got_plt_(got_plt), symbols_(), + plt_mips_offset_(0), plt_comp_offset_(0), plt_header_size_(0), + target_(target) + { + this->rel_ = new Reloc_section(false); + layout->add_output_section_data(".rel.plt", elfcpp::SHT_REL, + elfcpp::SHF_ALLOC, this->rel_, + ORDER_DYNAMIC_PLT_RELOCS, false); + } + + // Add an entry to the PLT for a symbol referenced by r_type relocation. + void + add_entry(Mips_symbol<size>* gsym, unsigned int r_type); + + // Return the .rel.plt section data. + const Reloc_section* + rel_plt() const + { return this->rel_; } + + // Return the number of PLT entries. + unsigned int + entry_count() const + { return this->symbols_.size(); } + + // Return the offset of the first non-reserved PLT entry. + unsigned int + first_plt_entry_offset() const + { return sizeof(plt0_entry_o32); } + + // Return the size of a PLT entry. + unsigned int + plt_entry_size() const + { return sizeof(plt_entry); } + + // Set final PLT offsets. For each symbol, determine whether standard or + // compressed (MIPS16 or microMIPS) PLT entry is used. + void + set_plt_offsets(); + + // Return the offset of the first standard PLT entry. + unsigned int + first_mips_plt_offset() const + { return this->plt_header_size_; } + + // Return the offset of the first compressed PLT entry. + unsigned int + first_comp_plt_offset() const + { return this->plt_header_size_ + this->plt_mips_offset_; } + + // Return whether there are any standard PLT entries. + bool + has_standard_entries() const + { return this->plt_mips_offset_ > 0; } + + // Return the output address of standard PLT entry. + Mips_address + mips_entry_address(const Mips_symbol<size>* sym) const + { + gold_assert (sym->has_mips_plt_offset()); + return (this->address() + this->first_mips_plt_offset() + + sym->mips_plt_offset()); + } + + // Return the output address of compressed (MIPS16 or microMIPS) PLT entry. + Mips_address + comp_entry_address(const Mips_symbol<size>* sym) const + { + gold_assert (sym->has_comp_plt_offset()); + return (this->address() + this->first_comp_plt_offset() + + sym->comp_plt_offset()); + } + + protected: + void + do_adjust_output_section(Output_section* os) + { os->set_entsize(0); } + + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _(".plt")); } + + private: + // Template for the first PLT entry. + static const uint32_t plt0_entry_o32[]; + static const uint32_t plt0_entry_n32[]; + static const uint32_t plt0_entry_n64[]; + static const uint32_t plt0_entry_micromips_o32[]; + static const uint32_t plt0_entry_micromips32_o32[]; + + // Template for subsequent PLT entries. + static const uint32_t plt_entry[]; + static const uint32_t plt_entry_mips16_o32[]; + static const uint32_t plt_entry_micromips_o32[]; + static const uint32_t plt_entry_micromips32_o32[]; + + // Set the final size. + void + set_final_data_size() + { + this->set_data_size(this->plt_header_size_ + this->plt_mips_offset_ + + this->plt_comp_offset_); + } + + // Write out the PLT data. + void + do_write(Output_file*); + + // Return whether the plt header contains microMIPS code. For the sake of + // cache alignment always use a standard header whenever any standard entries + // are present even if microMIPS entries are present as well. This also lets + // the microMIPS header rely on the value of $v0 only set by microMIPS + // entries, for a small size reduction. + bool + is_plt_header_compressed() const + { + gold_assert(this->plt_mips_offset_ + this->plt_comp_offset_ != 0); + return this->target_->is_output_micromips() && this->plt_mips_offset_ == 0; + } + + // Return the size of the PLT header. + unsigned int + get_plt_header_size() const + { + if (this->target_->is_output_n64()) + return 4 * sizeof(plt0_entry_n64) / sizeof(plt0_entry_n64[0]); + else if (this->target_->is_output_n32()) + return 4 * sizeof(plt0_entry_n32) / sizeof(plt0_entry_n32[0]); + else if (!this->is_plt_header_compressed()) + return 4 * sizeof(plt0_entry_o32) / sizeof(plt0_entry_o32[0]); + else if (this->target_->use_32bit_micromips_instructions()) + return (2 * sizeof(plt0_entry_micromips32_o32) + / sizeof(plt0_entry_micromips32_o32[0])); + else + return (2 * sizeof(plt0_entry_micromips_o32) + / sizeof(plt0_entry_micromips_o32[0])); + } + + // Return the PLT header entry. + const uint32_t* + get_plt_header_entry() const + { + if (this->target_->is_output_n64()) + return plt0_entry_n64; + else if (this->target_->is_output_n32()) + return plt0_entry_n32; + else if (!this->is_plt_header_compressed()) + return plt0_entry_o32; + else if (this->target_->use_32bit_micromips_instructions()) + return plt0_entry_micromips32_o32; + else + return plt0_entry_micromips_o32; + } + + // Return the size of the standard PLT entry. + unsigned int + standard_plt_entry_size() const + { return 4 * sizeof(plt_entry) / sizeof(plt_entry[0]); } + + // Return the size of the compressed PLT entry. + unsigned int + compressed_plt_entry_size() const + { + gold_assert(!this->target_->is_output_newabi()); + + if (!this->target_->is_output_micromips()) + return (2 * sizeof(plt_entry_mips16_o32) + / sizeof(plt_entry_mips16_o32[0])); + else if (this->target_->use_32bit_micromips_instructions()) + return (2 * sizeof(plt_entry_micromips32_o32) + / sizeof(plt_entry_micromips32_o32[0])); + else + return (2 * sizeof(plt_entry_micromips_o32) + / sizeof(plt_entry_micromips_o32[0])); + } + + // The reloc section. + Reloc_section* rel_; + // The .got.plt section. + Output_data_space* got_plt_; + // Symbols that have PLT entry. + std::vector<Mips_symbol<size>*> symbols_; + // The offset of the next standard PLT entry to create. + unsigned int plt_mips_offset_; + // The offset of the next compressed PLT entry to create. + unsigned int plt_comp_offset_; + // The size of the PLT header in bytes. + unsigned int plt_header_size_; + // The target. + Target_mips<size, big_endian>* target_; +}; + +// A class to handle the .MIPS.stubs data. + +template<int size, bool big_endian> +class Mips_output_data_mips_stubs : public Output_section_data +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + + public: + Mips_output_data_mips_stubs(Target_mips<size, big_endian>* target) + : Output_section_data(size == 32 ? 4 : 8), symbols_(), dynsym_count_(-1U), + stub_offsets_are_set_(false), target_(target) + { } + + // Create entry for a symbol. + void + make_entry(Mips_symbol<size>*); + + // Remove entry for a symbol. + void + remove_entry(Mips_symbol<size>* gsym); + + // Set stub offsets for symbols. This method expects that the number of + // entries in dynamic symbol table is set. + void + set_lazy_stub_offsets(); + + void + set_needs_dynsym_value(); + + // Set the number of entries in dynamic symbol table. + void + set_dynsym_count(unsigned int dynsym_count) + { this->dynsym_count_ = dynsym_count; } + + // Return maximum size of the stub, ie. the stub size if the dynamic symbol + // count is greater than 0x10000. If the dynamic symbol count is less than + // 0x10000, the stub will be 4 bytes smaller. + // There's no disadvantage from using microMIPS code here, so for the sake of + // pure-microMIPS binaries we prefer it whenever there's any microMIPS code in + // output produced at all. This has a benefit of stubs being shorter by + // 4 bytes each too, unless in the insn32 mode. + unsigned int + stub_max_size() const + { + if (!this->target_->is_output_micromips() + || this->target_->use_32bit_micromips_instructions()) + return 20; + else + return 16; + } + + // Return the size of the stub. This method expects that the final dynsym + // count is set. + unsigned int + stub_size() const + { + gold_assert(this->dynsym_count_ != -1U); + if (this->dynsym_count_ > 0x10000) + return this->stub_max_size(); + else + return this->stub_max_size() - 4; + } + + // Return output address of a stub. + Mips_address + stub_address(const Mips_symbol<size>* sym) const + { + gold_assert(sym->has_lazy_stub()); + return this->address() + sym->lazy_stub_offset(); + } + + protected: + void + do_adjust_output_section(Output_section* os) + { os->set_entsize(0); } + + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _(".MIPS.stubs")); } + + private: + static const uint32_t lazy_stub_normal_1[]; + static const uint32_t lazy_stub_normal_1_n64[]; + static const uint32_t lazy_stub_normal_2[]; + static const uint32_t lazy_stub_normal_2_n64[]; + static const uint32_t lazy_stub_big[]; + static const uint32_t lazy_stub_big_n64[]; + + static const uint32_t lazy_stub_micromips_normal_1[]; + static const uint32_t lazy_stub_micromips_normal_1_n64[]; + static const uint32_t lazy_stub_micromips_normal_2[]; + static const uint32_t lazy_stub_micromips_normal_2_n64[]; + static const uint32_t lazy_stub_micromips_big[]; + static const uint32_t lazy_stub_micromips_big_n64[]; + + static const uint32_t lazy_stub_micromips32_normal_1[]; + static const uint32_t lazy_stub_micromips32_normal_1_n64[]; + static const uint32_t lazy_stub_micromips32_normal_2[]; + static const uint32_t lazy_stub_micromips32_normal_2_n64[]; + static const uint32_t lazy_stub_micromips32_big[]; + static const uint32_t lazy_stub_micromips32_big_n64[]; + + // Set the final size. + void + set_final_data_size() + { this->set_data_size(this->symbols_.size() * this->stub_max_size()); } + + // Write out the .MIPS.stubs data. + void + do_write(Output_file*); + + // .MIPS.stubs symbols + Unordered_set<Mips_symbol<size>*> symbols_; + // Number of entries in dynamic symbol table. + unsigned int dynsym_count_; + // Whether the stub offsets are set. + bool stub_offsets_are_set_; + // The target. + Target_mips<size, big_endian>* target_; +}; + +// This class handles Mips .reginfo output section. + +template<int size, bool big_endian> +class Mips_output_section_reginfo : public Output_section +{ + typedef typename elfcpp::Swap<size, big_endian>::Valtype Valtype; + + public: + Mips_output_section_reginfo(const char* name, elfcpp::Elf_Word type, + elfcpp::Elf_Xword flags, + Target_mips<size, big_endian>* target) + : Output_section(name, type, flags), target_(target), gprmask_(0), + cprmask1_(0), cprmask2_(0), cprmask3_(0), cprmask4_(0) + { } + + // Downcast a base pointer to a Mips_output_section_reginfo pointer. + static Mips_output_section_reginfo<size, big_endian>* + as_mips_output_section_reginfo(Output_section* os) + { return static_cast<Mips_output_section_reginfo<size, big_endian>*>(os); } + + // Set masks of the output .reginfo section. + void + set_masks(Valtype gprmask, Valtype cprmask1, Valtype cprmask2, + Valtype cprmask3, Valtype cprmask4) + { + this->gprmask_ = gprmask; + this->cprmask1_ = cprmask1; + this->cprmask2_ = cprmask2; + this->cprmask3_ = cprmask3; + this->cprmask4_ = cprmask4; + } + + protected: + // Set the final data size. + void + set_final_data_size() + { this->set_data_size(24); } + + // Write out reginfo section. + void + do_write(Output_file* of); + + private: + Target_mips<size, big_endian>* target_; + + // gprmask of the output .reginfo section. + Valtype gprmask_; + // cprmask1 of the output .reginfo section. + Valtype cprmask1_; + // cprmask2 of the output .reginfo section. + Valtype cprmask2_; + // cprmask3 of the output .reginfo section. + Valtype cprmask3_; + // cprmask4 of the output .reginfo section. + Valtype cprmask4_; +}; + +// The MIPS target has relocation types which default handling of relocatable +// relocation cannot process. So we have to extend the default code. + +template<bool big_endian, int sh_type, typename Classify_reloc> +class Mips_scan_relocatable_relocs : + public Default_scan_relocatable_relocs<sh_type, Classify_reloc> +{ + public: + // Return the strategy to use for a local symbol which is a section + // symbol, given the relocation type. + inline Relocatable_relocs::Reloc_strategy + local_section_strategy(unsigned int r_type, Relobj* object) + { + if (sh_type == elfcpp::SHT_RELA) + return Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_RELA; + else + { + switch (r_type) + { + case elfcpp::R_MIPS_26: + return Relocatable_relocs::RELOC_SPECIAL; + + default: + return Default_scan_relocatable_relocs<sh_type, Classify_reloc>:: + local_section_strategy(r_type, object); + } + } + } +}; + +// Mips_copy_relocs class. The only difference from the base class is the +// method emit_mips, which should be called instead of Copy_reloc_entry::emit. +// Mips cannot convert all relocation types to dynamic relocs. If a reloc +// cannot be made dynamic, a COPY reloc is emitted. + +template<int sh_type, int size, bool big_endian> +class Mips_copy_relocs : public Copy_relocs<sh_type, size, big_endian> +{ + public: + Mips_copy_relocs() + : Copy_relocs<sh_type, size, big_endian>(elfcpp::R_MIPS_COPY) + { } + + // Emit any saved relocations which turn out to be needed. This is + // called after all the relocs have been scanned. + void + emit_mips(Output_data_reloc<sh_type, true, size, big_endian>*, + Symbol_table*, Layout*, Target_mips<size, big_endian>*); + + private: + typedef typename Copy_relocs<sh_type, size, big_endian>::Copy_reloc_entry + Copy_reloc_entry; + + // Emit this reloc if appropriate. This is called after we have + // scanned all the relocations, so we know whether we emitted a + // COPY relocation for SYM_. + void + emit_entry(Copy_reloc_entry& entry, + Output_data_reloc<sh_type, true, size, big_endian>* reloc_section, + Symbol_table* symtab, Layout* layout, + Target_mips<size, big_endian>* target); +}; + + +// Return true if the symbol SYM should be considered to resolve local +// to the current module, and false otherwise. The logic is taken from +// GNU ld's method _bfd_elf_symbol_refs_local_p. +static bool +symbol_refs_local(const Symbol* sym, bool has_dynsym_entry, + bool local_protected) +{ + // If it's a local sym, of course we resolve locally. + if (sym == NULL) + return true; + + // STV_HIDDEN or STV_INTERNAL ones must be local. + if (sym->visibility() == elfcpp::STV_HIDDEN + || sym->visibility() == elfcpp::STV_INTERNAL) + return true; + + // If we don't have a definition in a regular file, then we can't + // resolve locally. The sym is either undefined or dynamic. + if (sym->source() != Symbol::FROM_OBJECT || sym->object()->is_dynamic() + || sym->is_undefined()) + return false; + + // Forced local symbols resolve locally. + if (sym->is_forced_local()) + return true; + + // As do non-dynamic symbols. + if (!has_dynsym_entry) + return true; + + // At this point, we know the symbol is defined and dynamic. In an + // executable it must resolve locally, likewise when building symbolic + // shared libraries. + if (parameters->options().output_is_executable() + || parameters->options().Bsymbolic()) + return true; + + // Now deal with defined dynamic symbols in shared libraries. Ones + // with default visibility might not resolve locally. + if (sym->visibility() == elfcpp::STV_DEFAULT) + return false; + + // STV_PROTECTED non-function symbols are local. + if (sym->type() != elfcpp::STT_FUNC) + return true; + + // Function pointer equality tests may require that STV_PROTECTED + // symbols be treated as dynamic symbols. If the address of a + // function not defined in an executable is set to that function's + // plt entry in the executable, then the address of the function in + // a shared library must also be the plt entry in the executable. + return local_protected; +} + +// Return TRUE if references to this symbol always reference the symbol in this +// object. +static bool +symbol_references_local(const Symbol* sym, bool has_dynsym_entry) +{ + return symbol_refs_local(sym, has_dynsym_entry, false); +} + +// Return TRUE if calls to this symbol always call the version in this object. +static bool +symbol_calls_local(const Symbol* sym, bool has_dynsym_entry) +{ + return symbol_refs_local(sym, has_dynsym_entry, true); +} + +// Compare GOT offsets of two symbols. + +template<int size, bool big_endian> +static bool +got_offset_compare(Symbol* sym1, Symbol* sym2) +{ + Mips_symbol<size>* mips_sym1 = Mips_symbol<size>::as_mips_sym(sym1); + Mips_symbol<size>* mips_sym2 = Mips_symbol<size>::as_mips_sym(sym2); + unsigned int area1 = mips_sym1->global_got_area(); + unsigned int area2 = mips_sym2->global_got_area(); + gold_assert(area1 != GGA_NONE && area1 != GGA_NONE); + + // GGA_NORMAL entries always come before GGA_RELOC_ONLY. + if (area1 != area2) + return area1 < area2; + + return mips_sym1->global_gotoffset() < mips_sym2->global_gotoffset(); +} + +// This method divides dynamic symbols into symbols that have GOT entry, and +// symbols that don't have GOT entry. It also sorts symbols with the GOT entry. +// Mips ABI requires that symbols with the GOT entry must be at the end of +// dynamic symbol table, and the order in dynamic symbol table must match the +// order in GOT. + +template<int size, bool big_endian> +static void +reorder_dyn_symbols(std::vector<Symbol*>* dyn_symbols, + std::vector<Symbol*>* non_got_symbols, + std::vector<Symbol*>* got_symbols) +{ + for (std::vector<Symbol*>::iterator p = dyn_symbols->begin(); + p != dyn_symbols->end(); + ++p) + { + Mips_symbol<size>* mips_sym = Mips_symbol<size>::as_mips_sym(*p); + if (mips_sym->global_got_area() == GGA_NORMAL + || mips_sym->global_got_area() == GGA_RELOC_ONLY) + got_symbols->push_back(mips_sym); + else + non_got_symbols->push_back(mips_sym); + } + + std::sort(got_symbols->begin(), got_symbols->end(), + got_offset_compare<size, big_endian>); +} + +// Functor class for processing the global symbol table. + +template<int size, bool big_endian> +class Symbol_visitor_check_symbols +{ + public: + Symbol_visitor_check_symbols(Target_mips<size, big_endian>* target, + Layout* layout, Symbol_table* symtab) + : target_(target), layout_(layout), symtab_(symtab) + { } + + void + operator()(Sized_symbol<size>* sym) + { + Mips_symbol<size>* mips_sym = Mips_symbol<size>::as_mips_sym(sym); + if (local_pic_function<size, big_endian>(mips_sym)) + { + // SYM is a function that might need $25 to be valid on entry. + // If we're creating a non-PIC relocatable object, mark SYM as + // being PIC. If we're creating a non-relocatable object with + // non-PIC branches and jumps to SYM, make sure that SYM has an la25 + // stub. + if (parameters->options().relocatable()) + { + if (!parameters->options().output_is_position_independent()) + mips_sym->set_pic(); + } + else if (mips_sym->has_nonpic_branches()) + { + this->target_->la25_stub_section(layout_) + ->create_la25_stub(this->symtab_, this->target_, mips_sym); + } + } + } + + private: + Target_mips<size, big_endian>* target_; + Layout* layout_; + Symbol_table* symtab_; +}; + +template<int size, bool big_endian> +class Target_mips : public Sized_target<size, big_endian> +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + typedef Output_data_reloc<elfcpp::SHT_REL, true, size, big_endian> + Reloc_section; + typedef Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian> + Reloca_section; + typedef typename elfcpp::Swap<32, big_endian>::Valtype Valtype32; + typedef typename elfcpp::Swap<size, big_endian>::Valtype Valtype; + + public: + Target_mips(const Target::Target_info* info = &mips_info) + : Sized_target<size, big_endian>(info), got_(NULL), gp_(NULL), plt_(NULL), + got_plt_(NULL), rel_dyn_(NULL), copy_relocs_(), + dyn_relocs_(), la25_stub_(NULL), mips_mach_extensions_(), + mips_stubs_(NULL), ei_class_(0), mach_(0), layout_(NULL), + got16_addends_(), entry_symbol_is_compressed_(false), insn32_(false) + { + this->add_machine_extensions(); + } + + // The offset of $gp from the beginning of the .got section. + static const unsigned int MIPS_GP_OFFSET = 0x7ff0; + + // The maximum size of the GOT for it to be addressable using 16-bit + // offsets from $gp. + static const unsigned int MIPS_GOT_MAX_SIZE = MIPS_GP_OFFSET + 0x7fff; + + // Make a new symbol table entry for the Mips target. + Sized_symbol<size>* + make_symbol() const + { return new Mips_symbol<size>(); } + + // Process the relocations to determine unreferenced sections for + // garbage collection. + void + gc_process_relocs(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols); + + // Scan the relocations to look for symbol adjustments. + void + scan_relocs(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols); + + // Finalize the sections. + void + do_finalize_sections(Layout*, const Input_objects*, Symbol_table*); + + // Relocate a section. + void + relocate_section(const Relocate_info<size, big_endian>*, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + unsigned char* view, + Mips_address view_address, + section_size_type view_size, + const Reloc_symbol_changes*); + + // Scan the relocs during a relocatable link. + void + scan_relocatable_relocs(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols, + Relocatable_relocs*); + + // Emit relocations for a section. + void + relocate_relocs(const Relocate_info<size, big_endian>*, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + typename elfcpp::Elf_types<size>::Elf_Off + offset_in_output_section, + const Relocatable_relocs*, + unsigned char* view, + Mips_address view_address, + section_size_type view_size, + unsigned char* reloc_view, + section_size_type reloc_view_size); + + // Perform target-specific processing in a relocatable link. This is + // only used if we use the relocation strategy RELOC_SPECIAL. + void + relocate_special_relocatable(const Relocate_info<size, big_endian>* relinfo, + unsigned int sh_type, + const unsigned char* preloc_in, + size_t relnum, + Output_section* output_section, + typename elfcpp::Elf_types<size>::Elf_Off + offset_in_output_section, + unsigned char* view, + Mips_address view_address, + section_size_type view_size, + unsigned char* preloc_out); + + // Return whether SYM is defined by the ABI. + bool + do_is_defined_by_abi(const Symbol* sym) const + { + return ((strcmp(sym->name(), "__gnu_local_gp") == 0) + || (strcmp(sym->name(), "_gp_disp") == 0) + || (strcmp(sym->name(), "___tls_get_addr") == 0)); + } + + // Return the number of entries in the GOT. + unsigned int + got_entry_count() const + { + if (!this->has_got_section()) + return 0; + return this->got_size() / (size/8); + } + + // Return the number of entries in the PLT. + unsigned int + plt_entry_count() const + { + if (this->plt_ == NULL) + return 0; + return this->plt_->entry_count(); + } + + // Return the offset of the first non-reserved PLT entry. + unsigned int + first_plt_entry_offset() const + { return this->plt_->first_plt_entry_offset(); } + + // Return the size of each PLT entry. + unsigned int + plt_entry_size() const + { return this->plt_->plt_entry_size(); } + + // Get the GOT section, creating it if necessary. + Mips_output_data_got<size, big_endian>* + got_section(Symbol_table*, Layout*); + + // Get the GOT section. + Mips_output_data_got<size, big_endian>* + got_section() const + { + gold_assert(this->got_ != NULL); + return this->got_; + } + + // Get the .MIPS.stubs section, creating it if necessary. + Mips_output_data_mips_stubs<size, big_endian>* + mips_stubs_section(Layout* layout); + + // Get the .MIPS.stubs section. + Mips_output_data_mips_stubs<size, big_endian>* + mips_stubs_section() const + { + gold_assert(this->mips_stubs_ != NULL); + return this->mips_stubs_; + } + + // Get the LA25 stub section, creating it if necessary. + Mips_output_data_la25_stub<size, big_endian>* + la25_stub_section(Layout*); + + // Get the LA25 stub section. + Mips_output_data_la25_stub<size, big_endian>* + la25_stub_section() + { + gold_assert(this->la25_stub_ != NULL); + return this->la25_stub_; + } + + // Get gp value. It has the value of .got + 0x7FF0. + Mips_address + gp_value() const + { + if (this->gp_ != NULL) + return this->gp_->value(); + return 0; + } + + // Get gp value. It has the value of .got + 0x7FF0. Adjust it for + // multi-GOT links so that OBJECT's GOT + 0x7FF0 is returned. + Mips_address + adjusted_gp_value(const Mips_relobj<size, big_endian>* object) + { + if (this->gp_ == NULL) + return 0; + + bool multi_got = false; + if (this->has_got_section()) + multi_got = this->got_section()->multi_got(); + if (!multi_got) + return this->gp_->value(); + else + return this->gp_->value() + this->got_section()->get_got_offset(object); + } + + // Get the dynamic reloc section, creating it if necessary. + Reloc_section* + rel_dyn_section(Layout*); + + bool + do_has_custom_set_dynsym_indexes() const + { return true; } + + // Don't emit input .reginfo sections to output .reginfo. + bool + do_should_include_section(elfcpp::Elf_Word sh_type) const + { return sh_type != elfcpp::SHT_MIPS_REGINFO; } + + // Set the dynamic symbol indexes. INDEX is the index of the first + // global dynamic symbol. Pointers to the symbols are stored into the + // vector SYMS. The names are added to DYNPOOL. This returns an + // updated dynamic symbol index. + unsigned int + do_set_dynsym_indexes(std::vector<Symbol*>* dyn_symbols, unsigned int index, + std::vector<Symbol*>* syms, Stringpool* dynpool, + Versions* versions, Symbol_table* symtab) const; + + // Remove .MIPS.stubs entry for a symbol. + void + remove_lazy_stub_entry(Mips_symbol<size>* sym) + { + if (this->mips_stubs_ != NULL) + this->mips_stubs_->remove_entry(sym); + } + + // The value to write into got[1] for SVR4 targets, to identify it is + // a GNU object. The dynamic linker can then use got[1] to store the + // module pointer. + uint64_t + mips_elf_gnu_got1_mask() + { + if (this->is_output_n64()) + return (uint64_t)1 << 63; + else + return 1 << 31; + } + + // Whether the output has microMIPS code. This is valid only after + // merge_processor_specific_flags() is called. + bool + is_output_micromips() const + { + gold_assert(this->are_processor_specific_flags_set()); + return elfcpp::is_micromips(this->processor_specific_flags()); + } + + // Whether the output uses N32 ABI. This is valid only after + // merge_processor_specific_flags() is called. + bool + is_output_n32() const + { + gold_assert(this->are_processor_specific_flags_set()); + return elfcpp::abi_n32(this->processor_specific_flags()); + } + + // Whether the output uses N64 ABI. This is valid only after + // merge_processor_specific_flags() is called. + bool + is_output_n64() const + { + gold_assert(this->are_processor_specific_flags_set()); + return elfcpp::abi_64(this->ei_class_); + } + + // Whether the output uses NEWABI. This is valid only after + // merge_processor_specific_flags() is called. + bool + is_output_newabi() const + { return this->is_output_n32() || this->is_output_n64(); } + + // Whether we can only use 32-bit microMIPS instructions. + bool + use_32bit_micromips_instructions() const + { return this->insn32_; } + + protected: + // Return the value to use for a dynamic symbol which requires special + // treatment. This is how we support equality comparisons of function + // pointers across shared library boundaries, as described in the + // processor specific ABI supplement. + uint64_t + do_dynsym_value(const Symbol* gsym) const; + + // Make an ELF object. + Object* + do_make_elf_object(const std::string&, Input_file*, off_t, + const elfcpp::Ehdr<size, big_endian>& ehdr); + + Object* + do_make_elf_object(const std::string&, Input_file*, off_t, + const elfcpp::Ehdr<size, !big_endian>&) + { gold_unreachable(); } + + // Make an output section. + Output_section* + do_make_output_section(const char* name, elfcpp::Elf_Word type, + elfcpp::Elf_Xword flags) + { + if (type == elfcpp::SHT_MIPS_REGINFO) + return new Mips_output_section_reginfo<size, big_endian>(name, type, + flags, this); + else + return new Output_section(name, type, flags); + } + + // Adjust ELF file header. + void + do_adjust_elf_header(unsigned char* view, int len); + + // Get the custom dynamic tag value. + unsigned int + do_dynamic_tag_custom_value(elfcpp::DT) const; + + // Adjust the value written to the dynamic symbol table. + virtual void + do_adjust_dyn_symbol(const Symbol* sym, unsigned char* view) const + { + elfcpp::Sym<size, big_endian> isym(view); + elfcpp::Sym_write<size, big_endian> osym(view); + const Mips_symbol<size>* mips_sym = Mips_symbol<size>::as_mips_sym(sym); + + // Keep dynamic compressed symbols odd. This allows the dynamic linker + // to treat compressed symbols like any other. + Mips_address value = isym.get_st_value(); + if (mips_sym->is_mips16() && value != 0) + { + if (!mips_sym->has_mips16_fn_stub()) + value |= 1; + else + { + // If we have a MIPS16 function with a stub, the dynamic symbol + // must refer to the stub, since only the stub uses the standard + // calling conventions. Stub contains MIPS32 code, so don't add +1 + // in this case. + + // There is a code which does this in the method + // Target_mips::do_dynsym_value, but that code will only be + // executed if the symbol is from dynobj. + // TODO(sasa): GNU ld also changes the value in non-dynamic symbol + // table. + + Mips16_stub_section<size, big_endian>* fn_stub = + mips_sym->template get_mips16_fn_stub<big_endian>(); + value = fn_stub->output_address(); + osym.put_st_size(fn_stub->section_size()); + } + + osym.put_st_value(value); + osym.put_st_other(elfcpp::elf_st_other(sym->visibility(), + mips_sym->nonvis() - (elfcpp::STO_MIPS16 >> 2))); + } + else if ((mips_sym->is_micromips() + // Stubs are always microMIPS if there is any microMIPS code in + // the output. + || (this->is_output_micromips() && mips_sym->has_lazy_stub())) + && value != 0) + { + osym.put_st_value(value | 1); + osym.put_st_other(elfcpp::elf_st_other(sym->visibility(), + mips_sym->nonvis() - (elfcpp::STO_MICROMIPS >> 2))); + } + } + + private: + // The class which scans relocations. + class Scan + { + public: + Scan() + { } + + static inline int + get_reference_flags(unsigned int r_type); + + inline void + local(Symbol_table* symtab, Layout* layout, Target_mips* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rel<size, big_endian>& reloc, unsigned int r_type, + const elfcpp::Sym<size, big_endian>& lsym, + bool is_discarded); + + inline void + local(Symbol_table* symtab, Layout* layout, Target_mips* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>& reloc, unsigned int r_type, + const elfcpp::Sym<size, big_endian>& lsym, + bool is_discarded); + + inline void + local(Symbol_table* symtab, Layout* layout, Target_mips* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>* rela, + const elfcpp::Rel<size, big_endian>* rel, + unsigned int rel_type, + unsigned int r_type, + const elfcpp::Sym<size, big_endian>& lsym, + bool is_discarded); + + inline void + global(Symbol_table* symtab, Layout* layout, Target_mips* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rel<size, big_endian>& reloc, unsigned int r_type, + Symbol* gsym); + + inline void + global(Symbol_table* symtab, Layout* layout, Target_mips* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>& reloc, unsigned int r_type, + Symbol* gsym); + + inline void + global(Symbol_table* symtab, Layout* layout, Target_mips* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>* rela, + const elfcpp::Rel<size, big_endian>* rel, + unsigned int rel_type, + unsigned int r_type, + Symbol* gsym); + + inline bool + local_reloc_may_be_function_pointer(Symbol_table* , Layout*, + Target_mips*, + Sized_relobj_file<size, big_endian>*, + unsigned int, + Output_section*, + const elfcpp::Rel<size, big_endian>&, + unsigned int, + const elfcpp::Sym<size, big_endian>&) + { return false; } + + inline bool + global_reloc_may_be_function_pointer(Symbol_table*, Layout*, + Target_mips*, + Sized_relobj_file<size, big_endian>*, + unsigned int, + Output_section*, + const elfcpp::Rel<size, big_endian>&, + unsigned int, Symbol*) + { return false; } + + inline bool + local_reloc_may_be_function_pointer(Symbol_table*, Layout*, + Target_mips*, + Sized_relobj_file<size, big_endian>*, + unsigned int, + Output_section*, + const elfcpp::Rela<size, big_endian>&, + unsigned int, + const elfcpp::Sym<size, big_endian>&) + { return false; } + + inline bool + global_reloc_may_be_function_pointer(Symbol_table*, Layout*, + Target_mips*, + Sized_relobj_file<size, big_endian>*, + unsigned int, + Output_section*, + const elfcpp::Rela<size, big_endian>&, + unsigned int, Symbol*) + { return false; } + private: + static void + unsupported_reloc_local(Sized_relobj_file<size, big_endian>*, + unsigned int r_type); + + static void + unsupported_reloc_global(Sized_relobj_file<size, big_endian>*, + unsigned int r_type, Symbol*); + }; + + // The class which implements relocation. + class Relocate + { + public: + Relocate() + { } + + ~Relocate() + { } + + // Return whether the R_MIPS_32 relocation needs to be applied. + inline bool + should_apply_r_mips_32_reloc(const Mips_symbol<size>* gsym, + unsigned int r_type, + Output_section* output_section, + Target_mips* target); + + // Do a relocation. Return false if the caller should not issue + // any warnings about this relocation. + inline bool + relocate(const Relocate_info<size, big_endian>*, Target_mips*, + Output_section*, size_t relnum, + const elfcpp::Rela<size, big_endian>*, + const elfcpp::Rel<size, big_endian>*, + unsigned int, + unsigned int, const Sized_symbol<size>*, + const Symbol_value<size>*, + unsigned char*, + Mips_address, + section_size_type); + + inline bool + relocate(const Relocate_info<size, big_endian>*, Target_mips*, + Output_section*, size_t relnum, + const elfcpp::Rel<size, big_endian>&, + unsigned int, const Sized_symbol<size>*, + const Symbol_value<size>*, + unsigned char*, + Mips_address, + section_size_type); + + inline bool + relocate(const Relocate_info<size, big_endian>*, Target_mips*, + Output_section*, size_t relnum, + const elfcpp::Rela<size, big_endian>&, + unsigned int, const Sized_symbol<size>*, + const Symbol_value<size>*, + unsigned char*, + Mips_address, + section_size_type); + }; + + // A class which returns the size required for a relocation type, + // used while scanning relocs during a relocatable link. + class Relocatable_size_for_reloc + { + public: + unsigned int + get_size_for_reloc(unsigned int, Relobj*); + }; + + // This POD class holds the dynamic relocations that should be emitted instead + // of R_MIPS_32, R_MIPS_REL32 and R_MIPS_64 relocations. We will emit these + // relocations if it turns out that the symbol does not have static + // relocations. + class Dyn_reloc + { + public: + Dyn_reloc(Mips_symbol<size>* sym, unsigned int r_type, + Mips_relobj<size, big_endian>* relobj, unsigned int shndx, + Output_section* output_section, Mips_address r_offset) + : sym_(sym), r_type_(r_type), relobj_(relobj), + shndx_(shndx), output_section_(output_section), + r_offset_(r_offset) + { } + + // Emit this reloc if appropriate. This is called after we have + // scanned all the relocations, so we know whether the symbol has + // static relocations. + void + emit(Reloc_section* rel_dyn, Mips_output_data_got<size, big_endian>* got, + Symbol_table* symtab) + { + if (!this->sym_->has_static_relocs()) + { + got->record_global_got_symbol(this->sym_, this->relobj_, + this->r_type_, true, false); + if (!symbol_references_local(this->sym_, + this->sym_->should_add_dynsym_entry(symtab))) + rel_dyn->add_global(this->sym_, this->r_type_, + this->output_section_, this->relobj_, + this->shndx_, this->r_offset_); + else + rel_dyn->add_symbolless_global_addend(this->sym_, this->r_type_, + this->output_section_, this->relobj_, + this->shndx_, this->r_offset_); + } + } + + private: + Mips_symbol<size>* sym_; + unsigned int r_type_; + Mips_relobj<size, big_endian>* relobj_; + unsigned int shndx_; + Output_section* output_section_; + Mips_address r_offset_; + }; + + // Adjust TLS relocation type based on the options and whether this + // is a local symbol. + static tls::Tls_optimization + optimize_tls_reloc(bool is_final, int r_type); + + // Return whether there is a GOT section. + bool + has_got_section() const + { return this->got_ != NULL; } + + // Check whether the given ELF header flags describe a 32-bit binary. + bool + mips_32bit_flags(elfcpp::Elf_Word); + + enum Mips_mach { + mach_mips3000 = 3000, + mach_mips3900 = 3900, + mach_mips4000 = 4000, + mach_mips4010 = 4010, + mach_mips4100 = 4100, + mach_mips4111 = 4111, + mach_mips4120 = 4120, + mach_mips4300 = 4300, + mach_mips4400 = 4400, + mach_mips4600 = 4600, + mach_mips4650 = 4650, + mach_mips5000 = 5000, + mach_mips5400 = 5400, + mach_mips5500 = 5500, + mach_mips6000 = 6000, + mach_mips7000 = 7000, + mach_mips8000 = 8000, + mach_mips9000 = 9000, + mach_mips10000 = 10000, + mach_mips12000 = 12000, + mach_mips14000 = 14000, + mach_mips16000 = 16000, + mach_mips16 = 16, + mach_mips5 = 5, + mach_mips_loongson_2e = 3001, + mach_mips_loongson_2f = 3002, + mach_mips_loongson_3a = 3003, + mach_mips_sb1 = 12310201, // octal 'SB', 01 + mach_mips_octeon = 6501, + mach_mips_octeonp = 6601, + mach_mips_octeon2 = 6502, + mach_mips_xlr = 887682, // decimal 'XLR' + mach_mipsisa32 = 32, + mach_mipsisa32r2 = 33, + mach_mipsisa64 = 64, + mach_mipsisa64r2 = 65, + mach_mips_micromips = 96 + }; + + // Return the MACH for a MIPS e_flags value. + unsigned int + elf_mips_mach(elfcpp::Elf_Word); + + // Check whether machine EXTENSION is an extension of machine BASE. + bool + mips_mach_extends(unsigned int, unsigned int); + + // Merge processor specific flags. + void + merge_processor_specific_flags(const std::string&, elfcpp::Elf_Word, + unsigned char, bool); + + // True if we are linking for CPUs that are faster if JAL is converted to BAL. + static inline bool + jal_to_bal() + { return false; } + + // True if we are linking for CPUs that are faster if JALR is converted to + // BAL. This should be safe for all architectures. We enable this predicate + // for all CPUs. + static inline bool + jalr_to_bal() + { return true; } + + // True if we are linking for CPUs that are faster if JR is converted to B. + // This should be safe for all architectures. We enable this predicate for + // all CPUs. + static inline bool + jr_to_b() + { return true; } + + // Return the size of the GOT section. + section_size_type + got_size() const + { + gold_assert(this->got_ != NULL); + return this->got_->data_size(); + } + + // Create a PLT entry for a global symbol referenced by r_type relocation. + void + make_plt_entry(Symbol_table*, Layout*, Mips_symbol<size>*, + unsigned int r_type); + + // Get the PLT section. + Mips_output_data_plt<size, big_endian>* + plt_section() const + { + gold_assert(this->plt_ != NULL); + return this->plt_; + } + + // Get the GOT PLT section. + const Mips_output_data_plt<size, big_endian>* + got_plt_section() const + { + gold_assert(this->got_plt_ != NULL); + return this->got_plt_; + } + + // Copy a relocation against a global symbol. + void + copy_reloc(Symbol_table* symtab, Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int shndx, Output_section* output_section, + Symbol* sym, const elfcpp::Rel<size, big_endian>& reloc) + { + this->copy_relocs_.copy_reloc(symtab, layout, + symtab->get_sized_symbol<size>(sym), + object, shndx, output_section, + reloc, this->rel_dyn_section(layout)); + } + + void + dynamic_reloc(Mips_symbol<size>* sym, unsigned int r_type, + Mips_relobj<size, big_endian>* relobj, + unsigned int shndx, Output_section* output_section, + Mips_address r_offset) + { + this->dyn_relocs_.push_back(Dyn_reloc(sym, r_type, relobj, shndx, + output_section, r_offset)); + } + + // Calculate value of _gp symbol. + void + set_gp(Layout*, Symbol_table*); + + const char* + elf_mips_abi_name(elfcpp::Elf_Word e_flags, unsigned char ei_class); + const char* + elf_mips_mach_name(elfcpp::Elf_Word e_flags); + + // Adds entries that describe how machines relate to one another. The entries + // are ordered topologically with MIPS I extensions listed last. First + // element is extension, second element is base. + void + add_machine_extensions() + { + // MIPS64r2 extensions. + this->add_extension(mach_mips_octeon2, mach_mips_octeonp); + this->add_extension(mach_mips_octeonp, mach_mips_octeon); + this->add_extension(mach_mips_octeon, mach_mipsisa64r2); + + // MIPS64 extensions. + this->add_extension(mach_mipsisa64r2, mach_mipsisa64); + this->add_extension(mach_mips_sb1, mach_mipsisa64); + this->add_extension(mach_mips_xlr, mach_mipsisa64); + this->add_extension(mach_mips_loongson_3a, mach_mipsisa64); + + // MIPS V extensions. + this->add_extension(mach_mipsisa64, mach_mips5); + + // R10000 extensions. + this->add_extension(mach_mips12000, mach_mips10000); + this->add_extension(mach_mips14000, mach_mips10000); + this->add_extension(mach_mips16000, mach_mips10000); + + // R5000 extensions. Note: the vr5500 ISA is an extension of the core + // vr5400 ISA, but doesn't include the multimedia stuff. It seems + // better to allow vr5400 and vr5500 code to be merged anyway, since + // many libraries will just use the core ISA. Perhaps we could add + // some sort of ASE flag if this ever proves a problem. + this->add_extension(mach_mips5500, mach_mips5400); + this->add_extension(mach_mips5400, mach_mips5000); + + // MIPS IV extensions. + this->add_extension(mach_mips5, mach_mips8000); + this->add_extension(mach_mips10000, mach_mips8000); + this->add_extension(mach_mips5000, mach_mips8000); + this->add_extension(mach_mips7000, mach_mips8000); + this->add_extension(mach_mips9000, mach_mips8000); + + // VR4100 extensions. + this->add_extension(mach_mips4120, mach_mips4100); + this->add_extension(mach_mips4111, mach_mips4100); + + // MIPS III extensions. + this->add_extension(mach_mips_loongson_2e, mach_mips4000); + this->add_extension(mach_mips_loongson_2f, mach_mips4000); + this->add_extension(mach_mips8000, mach_mips4000); + this->add_extension(mach_mips4650, mach_mips4000); + this->add_extension(mach_mips4600, mach_mips4000); + this->add_extension(mach_mips4400, mach_mips4000); + this->add_extension(mach_mips4300, mach_mips4000); + this->add_extension(mach_mips4100, mach_mips4000); + this->add_extension(mach_mips4010, mach_mips4000); + + // MIPS32 extensions. + this->add_extension(mach_mipsisa32r2, mach_mipsisa32); + + // MIPS II extensions. + this->add_extension(mach_mips4000, mach_mips6000); + this->add_extension(mach_mipsisa32, mach_mips6000); + + // MIPS I extensions. + this->add_extension(mach_mips6000, mach_mips3000); + this->add_extension(mach_mips3900, mach_mips3000); + } + + // Add value to MIPS extenstions. + void + add_extension(unsigned int base, unsigned int extension) + { + std::pair<unsigned int, unsigned int> ext(base, extension); + this->mips_mach_extensions_.push_back(ext); + } + + // Return the number of entries in the .dynsym section. + unsigned int get_dt_mips_symtabno() const + { + return ((unsigned int)(this->layout_->dynsym_section()->data_size() + / elfcpp::Elf_sizes<size>::sym_size)); + // TODO(sasa): Entry size is MIPS_ELF_SYM_SIZE. + } + + // Information about this specific target which we pass to the + // general Target structure. + static const Target::Target_info mips_info; + // The GOT section. + Mips_output_data_got<size, big_endian>* got_; + // gp symbol. It has the value of .got + 0x7FF0. + Sized_symbol<size>* gp_; + // The PLT section. + Mips_output_data_plt<size, big_endian>* plt_; + // The GOT PLT section. + Output_data_space* got_plt_; + // The dynamic reloc section. + Reloc_section* rel_dyn_; + // Relocs saved to avoid a COPY reloc. + Mips_copy_relocs<elfcpp::SHT_REL, size, big_endian> copy_relocs_; + + // A list of dyn relocs to be saved. + std::vector<Dyn_reloc> dyn_relocs_; + + // The LA25 stub section. + Mips_output_data_la25_stub<size, big_endian>* la25_stub_; + // Architecture extensions. + std::vector<std::pair<unsigned int, unsigned int> > mips_mach_extensions_; + // .MIPS.stubs + Mips_output_data_mips_stubs<size, big_endian>* mips_stubs_; + + unsigned char ei_class_; + unsigned int mach_; + Layout* layout_; + + typename std::list<got16_addend<size, big_endian> > got16_addends_; + + // Whether the entry symbol is mips16 or micromips. + bool entry_symbol_is_compressed_; + + // Whether we can use only 32-bit microMIPS instructions. + // TODO(sasa): This should be a linker option. + bool insn32_; +}; + + +// Helper structure for R_MIPS*_HI16/LO16 and R_MIPS*_GOT16/LO16 relocations. +// It records high part of the relocation pair. + +template<int size, bool big_endian> +struct reloc_high +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + + reloc_high(unsigned char* _view, const Mips_relobj<size, big_endian>* _object, + const Symbol_value<size>* _psymval, Mips_address _addend, + unsigned int _r_type, bool _extract_addend, + Mips_address _address = 0, bool _gp_disp = false) + : view(_view), object(_object), psymval(_psymval), addend(_addend), + r_type(_r_type), extract_addend(_extract_addend), address(_address), + gp_disp(_gp_disp) + { } + + unsigned char* view; + const Mips_relobj<size, big_endian>* object; + const Symbol_value<size>* psymval; + Mips_address addend; + unsigned int r_type; + bool extract_addend; + Mips_address address; + bool gp_disp; +}; + +template<int size, bool big_endian> +class Mips_relocate_functions : public Relocate_functions<size, big_endian> +{ + typedef typename elfcpp::Elf_types<size>::Elf_Addr Mips_address; + typedef typename elfcpp::Swap<16, big_endian>::Valtype Valtype16; + typedef typename elfcpp::Swap<32, big_endian>::Valtype Valtype32; + + public: + typedef enum + { + STATUS_OKAY, // No error during relocation. + STATUS_OVERFLOW, // Relocation overflow. + STATUS_BAD_RELOC // Relocation cannot be applied. + } Status; + + private: + typedef Relocate_functions<size, big_endian> Base; + typedef Mips_relocate_functions<size, big_endian> This; + + static typename std::list<reloc_high<size, big_endian> > hi16_relocs; + static typename std::list<reloc_high<size, big_endian> > got16_relocs; + + // R_MIPS16_26 is used for the mips16 jal and jalx instructions. + // Most mips16 instructions are 16 bits, but these instructions + // are 32 bits. + // + // The format of these instructions is: + // + // +--------------+--------------------------------+ + // | JALX | X| Imm 20:16 | Imm 25:21 | + // +--------------+--------------------------------+ + // | Immediate 15:0 | + // +-----------------------------------------------+ + // + // JALX is the 5-bit value 00011. X is 0 for jal, 1 for jalx. + // Note that the immediate value in the first word is swapped. + // + // When producing a relocatable object file, R_MIPS16_26 is + // handled mostly like R_MIPS_26. In particular, the addend is + // stored as a straight 26-bit value in a 32-bit instruction. + // (gas makes life simpler for itself by never adjusting a + // R_MIPS16_26 reloc to be against a section, so the addend is + // always zero). However, the 32 bit instruction is stored as 2 + // 16-bit values, rather than a single 32-bit value. In a + // big-endian file, the result is the same; in a little-endian + // file, the two 16-bit halves of the 32 bit value are swapped. + // This is so that a disassembler can recognize the jal + // instruction. + // + // When doing a final link, R_MIPS16_26 is treated as a 32 bit + // instruction stored as two 16-bit values. The addend A is the + // contents of the targ26 field. The calculation is the same as + // R_MIPS_26. When storing the calculated value, reorder the + // immediate value as shown above, and don't forget to store the + // value as two 16-bit values. + // + // To put it in MIPS ABI terms, the relocation field is T-targ26-16, + // defined as + // + // big-endian: + // +--------+----------------------+ + // | | | + // | | targ26-16 | + // |31 26|25 0| + // +--------+----------------------+ + // + // little-endian: + // +----------+------+-------------+ + // | | | | + // | sub1 | | sub2 | + // |0 9|10 15|16 31| + // +----------+--------------------+ + // where targ26-16 is sub1 followed by sub2 (i.e., the addend field A is + // ((sub1 << 16) | sub2)). + // + // When producing a relocatable object file, the calculation is + // (((A < 2) | ((P + 4) & 0xf0000000) + S) >> 2) + // When producing a fully linked file, the calculation is + // let R = (((A < 2) | ((P + 4) & 0xf0000000) + S) >> 2) + // ((R & 0x1f0000) << 5) | ((R & 0x3e00000) >> 5) | (R & 0xffff) + // + // The table below lists the other MIPS16 instruction relocations. + // Each one is calculated in the same way as the non-MIPS16 relocation + // given on the right, but using the extended MIPS16 layout of 16-bit + // immediate fields: + // + // R_MIPS16_GPREL R_MIPS_GPREL16 + // R_MIPS16_GOT16 R_MIPS_GOT16 + // R_MIPS16_CALL16 R_MIPS_CALL16 + // R_MIPS16_HI16 R_MIPS_HI16 + // R_MIPS16_LO16 R_MIPS_LO16 + // + // A typical instruction will have a format like this: + // + // +--------------+--------------------------------+ + // | EXTEND | Imm 10:5 | Imm 15:11 | + // +--------------+--------------------------------+ + // | Major | rx | ry | Imm 4:0 | + // +--------------+--------------------------------+ + // + // EXTEND is the five bit value 11110. Major is the instruction + // opcode. + // + // All we need to do here is shuffle the bits appropriately. + // As above, the two 16-bit halves must be swapped on a + // little-endian system. + + // Similar to MIPS16, the two 16-bit halves in microMIPS must be swapped + // on a little-endian system. This does not apply to R_MICROMIPS_PC7_S1 + // and R_MICROMIPS_PC10_S1 relocs that apply to 16-bit instructions. + + static inline bool + should_shuffle_micromips_reloc(unsigned int r_type) + { + return (micromips_reloc(r_type) + && r_type != elfcpp::R_MICROMIPS_PC7_S1 + && r_type != elfcpp::R_MICROMIPS_PC10_S1); + } + + static void + mips_reloc_unshuffle(unsigned char* view, unsigned int r_type, + bool jal_shuffle) + { + if (!mips16_reloc(r_type) + && !should_shuffle_micromips_reloc(r_type)) + return; + + // Pick up the first and second halfwords of the instruction. + Valtype16 first = elfcpp::Swap<16, big_endian>::readval(view); + Valtype16 second = elfcpp::Swap<16, big_endian>::readval(view + 2); + Valtype32 val; + + if (micromips_reloc(r_type) + || (r_type == elfcpp::R_MIPS16_26 && !jal_shuffle)) + val = first << 16 | second; + else if (r_type != elfcpp::R_MIPS16_26) + val = (((first & 0xf800) << 16) | ((second & 0xffe0) << 11) + | ((first & 0x1f) << 11) | (first & 0x7e0) | (second & 0x1f)); + else + val = (((first & 0xfc00) << 16) | ((first & 0x3e0) << 11) + | ((first & 0x1f) << 21) | second); + + elfcpp::Swap<32, big_endian>::writeval(view, val); + } + + static void + mips_reloc_shuffle(unsigned char* view, unsigned int r_type, bool jal_shuffle) + { + if (!mips16_reloc(r_type) + && !should_shuffle_micromips_reloc(r_type)) + return; + + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(view); + Valtype16 first, second; + + if (micromips_reloc(r_type) + || (r_type == elfcpp::R_MIPS16_26 && !jal_shuffle)) + { + second = val & 0xffff; + first = val >> 16; + } + else if (r_type != elfcpp::R_MIPS16_26) + { + second = ((val >> 11) & 0xffe0) | (val & 0x1f); + first = ((val >> 16) & 0xf800) | ((val >> 11) & 0x1f) | (val & 0x7e0); + } + else + { + second = val & 0xffff; + first = ((val >> 16) & 0xfc00) | ((val >> 11) & 0x3e0) + | ((val >> 21) & 0x1f); + } + + elfcpp::Swap<16, big_endian>::writeval(view + 2, second); + elfcpp::Swap<16, big_endian>::writeval(view, first); + } + + public: + // R_MIPS_16: S + sign-extend(A) + static inline typename This::Status + rel16(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_a, + bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype16* wv = reinterpret_cast<Valtype16*>(view); + Valtype16 val = elfcpp::Swap<16, big_endian>::readval(wv); + + Valtype32 addend = (extract_addend ? Bits<16>::sign_extend32(val) + : Bits<16>::sign_extend32(addend_a)); + + Valtype32 x = psymval->value(object, addend); + val = Bits<16>::bit_select32(val, x, 0xffffU); + elfcpp::Swap<16, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<16>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MIPS_32: S + A + static inline typename This::Status + rel32(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_a, + bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 addend = (extract_addend + ? elfcpp::Swap<32, big_endian>::readval(wv) + : Bits<32>::sign_extend32(addend_a)); + Valtype32 x = psymval->value(object, addend); + elfcpp::Swap<32, big_endian>::writeval(wv, x); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_JALR, R_MICROMIPS_JALR + static inline typename This::Status + reljalr(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address address, + Mips_address addend_a, bool extract_addend, bool cross_mode_jump, + unsigned int r_type, bool jalr_to_bal, bool jr_to_b) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 addend = extract_addend ? 0 : addend_a; + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + // Try converting J(AL)R to B(AL), if the target is in range. + if (!parameters->options().relocatable() + && r_type == elfcpp::R_MIPS_JALR + && !cross_mode_jump + && ((jalr_to_bal && val == 0x0320f809) // jalr t9 + || (jr_to_b && val == 0x03200008))) // jr t9 + { + int offset = psymval->value(object, addend) - (address + 4); + if (!Bits<18>::has_overflow32(offset)) + { + if (val == 0x03200008) // jr t9 + val = 0x10000000 | (((Valtype32)offset >> 2) & 0xffff); // b addr + else + val = 0x04110000 | (((Valtype32)offset >> 2) & 0xffff); //bal addr + } + } + + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_PC32: S + A - P + static inline typename This::Status + relpc32(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address address, + Mips_address addend_a, bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 addend = (extract_addend + ? elfcpp::Swap<32, big_endian>::readval(wv) + : Bits<32>::sign_extend32(addend_a)); + Valtype32 x = psymval->value(object, addend) - address; + elfcpp::Swap<32, big_endian>::writeval(wv, x); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_26, R_MIPS16_26, R_MICROMIPS_26_S1 + static inline typename This::Status + rel26(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address address, + bool local, Mips_address addend_a, bool extract_addend, + const Symbol* gsym, bool cross_mode_jump, unsigned int r_type, + bool jal_to_bal) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend; + if (extract_addend) + { + if (r_type == elfcpp::R_MICROMIPS_26_S1) + addend = (val & 0x03ffffff) << 1; + else + addend = (val & 0x03ffffff) << 2; + } + else + addend = addend_a; + + // Make sure the target of JALX is word-aligned. Bit 0 must be + // the correct ISA mode selector and bit 1 must be 0. + if (cross_mode_jump + && (psymval->value(object, 0) & 3) != (r_type == elfcpp::R_MIPS_26)) + { + gold_warning(_("JALX to a non-word-aligned address")); + mips_reloc_shuffle(view, r_type, !parameters->options().relocatable()); + return This::STATUS_BAD_RELOC; + } + + // Shift is 2, unusually, for microMIPS JALX. + unsigned int shift = + (!cross_mode_jump && r_type == elfcpp::R_MICROMIPS_26_S1) ? 1 : 2; + + Valtype32 x; + if (local) + x = addend | ((address + 4) & (0xfc000000 << shift)); + else + { + if (shift == 1) + x = Bits<27>::sign_extend32(addend); + else + x = Bits<28>::sign_extend32(addend); + } + x = psymval->value(object, x) >> shift; + + if (!local && !gsym->is_weak_undefined()) + { + if ((x >> 26) != ((address + 4) >> (26 + shift))) + { + gold_error(_("relocation truncated to fit: %u against '%s'"), + r_type, gsym->name()); + return This::STATUS_OVERFLOW; + } + } + + val = Bits<32>::bit_select32(val, x, 0x03ffffff); + + // If required, turn JAL into JALX. + if (cross_mode_jump) + { + bool ok; + Valtype32 opcode = val >> 26; + Valtype32 jalx_opcode; + + // Check to see if the opcode is already JAL or JALX. + if (r_type == elfcpp::R_MIPS16_26) + { + ok = (opcode == 0x6) || (opcode == 0x7); + jalx_opcode = 0x7; + } + else if (r_type == elfcpp::R_MICROMIPS_26_S1) + { + ok = (opcode == 0x3d) || (opcode == 0x3c); + jalx_opcode = 0x3c; + } + else + { + ok = (opcode == 0x3) || (opcode == 0x1d); + jalx_opcode = 0x1d; + } + + // If the opcode is not JAL or JALX, there's a problem. We cannot + // convert J or JALS to JALX. + if (!ok) + { + gold_error(_("Unsupported jump between ISA modes; consider " + "recompiling with interlinking enabled.")); + return This::STATUS_BAD_RELOC; + } + + // Make this the JALX opcode. + val = (val & ~(0x3f << 26)) | (jalx_opcode << 26); + } + + // Try converting JAL to BAL, if the target is in range. + if (!parameters->options().relocatable() + && !cross_mode_jump + && ((jal_to_bal + && r_type == elfcpp::R_MIPS_26 + && (val >> 26) == 0x3))) // jal addr + { + Valtype32 dest = (x << 2) | (((address + 4) >> 28) << 28); + int offset = dest - (address + 4); + if (!Bits<18>::has_overflow32(offset)) + { + if (val == 0x03200008) // jr t9 + val = 0x10000000 | (((Valtype32)offset >> 2) & 0xffff); // b addr + else + val = 0x04110000 | (((Valtype32)offset >> 2) & 0xffff); //bal addr + } + } + + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, !parameters->options().relocatable()); + return This::STATUS_OKAY; + } + + // R_MIPS_PC16 + static inline typename This::Status + relpc16(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address address, + Mips_address addend_a, bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend = extract_addend ? (val & 0xffff) << 2 : addend_a; + addend = Bits<18>::sign_extend32(addend); + + Valtype32 x = psymval->value(object, addend) - address; + val = Bits<16>::bit_select32(val, x >> 2, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<18>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MICROMIPS_PC7_S1 + static inline typename This::Status + relmicromips_pc7_s1(unsigned char* view, + const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address address, + Mips_address addend_a, bool extract_addend, + unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend = extract_addend ? (val & 0x7f) << 1 : addend_a; + addend = Bits<8>::sign_extend32(addend); + + Valtype32 x = psymval->value(object, addend) - address; + val = Bits<16>::bit_select32(val, x >> 1, 0x7f); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<8>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MICROMIPS_PC10_S1 + static inline typename This::Status + relmicromips_pc10_s1(unsigned char* view, + const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address address, + Mips_address addend_a, bool extract_addend, + unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend = extract_addend ? (val & 0x3ff) << 1 : addend_a; + addend = Bits<11>::sign_extend32(addend); + + Valtype32 x = psymval->value(object, addend) - address; + val = Bits<16>::bit_select32(val, x >> 1, 0x3ff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<11>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MICROMIPS_PC16_S1 + static inline typename This::Status + relmicromips_pc16_s1(unsigned char* view, + const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address address, + Mips_address addend_a, bool extract_addend, + unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend = extract_addend ? (val & 0xffff) << 1 : addend_a; + addend = Bits<17>::sign_extend32(addend); + + Valtype32 x = psymval->value(object, addend) - address; + val = Bits<16>::bit_select32(val, x >> 1, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<17>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MIPS_HI16, R_MIPS16_HI16, R_MICROMIPS_HI16, + static inline typename This::Status + relhi16(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend, + Mips_address address, bool gp_disp, unsigned int r_type, + bool extract_addend) + { + // Record the relocation. It will be resolved when we find lo16 part. + hi16_relocs.push_back(reloc_high<size, big_endian>(view, object, psymval, + addend, r_type, extract_addend, address, gp_disp)); + return This::STATUS_OKAY; + } + + // R_MIPS_HI16, R_MIPS16_HI16, R_MICROMIPS_HI16, + static inline typename This::Status + do_relhi16(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_hi, + Mips_address address, bool is_gp_disp, unsigned int r_type, + bool extract_addend, Valtype32 addend_lo, + Target_mips<size, big_endian>* target) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend = (extract_addend ? ((val & 0xffff) << 16) + addend_lo + : addend_hi); + + Valtype32 value; + if (!is_gp_disp) + value = psymval->value(object, addend); + else + { + // For MIPS16 ABI code we generate this sequence + // 0: li $v0,%hi(_gp_disp) + // 4: addiupc $v1,%lo(_gp_disp) + // 8: sll $v0,16 + // 12: addu $v0,$v1 + // 14: move $gp,$v0 + // So the offsets of hi and lo relocs are the same, but the + // base $pc is that used by the ADDIUPC instruction at $t9 + 4. + // ADDIUPC clears the low two bits of the instruction address, + // so the base is ($t9 + 4) & ~3. + Valtype32 gp_disp; + if (r_type == elfcpp::R_MIPS16_HI16) + gp_disp = (target->adjusted_gp_value(object) + - ((address + 4) & ~0x3)); + // The microMIPS .cpload sequence uses the same assembly + // instructions as the traditional psABI version, but the + // incoming $t9 has the low bit set. + else if (r_type == elfcpp::R_MICROMIPS_HI16) + gp_disp = target->adjusted_gp_value(object) - address - 1; + else + gp_disp = target->adjusted_gp_value(object) - address; + value = gp_disp + addend; + } + Valtype32 x = ((value + 0x8000) >> 16) & 0xffff; + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (is_gp_disp && Bits<16>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MIPS_GOT16, R_MIPS16_GOT16, R_MICROMIPS_GOT16 + static inline typename This::Status + relgot16_local(unsigned char* view, + const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_a, + bool extract_addend, unsigned int r_type) + { + // Record the relocation. It will be resolved when we find lo16 part. + got16_relocs.push_back(reloc_high<size, big_endian>(view, object, psymval, + addend_a, r_type, extract_addend)); + return This::STATUS_OKAY; + } + + // R_MIPS_GOT16, R_MIPS16_GOT16, R_MICROMIPS_GOT16 + static inline typename This::Status + do_relgot16_local(unsigned char* view, + const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_hi, + unsigned int r_type, bool extract_addend, + Valtype32 addend_lo, Target_mips<size, big_endian>* target) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend = (extract_addend ? ((val & 0xffff) << 16) + addend_lo + : addend_hi); + + // Find GOT page entry. + Mips_address value = ((psymval->value(object, addend) + 0x8000) >> 16) + & 0xffff; + value <<= 16; + unsigned int got_offset = + target->got_section()->get_got_page_offset(value, object); + + // Resolve the relocation. + Valtype32 x = target->got_section()->gp_offset(got_offset, object); + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<16>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MIPS_LO16, R_MIPS16_LO16, R_MICROMIPS_LO16, R_MICROMIPS_HI0_LO16 + static inline typename This::Status + rello16(Target_mips<size, big_endian>* target, unsigned char* view, + const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_a, + bool extract_addend, Mips_address address, bool is_gp_disp, + unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend = (extract_addend ? Bits<16>::sign_extend32(val & 0xffff) + : addend_a); + + // Resolve pending R_MIPS_HI16 relocations. + typename std::list<reloc_high<size, big_endian> >::iterator it = + hi16_relocs.begin(); + while (it != hi16_relocs.end()) + { + reloc_high<size, big_endian> hi16 = *it; + if (hi16.psymval->value(hi16.object, 0) == psymval->value(object, 0)) + { + if (do_relhi16(hi16.view, hi16.object, hi16.psymval, hi16.addend, + hi16.address, hi16.gp_disp, hi16.r_type, + hi16.extract_addend, addend, target) + == This::STATUS_OVERFLOW) + return This::STATUS_OVERFLOW; + it = hi16_relocs.erase(it); + } + else + ++it; + } + + // Resolve pending local R_MIPS_GOT16 relocations. + typename std::list<reloc_high<size, big_endian> >::iterator it2 = + got16_relocs.begin(); + while (it2 != got16_relocs.end()) + { + reloc_high<size, big_endian> got16 = *it2; + if (got16.psymval->value(got16.object, 0) == psymval->value(object, 0)) + { + if (do_relgot16_local(got16.view, got16.object, got16.psymval, + got16.addend, got16.r_type, + got16.extract_addend, addend, + target) == This::STATUS_OVERFLOW) + return This::STATUS_OVERFLOW; + it2 = got16_relocs.erase(it2); + } + else + ++it2; + } + + // Resolve R_MIPS_LO16 relocation. + Valtype32 x; + if (!is_gp_disp) + x = psymval->value(object, addend); + else + { + // See the comment for R_MIPS16_HI16 above for the reason + // for this conditional. + Valtype32 gp_disp; + if (r_type == elfcpp::R_MIPS16_LO16) + gp_disp = target->adjusted_gp_value(object) - (address & ~0x3); + else if (r_type == elfcpp::R_MICROMIPS_LO16 + || r_type == elfcpp::R_MICROMIPS_HI0_LO16) + gp_disp = target->adjusted_gp_value(object) - address + 3; + else + gp_disp = target->adjusted_gp_value(object) - address + 4; + // The MIPS ABI requires checking the R_MIPS_LO16 relocation + // for overflow. Relocations against _gp_disp are normally + // generated from the .cpload pseudo-op. It generates code + // that normally looks like this: + + // lui $gp,%hi(_gp_disp) + // addiu $gp,$gp,%lo(_gp_disp) + // addu $gp,$gp,$t9 + + // Here $t9 holds the address of the function being called, + // as required by the MIPS ELF ABI. The R_MIPS_LO16 + // relocation can easily overflow in this situation, but the + // R_MIPS_HI16 relocation will handle the overflow. + // Therefore, we consider this a bug in the MIPS ABI, and do + // not check for overflow here. + x = gp_disp + addend; + } + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_CALL16, R_MIPS16_CALL16, R_MICROMIPS_CALL16 + // R_MIPS_GOT16, R_MIPS16_GOT16, R_MICROMIPS_GOT16 + // R_MIPS_TLS_GD, R_MIPS16_TLS_GD, R_MICROMIPS_TLS_GD + // R_MIPS_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL, R_MICROMIPS_TLS_GOTTPREL + // R_MIPS_TLS_LDM, R_MIPS16_TLS_LDM, R_MICROMIPS_TLS_LDM + // R_MIPS_GOT_DISP, R_MICROMIPS_GOT_DISP + static inline typename This::Status + relgot(unsigned char* view, int gp_offset, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + Valtype32 x = gp_offset; + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<16>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE + static inline typename This::Status + relgotpage(Target_mips<size, big_endian>* target, unsigned char* view, + const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_a, + bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(view); + Valtype32 addend = extract_addend ? val & 0xffff : addend_a; + + // Find a GOT page entry that points to within 32KB of symbol + addend. + Mips_address value = (psymval->value(object, addend) + 0x8000) & ~0xffff; + unsigned int got_offset = + target->got_section()->get_got_page_offset(value, object); + + Valtype32 x = target->got_section()->gp_offset(got_offset, object); + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<16>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MIPS_GOT_OFST, R_MICROMIPS_GOT_OFST + static inline typename This::Status + relgotofst(Target_mips<size, big_endian>* target, unsigned char* view, + const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_a, + bool extract_addend, bool local, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(view); + Valtype32 addend = extract_addend ? val & 0xffff : addend_a; + + // For a local symbol, find a GOT page entry that points to within 32KB of + // symbol + addend. Relocation value is the offset of the GOT page entry's + // value from symbol + addend. + // For a global symbol, relocation value is addend. + Valtype32 x; + if (local) + { + // Find GOT page entry. + Mips_address value = ((psymval->value(object, addend) + 0x8000) + & ~0xffff); + target->got_section()->get_got_page_offset(value, object); + + x = psymval->value(object, addend) - value; + } + else + x = addend; + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return (Bits<16>::has_overflow32(x) + ? This::STATUS_OVERFLOW + : This::STATUS_OKAY); + } + + // R_MIPS_GOT_HI16, R_MIPS_CALL_HI16, + // R_MICROMIPS_GOT_HI16, R_MICROMIPS_CALL_HI16 + static inline typename This::Status + relgot_hi16(unsigned char* view, int gp_offset, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + Valtype32 x = gp_offset; + x = ((x + 0x8000) >> 16) & 0xffff; + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_GOT_LO16, R_MIPS_CALL_LO16, + // R_MICROMIPS_GOT_LO16, R_MICROMIPS_CALL_LO16 + static inline typename This::Status + relgot_lo16(unsigned char* view, int gp_offset, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + Valtype32 x = gp_offset; + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_GPREL16, R_MIPS16_GPREL, R_MIPS_LITERAL, R_MICROMIPS_LITERAL + // R_MICROMIPS_GPREL7_S2, R_MICROMIPS_GPREL16 + static inline typename This::Status + relgprel(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address gp, + Mips_address addend_a, bool extract_addend, bool local, + unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + + Valtype32 addend; + if (extract_addend) + { + if (r_type == elfcpp::R_MICROMIPS_GPREL7_S2) + addend = (val & 0x7f) << 2; + else + addend = val & 0xffff; + // Only sign-extend the addend if it was extracted from the + // instruction. If the addend was separate, leave it alone, + // otherwise we may lose significant bits. + addend = Bits<16>::sign_extend32(addend); + } + else + addend = addend_a; + + Valtype32 x = psymval->value(object, addend) - gp; + + // If the symbol was local, any earlier relocatable links will + // have adjusted its addend with the gp offset, so compensate + // for that now. Don't do it for symbols forced local in this + // link, though, since they won't have had the gp offset applied + // to them before. + if (local) + x += object->gp_value(); + + if (r_type == elfcpp::R_MICROMIPS_GPREL7_S2) + val = Bits<32>::bit_select32(val, x, 0x7f); + else + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + if (Bits<16>::has_overflow32(x)) + { + gold_error(_("small-data section exceeds 64KB; lower small-data size " + "limit (see option -G)")); + return This::STATUS_OVERFLOW; + } + return This::STATUS_OKAY; + } + + // R_MIPS_GPREL32 + static inline typename This::Status + relgprel32(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address gp, + Mips_address addend_a, bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + Valtype32 addend = extract_addend ? val : addend_a; + + // R_MIPS_GPREL32 relocations are defined for local symbols only. + Valtype32 x = psymval->value(object, addend) + object->gp_value() - gp; + elfcpp::Swap<32, big_endian>::writeval(wv, x); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16, R_MICROMIPS_TLS_TPREL_HI16 + // R_MIPS_TLS_DTPREL_HI16, R_MIPS16_TLS_DTPREL_HI16, + // R_MICROMIPS_TLS_DTPREL_HI16 + static inline typename This::Status + tlsrelhi16(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Valtype32 tp_offset, + Mips_address addend_a, bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + Valtype32 addend = extract_addend ? val & 0xffff : addend_a; + + // tls symbol values are relative to tls_segment()->vaddr() + Valtype32 x = ((psymval->value(object, addend) - tp_offset) + 0x8000) >> 16; + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16, R_MICROMIPS_TLS_TPREL_LO16, + // R_MIPS_TLS_DTPREL_LO16, R_MIPS16_TLS_DTPREL_LO16, + // R_MICROMIPS_TLS_DTPREL_LO16, + static inline typename This::Status + tlsrello16(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Valtype32 tp_offset, + Mips_address addend_a, bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + Valtype32 addend = extract_addend ? val & 0xffff : addend_a; + + // tls symbol values are relative to tls_segment()->vaddr() + Valtype32 x = psymval->value(object, addend) - tp_offset; + val = Bits<32>::bit_select32(val, x, 0xffff); + elfcpp::Swap<32, big_endian>::writeval(wv, val); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL64, + // R_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL64 + static inline typename This::Status + tlsrel32(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Valtype32 tp_offset, + Mips_address addend_a, bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + Valtype32 addend = extract_addend ? val : addend_a; + + // tls symbol values are relative to tls_segment()->vaddr() + Valtype32 x = psymval->value(object, addend) - tp_offset; + elfcpp::Swap<32, big_endian>::writeval(wv, x); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } + + // R_MIPS_SUB, R_MICROMIPS_SUB + static inline typename This::Status + relsub(unsigned char* view, const Mips_relobj<size, big_endian>* object, + const Symbol_value<size>* psymval, Mips_address addend_a, + bool extract_addend, unsigned int r_type) + { + mips_reloc_unshuffle(view, r_type, false); + Valtype32* wv = reinterpret_cast<Valtype32*>(view); + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); + Valtype32 addend = extract_addend ? val : addend_a; + + Valtype32 x = psymval->value(object, -addend); + elfcpp::Swap<32, big_endian>::writeval(wv, x); + mips_reloc_shuffle(view, r_type, false); + return This::STATUS_OKAY; + } +}; + +template<int size, bool big_endian> +typename std::list<reloc_high<size, big_endian> > + Mips_relocate_functions<size, big_endian>::hi16_relocs; + +template<int size, bool big_endian> +typename std::list<reloc_high<size, big_endian> > + Mips_relocate_functions<size, big_endian>::got16_relocs; + +// Mips_got_info methods. + +// Reserve GOT entry for a GOT relocation of type R_TYPE against symbol +// SYMNDX + ADDEND, where SYMNDX is a local symbol in section SHNDX in OBJECT. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::record_local_got_symbol( + Mips_relobj<size, big_endian>* object, unsigned int symndx, + Mips_address addend, unsigned int r_type, unsigned int shndx) +{ + Mips_got_entry<size, big_endian>* entry = + new Mips_got_entry<size, big_endian>(object, symndx, addend, + mips_elf_reloc_tls_type(r_type), + shndx); + this->record_got_entry(entry, object); +} + +// Reserve GOT entry for a GOT relocation of type R_TYPE against MIPS_SYM, +// in OBJECT. FOR_CALL is true if the caller is only interested in +// using the GOT entry for calls. DYN_RELOC is true if R_TYPE is a dynamic +// relocation. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::record_global_got_symbol( + Mips_symbol<size>* mips_sym, Mips_relobj<size, big_endian>* object, + unsigned int r_type, bool dyn_reloc, bool for_call) +{ + if (!for_call) + mips_sym->set_got_not_only_for_calls(); + + // A global symbol in the GOT must also be in the dynamic symbol table. + if (!mips_sym->needs_dynsym_entry()) + { + switch (mips_sym->visibility()) + { + case elfcpp::STV_INTERNAL: + case elfcpp::STV_HIDDEN: + mips_sym->set_is_forced_local(); + break; + default: + mips_sym->set_needs_dynsym_entry(); + break; + } + } + + unsigned char tls_type = mips_elf_reloc_tls_type(r_type); + if (tls_type == GOT_TLS_NONE) + this->global_got_symbols_.insert(mips_sym); + + if (dyn_reloc) + { + if (mips_sym->global_got_area() == GGA_NONE) + mips_sym->set_global_got_area(GGA_RELOC_ONLY); + return; + } + + Mips_got_entry<size, big_endian>* entry = + new Mips_got_entry<size, big_endian>(object, mips_sym, tls_type); + + this->record_got_entry(entry, object); +} + +// Add ENTRY to master GOT and to OBJECT's GOT. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::record_got_entry( + Mips_got_entry<size, big_endian>* entry, + Mips_relobj<size, big_endian>* object) +{ + if (this->got_entries_.find(entry) == this->got_entries_.end()) + this->got_entries_.insert(entry); + + // Create the GOT entry for the OBJECT's GOT. + Mips_got_info<size, big_endian>* g = object->get_or_create_got_info(); + Mips_got_entry<size, big_endian>* entry2 = + new Mips_got_entry<size, big_endian>(*entry); + + if (g->got_entries_.find(entry2) == g->got_entries_.end()) + g->got_entries_.insert(entry2); +} + +// Record that OBJECT has a page relocation against symbol SYMNDX and +// that ADDEND is the addend for that relocation. +// This function creates an upper bound on the number of GOT slots +// required; no attempt is made to combine references to non-overridable +// global symbols across multiple input files. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::record_got_page_entry( + Mips_relobj<size, big_endian>* object, unsigned int symndx, int addend) +{ + struct Got_page_range **range_ptr, *range; + int old_pages, new_pages; + + // Find the Got_page_entry for this symbol. + Got_page_entry* entry = new Got_page_entry(object, symndx); + typename Got_page_entry_set::iterator it = + this->got_page_entries_.find(entry); + if (it != this->got_page_entries_.end()) + entry = *it; + else + this->got_page_entries_.insert(entry); + + // Add the same entry to the OBJECT's GOT. + Got_page_entry* entry2 = NULL; + Mips_got_info<size, big_endian>* g2 = object->get_or_create_got_info(); + if (g2->got_page_entries_.find(entry) == g2->got_page_entries_.end()) + { + entry2 = new Got_page_entry(*entry); + g2->got_page_entries_.insert(entry2); + } + + // Skip over ranges whose maximum extent cannot share a page entry + // with ADDEND. + range_ptr = &entry->ranges; + while (*range_ptr && addend > (*range_ptr)->max_addend + 0xffff) + range_ptr = &(*range_ptr)->next; + + // If we scanned to the end of the list, or found a range whose + // minimum extent cannot share a page entry with ADDEND, create + // a new singleton range. + range = *range_ptr; + if (!range || addend < range->min_addend - 0xffff) + { + range = new Got_page_range(); + range->next = *range_ptr; + range->min_addend = addend; + range->max_addend = addend; + + *range_ptr = range; + ++entry->num_pages; + if (entry2 != NULL) + ++entry2->num_pages; + ++this->page_gotno_; + ++g2->page_gotno_; + return; + } + + // Remember how many pages the old range contributed. + old_pages = range->get_max_pages(); + + // Update the ranges. + if (addend < range->min_addend) + range->min_addend = addend; + else if (addend > range->max_addend) + { + if (range->next && addend >= range->next->min_addend - 0xffff) + { + old_pages += range->next->get_max_pages(); + range->max_addend = range->next->max_addend; + range->next = range->next->next; + } + else + range->max_addend = addend; + } + + // Record any change in the total estimate. + new_pages = range->get_max_pages(); + if (old_pages != new_pages) + { + entry->num_pages += new_pages - old_pages; + if (entry2 != NULL) + entry2->num_pages += new_pages - old_pages; + this->page_gotno_ += new_pages - old_pages; + g2->page_gotno_ += new_pages - old_pages; + } +} + +// Create all entries that should be in the local part of the GOT. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::add_local_entries( + Target_mips<size, big_endian>* target, Layout* layout) +{ + Mips_output_data_got<size, big_endian>* got = target->got_section(); + // First two GOT entries are reserved. The first entry will be filled at + // runtime. The second entry will be used by some runtime loaders. + got->add_constant(0); + got->add_constant(target->mips_elf_gnu_got1_mask()); + + for (typename Got_entry_set::iterator + p = this->got_entries_.begin(); + p != this->got_entries_.end(); + ++p) + { + Mips_got_entry<size, big_endian>* entry = *p; + if (entry->is_for_local_symbol() && !entry->is_tls_entry()) + { + got->add_local(entry->object(), entry->symndx(), + GOT_TYPE_STANDARD); + unsigned int got_offset = entry->object()->local_got_offset( + entry->symndx(), GOT_TYPE_STANDARD); + if (got->multi_got() && this->index_ > 0 + && parameters->options().output_is_position_independent()) + target->rel_dyn_section(layout)->add_local(entry->object(), + entry->symndx(), elfcpp::R_MIPS_REL32, got, got_offset); + } + } + + this->add_page_entries(target, layout); + + // Add global entries that should be in the local area. + for (typename Got_entry_set::iterator + p = this->got_entries_.begin(); + p != this->got_entries_.end(); + ++p) + { + Mips_got_entry<size, big_endian>* entry = *p; + if (!entry->is_for_global_symbol()) + continue; + + Mips_symbol<size>* mips_sym = entry->sym(); + if (mips_sym->global_got_area() == GGA_NONE && !entry->is_tls_entry()) + { + unsigned int got_type; + if (!got->multi_got()) + got_type = GOT_TYPE_STANDARD; + else + got_type = GOT_TYPE_STANDARD_MULTIGOT + this->index_; + if (got->add_global(mips_sym, got_type)) + { + mips_sym->set_global_gotoffset(mips_sym->got_offset(got_type)); + if (got->multi_got() && this->index_ > 0 + && parameters->options().output_is_position_independent()) + target->rel_dyn_section(layout)->add_symbolless_global_addend( + mips_sym, elfcpp::R_MIPS_REL32, got, + mips_sym->got_offset(got_type)); + } + } + } +} + +// Create GOT page entries. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::add_page_entries( + Target_mips<size, big_endian>* target, Layout* layout) +{ + if (this->page_gotno_ == 0) + return; + + Mips_output_data_got<size, big_endian>* got = target->got_section(); + this->got_page_offset_start_ = got->add_constant(0); + if (got->multi_got() && this->index_ > 0 + && parameters->options().output_is_position_independent()) + target->rel_dyn_section(layout)->add_absolute(elfcpp::R_MIPS_REL32, got, + this->got_page_offset_start_); + int num_entries = this->page_gotno_; + unsigned int prev_offset = this->got_page_offset_start_; + while (--num_entries > 0) + { + unsigned int next_offset = got->add_constant(0); + if (got->multi_got() && this->index_ > 0 + && parameters->options().output_is_position_independent()) + target->rel_dyn_section(layout)->add_absolute(elfcpp::R_MIPS_REL32, got, + next_offset); + gold_assert(next_offset == prev_offset + size/8); + prev_offset = next_offset; + } + this->got_page_offset_next_ = this->got_page_offset_start_; +} + +// Create global GOT entries, both GGA_NORMAL and GGA_RELOC_ONLY. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::add_global_entries( + Target_mips<size, big_endian>* target, Layout* layout, + unsigned int non_reloc_only_global_gotno) +{ + Mips_output_data_got<size, big_endian>* got = target->got_section(); + // Add GGA_NORMAL entries. + unsigned int count = 0; + for (typename Got_entry_set::iterator + p = this->got_entries_.begin(); + p != this->got_entries_.end(); + ++p) + { + Mips_got_entry<size, big_endian>* entry = *p; + if (!entry->is_for_global_symbol()) + continue; + + Mips_symbol<size>* mips_sym = entry->sym(); + if (mips_sym->global_got_area() != GGA_NORMAL) + continue; + + unsigned int got_type; + if (!got->multi_got()) + got_type = GOT_TYPE_STANDARD; + else + // In multi-GOT links, global symbol can be in both primary and + // secondary GOT(s). By creating custom GOT type + // (GOT_TYPE_STANDARD_MULTIGOT + got_index) we ensure that symbol + // is added to secondary GOT(s). + got_type = GOT_TYPE_STANDARD_MULTIGOT + this->index_; + if (!got->add_global(mips_sym, got_type)) + continue; + + mips_sym->set_global_gotoffset(mips_sym->got_offset(got_type)); + if (got->multi_got() && this->index_ == 0) + count++; + if (got->multi_got() && this->index_ > 0) + { + if (parameters->options().output_is_position_independent() + || (!parameters->doing_static_link() + && mips_sym->is_from_dynobj() && !mips_sym->is_undefined())) + { + target->rel_dyn_section(layout)->add_global( + mips_sym, elfcpp::R_MIPS_REL32, got, + mips_sym->got_offset(got_type)); + got->add_secondary_got_reloc(mips_sym->got_offset(got_type), + elfcpp::R_MIPS_REL32, mips_sym); + } + } + } + + if (!got->multi_got() || this->index_ == 0) + { + if (got->multi_got()) + { + // We need to allocate space in the primary GOT for GGA_NORMAL entries + // of secondary GOTs, to ensure that GOT offsets of GGA_RELOC_ONLY + // entries correspond to dynamic symbol indexes. + while (count < non_reloc_only_global_gotno) + { + got->add_constant(0); + ++count; + } + } + + // Add GGA_RELOC_ONLY entries. + got->add_reloc_only_entries(); + } +} + +// Create global GOT entries that should be in the GGA_RELOC_ONLY area. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::add_reloc_only_entries( + Mips_output_data_got<size, big_endian>* got) +{ + for (typename Unordered_set<Mips_symbol<size>*>::iterator + p = this->global_got_symbols_.begin(); + p != this->global_got_symbols_.end(); + ++p) + { + Mips_symbol<size>* mips_sym = *p; + if (mips_sym->global_got_area() == GGA_RELOC_ONLY) + { + unsigned int got_type; + if (!got->multi_got()) + got_type = GOT_TYPE_STANDARD; + else + got_type = GOT_TYPE_STANDARD_MULTIGOT; + if (got->add_global(mips_sym, got_type)) + mips_sym->set_global_gotoffset(mips_sym->got_offset(got_type)); + } + } +} + +// Create TLS GOT entries. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::add_tls_entries( + Target_mips<size, big_endian>* target, Layout* layout) +{ + Mips_output_data_got<size, big_endian>* got = target->got_section(); + // Add local tls entries. + for (typename Got_entry_set::iterator + p = this->got_entries_.begin(); + p != this->got_entries_.end(); + ++p) + { + Mips_got_entry<size, big_endian>* entry = *p; + if (!entry->is_tls_entry() || !entry->is_for_local_symbol()) + continue; + + if (entry->tls_type() == GOT_TLS_GD) + { + unsigned int got_type = GOT_TYPE_TLS_PAIR; + unsigned int r_type1 = (size == 32 ? elfcpp::R_MIPS_TLS_DTPMOD32 + : elfcpp::R_MIPS_TLS_DTPMOD64); + unsigned int r_type2 = (size == 32 ? elfcpp::R_MIPS_TLS_DTPREL32 + : elfcpp::R_MIPS_TLS_DTPREL64); + + if (!parameters->doing_static_link()) + { + got->add_local_pair_with_rel(entry->object(), entry->symndx(), + entry->shndx(), got_type, + target->rel_dyn_section(layout), + r_type1); + unsigned int got_offset = + entry->object()->local_got_offset(entry->symndx(), got_type); + got->add_static_reloc(got_offset + size/8, r_type2, + entry->object(), entry->symndx()); + } + else + { + // We are doing a static link. Mark it as belong to module 1, + // the executable. + unsigned int got_offset = got->add_constant(1); + entry->object()->set_local_got_offset(entry->symndx(), got_type, + got_offset); + got->add_constant(0); + got->add_static_reloc(got_offset + size/8, r_type2, + entry->object(), entry->symndx()); + } + } + else if (entry->tls_type() == GOT_TLS_IE) + { + unsigned int got_type = GOT_TYPE_TLS_OFFSET; + unsigned int r_type = (size == 32 ? elfcpp::R_MIPS_TLS_TPREL32 + : elfcpp::R_MIPS_TLS_TPREL64); + if (!parameters->doing_static_link()) + got->add_local_with_rel(entry->object(), entry->symndx(), got_type, + target->rel_dyn_section(layout), r_type); + else + { + got->add_local(entry->object(), entry->symndx(), got_type); + unsigned int got_offset = + entry->object()->local_got_offset(entry->symndx(), got_type); + got->add_static_reloc(got_offset, r_type, entry->object(), + entry->symndx()); + } + } + else if (entry->tls_type() == GOT_TLS_LDM) + { + unsigned int r_type = (size == 32 ? elfcpp::R_MIPS_TLS_DTPMOD32 + : elfcpp::R_MIPS_TLS_DTPMOD64); + unsigned int got_offset; + if (!parameters->doing_static_link()) + { + got_offset = got->add_constant(0); + target->rel_dyn_section(layout)->add_local( + entry->object(), 0, r_type, got, got_offset); + } + else + // We are doing a static link. Just mark it as belong to module 1, + // the executable. + got_offset = got->add_constant(1); + + got->add_constant(0); + got->set_tls_ldm_offset(got_offset, entry->object()); + } + else + gold_unreachable(); + } + + // Add global tls entries. + for (typename Got_entry_set::iterator + p = this->got_entries_.begin(); + p != this->got_entries_.end(); + ++p) + { + Mips_got_entry<size, big_endian>* entry = *p; + if (!entry->is_tls_entry() || !entry->is_for_global_symbol()) + continue; + + Mips_symbol<size>* mips_sym = entry->sym(); + if (entry->tls_type() == GOT_TLS_GD) + { + unsigned int got_type; + if (!got->multi_got()) + got_type = GOT_TYPE_TLS_PAIR; + else + got_type = GOT_TYPE_TLS_PAIR_MULTIGOT + this->index_; + unsigned int r_type1 = (size == 32 ? elfcpp::R_MIPS_TLS_DTPMOD32 + : elfcpp::R_MIPS_TLS_DTPMOD64); + unsigned int r_type2 = (size == 32 ? elfcpp::R_MIPS_TLS_DTPREL32 + : elfcpp::R_MIPS_TLS_DTPREL64); + if (!parameters->doing_static_link()) + got->add_global_pair_with_rel(mips_sym, got_type, + target->rel_dyn_section(layout), r_type1, r_type2); + else + { + // Add a GOT pair for for R_MIPS_TLS_GD. The creates a pair of + // GOT entries. The first one is initialized to be 1, which is the + // module index for the main executable and the second one 0. A + // reloc of the type R_MIPS_TLS_DTPREL32/64 will be created for + // the second GOT entry and will be applied by gold. + unsigned int got_offset = got->add_constant(1); + mips_sym->set_got_offset(got_type, got_offset); + got->add_constant(0); + got->add_static_reloc(got_offset + size/8, r_type2, mips_sym); + } + } + else if (entry->tls_type() == GOT_TLS_IE) + { + unsigned int got_type; + if (!got->multi_got()) + got_type = GOT_TYPE_TLS_OFFSET; + else + got_type = GOT_TYPE_TLS_OFFSET_MULTIGOT + this->index_; + unsigned int r_type = (size == 32 ? elfcpp::R_MIPS_TLS_TPREL32 + : elfcpp::R_MIPS_TLS_TPREL64); + if (!parameters->doing_static_link()) + got->add_global_with_rel(mips_sym, got_type, + target->rel_dyn_section(layout), r_type); + else + { + got->add_global(mips_sym, got_type); + unsigned int got_offset = mips_sym->got_offset(got_type); + got->add_static_reloc(got_offset, r_type, mips_sym); + } + } + else + gold_unreachable(); + } +} + +// Decide whether the symbol needs an entry in the global part of the primary +// GOT, setting global_got_area accordingly. Count the number of global +// symbols that are in the primary GOT only because they have dynamic +// relocations R_MIPS_REL32 against them (reloc_only_gotno). + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::count_got_symbols(Symbol_table* symtab) +{ + for (typename Unordered_set<Mips_symbol<size>*>::iterator + p = this->global_got_symbols_.begin(); + p != this->global_got_symbols_.end(); + ++p) + { + Mips_symbol<size>* sym = *p; + // Make a final decision about whether the symbol belongs in the + // local or global GOT. Symbols that bind locally can (and in the + // case of forced-local symbols, must) live in the local GOT. + // Those that are aren't in the dynamic symbol table must also + // live in the local GOT. + + if (!sym->should_add_dynsym_entry(symtab) + || (sym->got_only_for_calls() + ? symbol_calls_local(sym, sym->should_add_dynsym_entry(symtab)) + : symbol_references_local(sym, + sym->should_add_dynsym_entry(symtab)))) + // The symbol belongs in the local GOT. We no longer need this + // entry if it was only used for relocations; those relocations + // will be against the null or section symbol instead. + sym->set_global_got_area(GGA_NONE); + else if (sym->global_got_area() == GGA_RELOC_ONLY) + { + ++this->reloc_only_gotno_; + ++this->global_gotno_ ; + } + } +} + +// Return the offset of GOT page entry for VALUE. Initialize the entry with +// VALUE if it is not initialized. + +template<int size, bool big_endian> +unsigned int +Mips_got_info<size, big_endian>::get_got_page_offset(Mips_address value, + Mips_output_data_got<size, big_endian>* got) +{ + typename Got_page_offsets::iterator it = this->got_page_offsets_.find(value); + if (it != this->got_page_offsets_.end()) + return it->second; + + gold_assert(this->got_page_offset_next_ < this->got_page_offset_start_ + + (size/8) * this->page_gotno_); + + unsigned int got_offset = this->got_page_offset_next_; + this->got_page_offsets_[value] = got_offset; + this->got_page_offset_next_ += size/8; + got->update_got_entry(got_offset, value); + return got_offset; +} + +// Remove lazy-binding stubs for global symbols in this GOT. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::remove_lazy_stubs( + Target_mips<size, big_endian>* target) +{ + for (typename Got_entry_set::iterator + p = this->got_entries_.begin(); + p != this->got_entries_.end(); + ++p) + { + Mips_got_entry<size, big_endian>* entry = *p; + if (entry->is_for_global_symbol()) + target->remove_lazy_stub_entry(entry->sym()); + } +} + +// Count the number of GOT entries required. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::count_got_entries() +{ + for (typename Got_entry_set::iterator + p = this->got_entries_.begin(); + p != this->got_entries_.end(); + ++p) + { + this->count_got_entry(*p); + } +} + +// Count the number of GOT entries required by ENTRY. Accumulate the result. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::count_got_entry( + Mips_got_entry<size, big_endian>* entry) +{ + if (entry->is_tls_entry()) + this->tls_gotno_ += mips_tls_got_entries(entry->tls_type()); + else if (entry->is_for_local_symbol() + || entry->sym()->global_got_area() == GGA_NONE) + ++this->local_gotno_; + else + ++this->global_gotno_; +} + +// Add FROM's GOT entries. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::add_got_entries( + Mips_got_info<size, big_endian>* from) +{ + for (typename Got_entry_set::iterator + p = from->got_entries_.begin(); + p != from->got_entries_.end(); + ++p) + { + Mips_got_entry<size, big_endian>* entry = *p; + if (this->got_entries_.find(entry) == this->got_entries_.end()) + { + Mips_got_entry<size, big_endian>* entry2 = + new Mips_got_entry<size, big_endian>(*entry); + this->got_entries_.insert(entry2); + this->count_got_entry(entry); + } + } +} + +// Add FROM's GOT page entries. + +template<int size, bool big_endian> +void +Mips_got_info<size, big_endian>::add_got_page_entries( + Mips_got_info<size, big_endian>* from) +{ + for (typename Got_page_entry_set::iterator + p = from->got_page_entries_.begin(); + p != from->got_page_entries_.end(); + ++p) + { + Got_page_entry* entry = *p; + if (this->got_page_entries_.find(entry) == this->got_page_entries_.end()) + { + Got_page_entry* entry2 = new Got_page_entry(*entry); + this->got_page_entries_.insert(entry2); + this->page_gotno_ += entry->num_pages; + } + } +} + +// Mips_output_data_got methods. + +// Lay out the GOT. Add local, global and TLS entries. If GOT is +// larger than 64K, create multi-GOT. + +template<int size, bool big_endian> +void +Mips_output_data_got<size, big_endian>::lay_out_got(Layout* layout, + Symbol_table* symtab, const Input_objects* input_objects) +{ + // Decide which symbols need to go in the global part of the GOT and + // count the number of reloc-only GOT symbols. + this->master_got_info_->count_got_symbols(symtab); + + // Count the number of GOT entries. + this->master_got_info_->count_got_entries(); + + unsigned int got_size = this->master_got_info_->got_size(); + if (got_size > Target_mips<size, big_endian>::MIPS_GOT_MAX_SIZE) + this->lay_out_multi_got(layout, input_objects); + else + { + // Record that all objects use single GOT. + for (Input_objects::Relobj_iterator p = input_objects->relobj_begin(); + p != input_objects->relobj_end(); + ++p) + { + Mips_relobj<size, big_endian>* object = + Mips_relobj<size, big_endian>::as_mips_relobj(*p); + if (object->get_got_info() != NULL) + object->set_got_info(this->master_got_info_); + } + + this->master_got_info_->add_local_entries(this->target_, layout); + this->master_got_info_->add_global_entries(this->target_, layout, + /*not used*/-1U); + this->master_got_info_->add_tls_entries(this->target_, layout); + } +} + +// Create multi-GOT. For every GOT, add local, global and TLS entries. + +template<int size, bool big_endian> +void +Mips_output_data_got<size, big_endian>::lay_out_multi_got(Layout* layout, + const Input_objects* input_objects) +{ + // Try to merge the GOTs of input objects together, as long as they + // don't seem to exceed the maximum GOT size, choosing one of them + // to be the primary GOT. + this->merge_gots(input_objects); + + // Every symbol that is referenced in a dynamic relocation must be + // present in the primary GOT. + this->primary_got_->set_global_gotno(this->master_got_info_->global_gotno()); + + // Add GOT entries. + unsigned int i = 0; + unsigned int offset = 0; + Mips_got_info<size, big_endian>* g = this->primary_got_; + do + { + g->set_index(i); + g->set_offset(offset); + + g->add_local_entries(this->target_, layout); + if (i == 0) + g->add_global_entries(this->target_, layout, + (this->master_got_info_->global_gotno() + - this->master_got_info_->reloc_only_gotno())); + else + g->add_global_entries(this->target_, layout, /*not used*/-1U); + g->add_tls_entries(this->target_, layout); + + // Forbid global symbols in every non-primary GOT from having + // lazy-binding stubs. + if (i > 0) + g->remove_lazy_stubs(this->target_); + + ++i; + offset += g->got_size(); + g = g->next(); + } + while (g); +} + +// Attempt to merge GOTs of different input objects. Try to use as much as +// possible of the primary GOT, since it doesn't require explicit dynamic +// relocations, but don't use objects that would reference global symbols +// out of the addressable range. Failing the primary GOT, attempt to merge +// with the current GOT, or finish the current GOT and then make make the new +// GOT current. + +template<int size, bool big_endian> +void +Mips_output_data_got<size, big_endian>::merge_gots( + const Input_objects* input_objects) +{ + gold_assert(this->primary_got_ == NULL); + Mips_got_info<size, big_endian>* current = NULL; + + for (Input_objects::Relobj_iterator p = input_objects->relobj_begin(); + p != input_objects->relobj_end(); + ++p) + { + Mips_relobj<size, big_endian>* object = + Mips_relobj<size, big_endian>::as_mips_relobj(*p); + + Mips_got_info<size, big_endian>* g = object->get_got_info(); + if (g == NULL) + continue; + + g->count_got_entries(); + + // Work out the number of page, local and TLS entries. + unsigned int estimate = this->master_got_info_->page_gotno(); + if (estimate > g->page_gotno()) + estimate = g->page_gotno(); + estimate += g->local_gotno() + g->tls_gotno(); + + // We place TLS GOT entries after both locals and globals. The globals + // for the primary GOT may overflow the normal GOT size limit, so be + // sure not to merge a GOT which requires TLS with the primary GOT in that + // case. This doesn't affect non-primary GOTs. + estimate += (g->tls_gotno() > 0 ? this->master_got_info_->global_gotno() + : g->global_gotno()); + + unsigned int max_count = + Target_mips<size, big_endian>::MIPS_GOT_MAX_SIZE / (size/8) - 2; + if (estimate <= max_count) + { + // If we don't have a primary GOT, use it as + // a starting point for the primary GOT. + if (!this->primary_got_) + { + this->primary_got_ = g; + continue; + } + + // Try merging with the primary GOT. + if (this->merge_got_with(g, object, this->primary_got_)) + continue; + } + + // If we can merge with the last-created GOT, do it. + if (current && this->merge_got_with(g, object, current)) + continue; + + // Well, we couldn't merge, so create a new GOT. Don't check if it + // fits; if it turns out that it doesn't, we'll get relocation + // overflows anyway. + g->set_next(current); + current = g; + } + + // If we do not find any suitable primary GOT, create an empty one. + if (this->primary_got_ == NULL) + this->primary_got_ = new Mips_got_info<size, big_endian>(); + + // Link primary GOT with secondary GOTs. + this->primary_got_->set_next(current); +} + +// Consider merging FROM, which is OBJECT's GOT, into TO. Return false if +// this would lead to overflow, true if they were merged successfully. + +template<int size, bool big_endian> +bool +Mips_output_data_got<size, big_endian>::merge_got_with( + Mips_got_info<size, big_endian>* from, + Mips_relobj<size, big_endian>* object, + Mips_got_info<size, big_endian>* to) +{ + // Work out how many page entries we would need for the combined GOT. + unsigned int estimate = this->master_got_info_->page_gotno(); + if (estimate >= from->page_gotno() + to->page_gotno()) + estimate = from->page_gotno() + to->page_gotno(); + + // Conservatively estimate how many local and TLS entries would be needed. + estimate += from->local_gotno() + to->local_gotno(); + estimate += from->tls_gotno() + to->tls_gotno(); + + // If we're merging with the primary got, any TLS relocations will + // come after the full set of global entries. Otherwise estimate those + // conservatively as well. + if (to == this->primary_got_ && (from->tls_gotno() + to->tls_gotno()) > 0) + estimate += this->master_got_info_->global_gotno(); + else + estimate += from->global_gotno() + to->global_gotno(); + + // Bail out if the combined GOT might be too big. + unsigned int max_count = + Target_mips<size, big_endian>::MIPS_GOT_MAX_SIZE / (size/8) - 2; + if (estimate > max_count) + return false; + + // Transfer the object's GOT information from FROM to TO. + to->add_got_entries(from); + to->add_got_page_entries(from); + + // Record that OBJECT should use output GOT TO. + object->set_got_info(to); + + return true; +} + +// Write out the GOT. + +template<int size, bool big_endian> +void +Mips_output_data_got<size, big_endian>::do_write(Output_file* of) +{ + // Call parent to write out GOT. + Output_data_got<size, big_endian>::do_write(of); + + const off_t offset = this->offset(); + const section_size_type oview_size = + convert_to_section_size_type(this->data_size()); + unsigned char* const oview = of->get_output_view(offset, oview_size); + + // Needed for fixing values of .got section. + this->got_view_ = oview; + + // Write lazy stub addresses. + for (typename Unordered_set<Mips_symbol<size>*>::iterator + p = this->master_got_info_->global_got_symbols().begin(); + p != this->master_got_info_->global_got_symbols().end(); + ++p) + { + Mips_symbol<size>* mips_sym = *p; + if (mips_sym->has_lazy_stub()) + { + Valtype* wv = reinterpret_cast<Valtype*>( + oview + this->get_primary_got_offset(mips_sym)); + Valtype value = + this->target_->mips_stubs_section()->stub_address(mips_sym); + elfcpp::Swap<size, big_endian>::writeval(wv, value); + } + } + + // Add +1 to GGA_NONE nonzero MIPS16 and microMIPS entries. + for (typename Unordered_set<Mips_symbol<size>*>::iterator + p = this->master_got_info_->global_got_symbols().begin(); + p != this->master_got_info_->global_got_symbols().end(); + ++p) + { + Mips_symbol<size>* mips_sym = *p; + if (!this->multi_got() + && (mips_sym->is_mips16() || mips_sym->is_micromips()) + && mips_sym->global_got_area() == GGA_NONE + && mips_sym->has_got_offset(GOT_TYPE_STANDARD)) + { + Valtype* wv = reinterpret_cast<Valtype*>( + oview + mips_sym->got_offset(GOT_TYPE_STANDARD)); + Valtype value = elfcpp::Swap<size, big_endian>::readval(wv); + if (value != 0) + { + value |= 1; + elfcpp::Swap<size, big_endian>::writeval(wv, value); + } + } + } + + if (!this->secondary_got_relocs_.empty()) + { + // Fixup for the secondary GOT R_MIPS_REL32 relocs. For global + // secondary GOT entries with non-zero initial value copy the value + // to the corresponding primary GOT entry, and set the secondary GOT + // entry to zero. + // TODO(sasa): This is workaround. It needs to be investigated further. + + for (size_t i = 0; i < this->secondary_got_relocs_.size(); ++i) + { + Static_reloc& reloc(this->secondary_got_relocs_[i]); + if (reloc.symbol_is_global()) + { + Mips_symbol<size>* gsym = reloc.symbol(); + gold_assert(gsym != NULL); + + unsigned got_offset = reloc.got_offset(); + gold_assert(got_offset < oview_size); + + // Find primary GOT entry. + Valtype* wv_prim = reinterpret_cast<Valtype*>( + oview + this->get_primary_got_offset(gsym)); + + // Find secondary GOT entry. + Valtype* wv_sec = reinterpret_cast<Valtype*>(oview + got_offset); + + Valtype value = elfcpp::Swap<size, big_endian>::readval(wv_sec); + if (value != 0) + { + elfcpp::Swap<size, big_endian>::writeval(wv_prim, value); + elfcpp::Swap<size, big_endian>::writeval(wv_sec, 0); + gsym->set_applied_secondary_got_fixup(); + } + } + } + + of->write_output_view(offset, oview_size, oview); + } + + // We are done if there is no fix up. + if (this->static_relocs_.empty()) + return; + + Output_segment* tls_segment = this->layout_->tls_segment(); + gold_assert(tls_segment != NULL); + + for (size_t i = 0; i < this->static_relocs_.size(); ++i) + { + Static_reloc& reloc(this->static_relocs_[i]); + + Mips_address value; + if (!reloc.symbol_is_global()) + { + Sized_relobj_file<size, big_endian>* object = reloc.relobj(); + const Symbol_value<size>* psymval = + object->local_symbol(reloc.index()); + + // We are doing static linking. Issue an error and skip this + // relocation if the symbol is undefined or in a discarded_section. + bool is_ordinary; + unsigned int shndx = psymval->input_shndx(&is_ordinary); + if ((shndx == elfcpp::SHN_UNDEF) + || (is_ordinary + && shndx != elfcpp::SHN_UNDEF + && !object->is_section_included(shndx) + && !this->symbol_table_->is_section_folded(object, shndx))) + { + gold_error(_("undefined or discarded local symbol %u from " + " object %s in GOT"), + reloc.index(), reloc.relobj()->name().c_str()); + continue; + } + + value = psymval->value(object, 0); + } + else + { + const Mips_symbol<size>* gsym = reloc.symbol(); + gold_assert(gsym != NULL); + + // We are doing static linking. Issue an error and skip this + // relocation if the symbol is undefined or in a discarded_section + // unless it is a weakly_undefined symbol. + if ((gsym->is_defined_in_discarded_section() || gsym->is_undefined()) + && !gsym->is_weak_undefined()) + { + gold_error(_("undefined or discarded symbol %s in GOT"), + gsym->name()); + continue; + } + + if (!gsym->is_weak_undefined()) + value = gsym->value(); + else + value = 0; + } + + unsigned got_offset = reloc.got_offset(); + gold_assert(got_offset < oview_size); + + Valtype* wv = reinterpret_cast<Valtype*>(oview + got_offset); + Valtype x; + + switch (reloc.r_type()) + { + case elfcpp::R_MIPS_TLS_DTPMOD32: + case elfcpp::R_MIPS_TLS_DTPMOD64: + x = value; + break; + case elfcpp::R_MIPS_TLS_DTPREL32: + case elfcpp::R_MIPS_TLS_DTPREL64: + x = value - elfcpp::DTP_OFFSET; + break; + case elfcpp::R_MIPS_TLS_TPREL32: + case elfcpp::R_MIPS_TLS_TPREL64: + x = value - elfcpp::TP_OFFSET; + break; + default: + gold_unreachable(); + break; + } + + elfcpp::Swap<size, big_endian>::writeval(wv, x); + } + + of->write_output_view(offset, oview_size, oview); +} + +// Mips_relobj methods. + +// Count the local symbols. The Mips backend needs to know if a symbol +// is a MIPS16 or microMIPS function or not. For global symbols, it is easy +// because the Symbol object keeps the ELF symbol type and st_other field. +// For local symbol it is harder because we cannot access this information. +// So we override the do_count_local_symbol in parent and scan local symbols to +// mark MIPS16 and microMIPS functions. This is not the most efficient way but +// I do not want to slow down other ports by calling a per symbol target hook +// inside Sized_relobj_file<size, big_endian>::do_count_local_symbols. + +template<int size, bool big_endian> +void +Mips_relobj<size, big_endian>::do_count_local_symbols( + Stringpool_template<char>* pool, + Stringpool_template<char>* dynpool) +{ + // Ask parent to count the local symbols. + Sized_relobj_file<size, big_endian>::do_count_local_symbols(pool, dynpool); + const unsigned int loccount = this->local_symbol_count(); + if (loccount == 0) + return; + + // Initialize the mips16 and micromips function bit-vector. + this->local_symbol_is_mips16_.resize(loccount, false); + this->local_symbol_is_micromips_.resize(loccount, false); + + // Read the symbol table section header. + const unsigned int symtab_shndx = this->symtab_shndx(); + elfcpp::Shdr<size, big_endian> + symtabshdr(this, this->elf_file()->section_header(symtab_shndx)); + gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB); + + // Read the local symbols. + const int sym_size = elfcpp::Elf_sizes<size>::sym_size; + gold_assert(loccount == symtabshdr.get_sh_info()); + off_t locsize = loccount * sym_size; + const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(), + locsize, true, true); + + // Loop over the local symbols and mark any MIPS16 or microMIPS local symbols. + + // Skip the first dummy symbol. + psyms += sym_size; + for (unsigned int i = 1; i < loccount; ++i, psyms += sym_size) + { + elfcpp::Sym<size, big_endian> sym(psyms); + unsigned char st_other = sym.get_st_other(); + this->local_symbol_is_mips16_[i] = elfcpp::elf_st_is_mips16(st_other); + this->local_symbol_is_micromips_[i] = + elfcpp::elf_st_is_micromips(st_other); + } +} + +// Read the symbol information. + +template<int size, bool big_endian> +void +Mips_relobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd) +{ + // Call parent class to read symbol information. + this->base_read_symbols(sd); + + // Read processor-specific flags in ELF file header. + const unsigned char* pehdr = this->get_view(elfcpp::file_header_offset, + elfcpp::Elf_sizes<size>::ehdr_size, + true, false); + elfcpp::Ehdr<size, big_endian> ehdr(pehdr); + this->processor_specific_flags_ = ehdr.get_e_flags(); + + // Get the section names. + const unsigned char* pnamesu = sd->section_names->data(); + const char* pnames = reinterpret_cast<const char*>(pnamesu); + + // Initialize the mips16 stub section bit-vectors. + this->section_is_mips16_fn_stub_.resize(this->shnum(), false); + this->section_is_mips16_call_stub_.resize(this->shnum(), false); + this->section_is_mips16_call_fp_stub_.resize(this->shnum(), false); + + const size_t shdr_size = elfcpp::Elf_sizes<size>::shdr_size; + const unsigned char* pshdrs = sd->section_headers->data(); + const unsigned char* ps = pshdrs + shdr_size; + for (unsigned int i = 1; i < this->shnum(); ++i, ps += shdr_size) + { + elfcpp::Shdr<size, big_endian> shdr(ps); + + if (shdr.get_sh_type() == elfcpp::SHT_MIPS_REGINFO) + { + // Read the gp value that was used to create this object. We need the + // gp value while processing relocs. The .reginfo section is not used + // in the 64-bit MIPS ELF ABI. + section_offset_type section_offset = shdr.get_sh_offset(); + section_size_type section_size = + convert_to_section_size_type(shdr.get_sh_size()); + const unsigned char* view = + this->get_view(section_offset, section_size, true, false); + + this->gp_ = elfcpp::Swap<size, big_endian>::readval(view + 20); + + // Read the rest of .reginfo. + this->gprmask_ = elfcpp::Swap<size, big_endian>::readval(view); + this->cprmask1_ = elfcpp::Swap<size, big_endian>::readval(view + 4); + this->cprmask2_ = elfcpp::Swap<size, big_endian>::readval(view + 8); + this->cprmask3_ = elfcpp::Swap<size, big_endian>::readval(view + 12); + this->cprmask4_ = elfcpp::Swap<size, big_endian>::readval(view + 16); + } + + const char* name = pnames + shdr.get_sh_name(); + this->section_is_mips16_fn_stub_[i] = is_prefix_of(".mips16.fn", name); + this->section_is_mips16_call_stub_[i] = + is_prefix_of(".mips16.call.", name); + this->section_is_mips16_call_fp_stub_[i] = + is_prefix_of(".mips16.call.fp.", name); + + if (strcmp(name, ".pdr") == 0) + { + gold_assert(this->pdr_shndx_ == -1U); + this->pdr_shndx_ = i; + } + } +} + +// Discard MIPS16 stub secions that are not needed. + +template<int size, bool big_endian> +void +Mips_relobj<size, big_endian>::discard_mips16_stub_sections(Symbol_table* symtab) +{ + for (typename Mips16_stubs_int_map::const_iterator + it = this->mips16_stub_sections_.begin(); + it != this->mips16_stub_sections_.end(); ++it) + { + Mips16_stub_section<size, big_endian>* stub_section = it->second; + if (!stub_section->is_target_found()) + { + gold_error(_("no relocation found in mips16 stub section '%s'"), + stub_section->object() + ->section_name(stub_section->shndx()).c_str()); + } + + bool discard = false; + if (stub_section->is_for_local_function()) + { + if (stub_section->is_fn_stub()) + { + // This stub is for a local symbol. This stub will only + // be needed if there is some relocation in this object, + // other than a 16 bit function call, which refers to this + // symbol. + if (!this->has_local_non_16bit_call_relocs(stub_section->r_sym())) + discard = true; + else + this->add_local_mips16_fn_stub(stub_section); + } + else + { + // This stub is for a local symbol. This stub will only + // be needed if there is some relocation (R_MIPS16_26) in + // this object that refers to this symbol. + gold_assert(stub_section->is_call_stub() + || stub_section->is_call_fp_stub()); + if (!this->has_local_16bit_call_relocs(stub_section->r_sym())) + discard = true; + else + this->add_local_mips16_call_stub(stub_section); + } + } + else + { + Mips_symbol<size>* gsym = stub_section->gsym(); + if (stub_section->is_fn_stub()) + { + if (gsym->has_mips16_fn_stub()) + // We already have a stub for this function. + discard = true; + else + { + gsym->set_mips16_fn_stub(stub_section); + if (gsym->should_add_dynsym_entry(symtab)) + { + // If we have a MIPS16 function with a stub, the + // dynamic symbol must refer to the stub, since only + // the stub uses the standard calling conventions. + gsym->set_need_fn_stub(); + if (gsym->is_from_dynobj()) + gsym->set_needs_dynsym_value(); + } + } + if (!gsym->need_fn_stub()) + discard = true; + } + else if (stub_section->is_call_stub()) + { + if (gsym->is_mips16()) + // We don't need the call_stub; this is a 16 bit + // function, so calls from other 16 bit functions are + // OK. + discard = true; + else if (gsym->has_mips16_call_stub()) + // We already have a stub for this function. + discard = true; + else + gsym->set_mips16_call_stub(stub_section); + } + else + { + gold_assert(stub_section->is_call_fp_stub()); + if (gsym->is_mips16()) + // We don't need the call_stub; this is a 16 bit + // function, so calls from other 16 bit functions are + // OK. + discard = true; + else if (gsym->has_mips16_call_fp_stub()) + // We already have a stub for this function. + discard = true; + else + gsym->set_mips16_call_fp_stub(stub_section); + } + } + if (discard) + this->set_output_section(stub_section->shndx(), NULL); + } +} + +// Mips_output_data_la25_stub methods. + +// Template for standard LA25 stub. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_la25_stub<size, big_endian>::la25_stub_entry[] = +{ + 0x3c190000, // lui $25,%hi(func) + 0x08000000, // j func + 0x27390000, // add $25,$25,%lo(func) + 0x00000000 // nop +}; + +// Template for microMIPS LA25 stub. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_la25_stub<size, big_endian>::la25_stub_micromips_entry[] = +{ + 0x41b9, 0x0000, // lui t9,%hi(func) + 0xd400, 0x0000, // j func + 0x3339, 0x0000, // addiu t9,t9,%lo(func) + 0x0000, 0x0000 // nop +}; + +// Create la25 stub for a symbol. + +template<int size, bool big_endian> +void +Mips_output_data_la25_stub<size, big_endian>::create_la25_stub( + Symbol_table* symtab, Target_mips<size, big_endian>* target, + Mips_symbol<size>* gsym) +{ + if (!gsym->has_la25_stub()) + { + gsym->set_la25_stub_offset(this->symbols_.size() * 16); + this->symbols_.insert(gsym); + this->create_stub_symbol(gsym, symtab, target, 16); + } +} + +// Create a symbol for SYM stub's value and size, to help make the disassembly +// easier to read. + +template<int size, bool big_endian> +void +Mips_output_data_la25_stub<size, big_endian>::create_stub_symbol( + Mips_symbol<size>* sym, Symbol_table* symtab, + Target_mips<size, big_endian>* target, uint64_t symsize) +{ + std::string name(".pic."); + name += sym->name(); + + unsigned int offset = sym->la25_stub_offset(); + if (sym->is_micromips()) + offset |= 1; + + // Make it a local function. + Symbol* new_sym = symtab->define_in_output_data(name.c_str(), NULL, + Symbol_table::PREDEFINED, + target->la25_stub_section(), + offset, symsize, elfcpp::STT_FUNC, + elfcpp::STB_LOCAL, + elfcpp::STV_DEFAULT, 0, + false, false); + new_sym->set_is_forced_local(); +} + +// Write out la25 stubs. This uses the hand-coded instructions above, +// and adjusts them as needed. + +template<int size, bool big_endian> +void +Mips_output_data_la25_stub<size, big_endian>::do_write(Output_file* of) +{ + const off_t offset = this->offset(); + const section_size_type oview_size = + convert_to_section_size_type(this->data_size()); + unsigned char* const oview = of->get_output_view(offset, oview_size); + + for (typename Unordered_set<Mips_symbol<size>*>::iterator + p = this->symbols_.begin(); + p != this->symbols_.end(); + ++p) + { + Mips_symbol<size>* sym = *p; + unsigned char* pov = oview + sym->la25_stub_offset(); + + Mips_address target = sym->value(); + if (!sym->is_micromips()) + { + elfcpp::Swap<32, big_endian>::writeval(pov, + la25_stub_entry[0] | (((target + 0x8000) >> 16) & 0xffff)); + elfcpp::Swap<32, big_endian>::writeval(pov + 4, + la25_stub_entry[1] | ((target >> 2) & 0x3ffffff)); + elfcpp::Swap<32, big_endian>::writeval(pov + 8, + la25_stub_entry[2] | (target & 0xffff)); + elfcpp::Swap<32, big_endian>::writeval(pov + 12, la25_stub_entry[3]); + } + else + { + target |= 1; + // First stub instruction. Paste high 16-bits of the target. + elfcpp::Swap<16, big_endian>::writeval(pov, + la25_stub_micromips_entry[0]); + elfcpp::Swap<16, big_endian>::writeval(pov + 2, + ((target + 0x8000) >> 16) & 0xffff); + // Second stub instruction. Paste low 26-bits of the target, shifted + // right by 1. + elfcpp::Swap<16, big_endian>::writeval(pov + 4, + la25_stub_micromips_entry[2] | ((target >> 17) & 0x3ff)); + elfcpp::Swap<16, big_endian>::writeval(pov + 6, + la25_stub_micromips_entry[3] | ((target >> 1) & 0xffff)); + // Third stub instruction. Paste low 16-bits of the target. + elfcpp::Swap<16, big_endian>::writeval(pov + 8, + la25_stub_micromips_entry[4]); + elfcpp::Swap<16, big_endian>::writeval(pov + 10, target & 0xffff); + // Fourth stub instruction. + elfcpp::Swap<16, big_endian>::writeval(pov + 12, + la25_stub_micromips_entry[6]); + elfcpp::Swap<16, big_endian>::writeval(pov + 14, + la25_stub_micromips_entry[7]); + } + } + + of->write_output_view(offset, oview_size, oview); +} + +// Mips_output_data_plt methods. + +// The format of the first PLT entry in an O32 executable. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>::plt0_entry_o32[] = +{ + 0x3c1c0000, // lui $28, %hi(&GOTPLT[0]) + 0x8f990000, // lw $25, %lo(&GOTPLT[0])($28) + 0x279c0000, // addiu $28, $28, %lo(&GOTPLT[0]) + 0x031cc023, // subu $24, $24, $28 + 0x03e07821, // move $15, $31 # 32-bit move (addu) + 0x0018c082, // srl $24, $24, 2 + 0x0320f809, // jalr $25 + 0x2718fffe // subu $24, $24, 2 +}; + +// The format of the first PLT entry in an N32 executable. Different +// because gp ($28) is not available; we use t2 ($14) instead. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>::plt0_entry_n32[] = +{ + 0x3c0e0000, // lui $14, %hi(&GOTPLT[0]) + 0x8dd90000, // lw $25, %lo(&GOTPLT[0])($14) + 0x25ce0000, // addiu $14, $14, %lo(&GOTPLT[0]) + 0x030ec023, // subu $24, $24, $14 + 0x03e07821, // move $15, $31 # 32-bit move (addu) + 0x0018c082, // srl $24, $24, 2 + 0x0320f809, // jalr $25 + 0x2718fffe // subu $24, $24, 2 +}; + +// The format of the first PLT entry in an N64 executable. Different +// from N32 because of the increased size of GOT entries. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>::plt0_entry_n64[] = +{ + 0x3c0e0000, // lui $14, %hi(&GOTPLT[0]) + 0xddd90000, // ld $25, %lo(&GOTPLT[0])($14) + 0x25ce0000, // addiu $14, $14, %lo(&GOTPLT[0]) + 0x030ec023, // subu $24, $24, $14 + 0x03e07821, // move $15, $31 # 64-bit move (daddu) + 0x0018c0c2, // srl $24, $24, 3 + 0x0320f809, // jalr $25 + 0x2718fffe // subu $24, $24, 2 +}; + +// The format of the microMIPS first PLT entry in an O32 executable. +// We rely on v0 ($2) rather than t8 ($24) to contain the address +// of the GOTPLT entry handled, so this stub may only be used when +// all the subsequent PLT entries are microMIPS code too. +// +// The trailing NOP is for alignment and correct disassembly only. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>:: +plt0_entry_micromips_o32[] = +{ + 0x7980, 0x0000, // addiupc $3, (&GOTPLT[0]) - . + 0xff23, 0x0000, // lw $25, 0($3) + 0x0535, // subu $2, $2, $3 + 0x2525, // srl $2, $2, 2 + 0x3302, 0xfffe, // subu $24, $2, 2 + 0x0dff, // move $15, $31 + 0x45f9, // jalrs $25 + 0x0f83, // move $28, $3 + 0x0c00 // nop +}; + +// The format of the microMIPS first PLT entry in an O32 executable +// in the insn32 mode. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>:: +plt0_entry_micromips32_o32[] = +{ + 0x41bc, 0x0000, // lui $28, %hi(&GOTPLT[0]) + 0xff3c, 0x0000, // lw $25, %lo(&GOTPLT[0])($28) + 0x339c, 0x0000, // addiu $28, $28, %lo(&GOTPLT[0]) + 0x0398, 0xc1d0, // subu $24, $24, $28 + 0x001f, 0x7950, // move $15, $31 + 0x0318, 0x1040, // srl $24, $24, 2 + 0x03f9, 0x0f3c, // jalr $25 + 0x3318, 0xfffe // subu $24, $24, 2 +}; + +// The format of subsequent standard entries in the PLT. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>::plt_entry[] = +{ + 0x3c0f0000, // lui $15, %hi(.got.plt entry) + 0x8df90000, // l[wd] $25, %lo(.got.plt entry)($15) + 0x03200008, // jr $25 + 0x25f80000 // addiu $24, $15, %lo(.got.plt entry) +}; + +// The format of subsequent MIPS16 o32 PLT entries. We use v1 ($3) as a +// temporary because t8 ($24) and t9 ($25) are not directly addressable. +// Note that this differs from the GNU ld which uses both v0 ($2) and v1 ($3). +// We cannot use v0 because MIPS16 call stubs from the CS toolchain expect +// target function address in register v0. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>::plt_entry_mips16_o32[] = +{ + 0xb303, // lw $3, 12($pc) + 0x651b, // move $24, $3 + 0x9b60, // lw $3, 0($3) + 0xeb00, // jr $3 + 0x653b, // move $25, $3 + 0x6500, // nop + 0x0000, 0x0000 // .word (.got.plt entry) +}; + +// The format of subsequent microMIPS o32 PLT entries. We use v0 ($2) +// as a temporary because t8 ($24) is not addressable with ADDIUPC. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>:: +plt_entry_micromips_o32[] = +{ + 0x7900, 0x0000, // addiupc $2, (.got.plt entry) - . + 0xff22, 0x0000, // lw $25, 0($2) + 0x4599, // jr $25 + 0x0f02 // move $24, $2 +}; + +// The format of subsequent microMIPS o32 PLT entries in the insn32 mode. +template<int size, bool big_endian> +const uint32_t Mips_output_data_plt<size, big_endian>:: +plt_entry_micromips32_o32[] = +{ + 0x41af, 0x0000, // lui $15, %hi(.got.plt entry) + 0xff2f, 0x0000, // lw $25, %lo(.got.plt entry)($15) + 0x0019, 0x0f3c, // jr $25 + 0x330f, 0x0000 // addiu $24, $15, %lo(.got.plt entry) +}; + +// Add an entry to the PLT for a symbol referenced by r_type relocation. + +template<int size, bool big_endian> +void +Mips_output_data_plt<size, big_endian>::add_entry(Mips_symbol<size>* gsym, + unsigned int r_type) +{ + gold_assert(!gsym->has_plt_offset()); + + // Final PLT offset for a symbol will be set in method set_plt_offsets(). + gsym->set_plt_offset(this->entry_count() * sizeof(plt_entry) + + sizeof(plt0_entry_o32)); + this->symbols_.push_back(gsym); + + // Record whether the relocation requires a standard MIPS + // or a compressed code entry. + if (jal_reloc(r_type)) + { + if (r_type == elfcpp::R_MIPS_26) + gsym->set_needs_mips_plt(true); + else + gsym->set_needs_comp_plt(true); + } + + section_offset_type got_offset = this->got_plt_->current_data_size(); + + // Every PLT entry needs a GOT entry which points back to the PLT + // entry (this will be changed by the dynamic linker, normally + // lazily when the function is called). + this->got_plt_->set_current_data_size(got_offset + size/8); + + gsym->set_needs_dynsym_entry(); + this->rel_->add_global(gsym, elfcpp::R_MIPS_JUMP_SLOT, this->got_plt_, + got_offset); +} + +// Set final PLT offsets. For each symbol, determine whether standard or +// compressed (MIPS16 or microMIPS) PLT entry is used. + +template<int size, bool big_endian> +void +Mips_output_data_plt<size, big_endian>::set_plt_offsets() +{ + // The sizes of individual PLT entries. + unsigned int plt_mips_entry_size = this->standard_plt_entry_size(); + unsigned int plt_comp_entry_size = (!this->target_->is_output_newabi() + ? this->compressed_plt_entry_size() : 0); + + for (typename std::vector<Mips_symbol<size>*>::const_iterator + p = this->symbols_.begin(); p != this->symbols_.end(); ++p) + { + Mips_symbol<size>* mips_sym = *p; + + // There are no defined MIPS16 or microMIPS PLT entries for n32 or n64, + // so always use a standard entry there. + // + // If the symbol has a MIPS16 call stub and gets a PLT entry, then + // all MIPS16 calls will go via that stub, and there is no benefit + // to having a MIPS16 entry. And in the case of call_stub a + // standard entry actually has to be used as the stub ends with a J + // instruction. + if (this->target_->is_output_newabi() + || mips_sym->has_mips16_call_stub() + || mips_sym->has_mips16_call_fp_stub()) + { + mips_sym->set_needs_mips_plt(true); + mips_sym->set_needs_comp_plt(false); + } + + // Otherwise, if there are no direct calls to the function, we + // have a free choice of whether to use standard or compressed + // entries. Prefer microMIPS entries if the object is known to + // contain microMIPS code, so that it becomes possible to create + // pure microMIPS binaries. Prefer standard entries otherwise, + // because MIPS16 ones are no smaller and are usually slower. + if (!mips_sym->needs_mips_plt() && !mips_sym->needs_comp_plt()) + { + if (this->target_->is_output_micromips()) + mips_sym->set_needs_comp_plt(true); + else + mips_sym->set_needs_mips_plt(true); + } + + if (mips_sym->needs_mips_plt()) + { + mips_sym->set_mips_plt_offset(this->plt_mips_offset_); + this->plt_mips_offset_ += plt_mips_entry_size; + } + if (mips_sym->needs_comp_plt()) + { + mips_sym->set_comp_plt_offset(this->plt_comp_offset_); + this->plt_comp_offset_ += plt_comp_entry_size; + } + } + + // Figure out the size of the PLT header if we know that we are using it. + if (this->plt_mips_offset_ + this->plt_comp_offset_ != 0) + this->plt_header_size_ = this->get_plt_header_size(); +} + +// Write out the PLT. This uses the hand-coded instructions above, +// and adjusts them as needed. + +template<int size, bool big_endian> +void +Mips_output_data_plt<size, big_endian>::do_write(Output_file* of) +{ + const off_t offset = this->offset(); + const section_size_type oview_size = + convert_to_section_size_type(this->data_size()); + unsigned char* const oview = of->get_output_view(offset, oview_size); + + const off_t gotplt_file_offset = this->got_plt_->offset(); + const section_size_type gotplt_size = + convert_to_section_size_type(this->got_plt_->data_size()); + unsigned char* const gotplt_view = of->get_output_view(gotplt_file_offset, + gotplt_size); + unsigned char* pov = oview; + + Mips_address plt_address = this->address(); + + // Calculate the address of .got.plt. + Mips_address gotplt_addr = this->got_plt_->address(); + Mips_address gotplt_addr_high = ((gotplt_addr + 0x8000) >> 16) & 0xffff; + Mips_address gotplt_addr_low = gotplt_addr & 0xffff; + + // The PLT sequence is not safe for N64 if .got.plt's address can + // not be loaded in two instructions. + gold_assert((gotplt_addr & ~(Mips_address) 0x7fffffff) == 0 + || ~(gotplt_addr | 0x7fffffff) == 0); + + // Write the PLT header. + const uint32_t* plt0_entry = this->get_plt_header_entry(); + if (plt0_entry == plt0_entry_micromips_o32) + { + // Write microMIPS PLT header. + gold_assert(gotplt_addr % 4 == 0); + + Mips_address gotpc_offset = gotplt_addr - ((plt_address | 3) ^ 3); + + // ADDIUPC has a span of +/-16MB, check we're in range. + if (gotpc_offset + 0x1000000 >= 0x2000000) + { + gold_error(_(".got.plt offset of %ld from .plt beyond the range of " + "ADDIUPC"), (long)gotpc_offset); + return; + } + + elfcpp::Swap<16, big_endian>::writeval(pov, + plt0_entry[0] | ((gotpc_offset >> 18) & 0x7f)); + elfcpp::Swap<16, big_endian>::writeval(pov + 2, + (gotpc_offset >> 2) & 0xffff); + pov += 4; + for (unsigned int i = 2; + i < (sizeof(plt0_entry_micromips_o32) + / sizeof(plt0_entry_micromips_o32[0])); + i++) + { + elfcpp::Swap<16, big_endian>::writeval(pov, plt0_entry[i]); + pov += 2; + } + } + else if (plt0_entry == plt0_entry_micromips32_o32) + { + // Write microMIPS PLT header in insn32 mode. + elfcpp::Swap<16, big_endian>::writeval(pov, plt0_entry[0]); + elfcpp::Swap<16, big_endian>::writeval(pov + 2, gotplt_addr_high); + elfcpp::Swap<16, big_endian>::writeval(pov + 4, plt0_entry[2]); + elfcpp::Swap<16, big_endian>::writeval(pov + 6, gotplt_addr_low); + elfcpp::Swap<16, big_endian>::writeval(pov + 8, plt0_entry[4]); + elfcpp::Swap<16, big_endian>::writeval(pov + 10, gotplt_addr_low); + pov += 12; + for (unsigned int i = 6; + i < (sizeof(plt0_entry_micromips32_o32) + / sizeof(plt0_entry_micromips32_o32[0])); + i++) + { + elfcpp::Swap<16, big_endian>::writeval(pov, plt0_entry[i]); + pov += 2; + } + } + else + { + // Write standard PLT header. + elfcpp::Swap<32, big_endian>::writeval(pov, + plt0_entry[0] | gotplt_addr_high); + elfcpp::Swap<32, big_endian>::writeval(pov + 4, + plt0_entry[1] | gotplt_addr_low); + elfcpp::Swap<32, big_endian>::writeval(pov + 8, + plt0_entry[2] | gotplt_addr_low); + pov += 12; + for (int i = 3; i < 8; i++) + { + elfcpp::Swap<32, big_endian>::writeval(pov, plt0_entry[i]); + pov += 4; + } + } + + + unsigned char* gotplt_pov = gotplt_view; + unsigned int got_entry_size = size/8; // TODO(sasa): MIPS_ELF_GOT_SIZE + + // The first two entries in .got.plt are reserved. + elfcpp::Swap<size, big_endian>::writeval(gotplt_pov, 0); + elfcpp::Swap<size, big_endian>::writeval(gotplt_pov + got_entry_size, 0); + + unsigned int gotplt_offset = 2 * got_entry_size; + gotplt_pov += 2 * got_entry_size; + + // Calculate the address of the PLT header. + Mips_address header_address = (plt_address + + (this->is_plt_header_compressed() ? 1 : 0)); + + // Initialize compressed PLT area view. + unsigned char* pov2 = pov + this->plt_mips_offset_; + + // Write the PLT entries. + for (typename std::vector<Mips_symbol<size>*>::const_iterator + p = this->symbols_.begin(); + p != this->symbols_.end(); + ++p, gotplt_pov += got_entry_size, gotplt_offset += got_entry_size) + { + Mips_symbol<size>* mips_sym = *p; + + // Calculate the address of the .got.plt entry. + uint32_t gotplt_entry_addr = (gotplt_addr + gotplt_offset); + uint32_t gotplt_entry_addr_hi = (((gotplt_entry_addr + 0x8000) >> 16) + & 0xffff); + uint32_t gotplt_entry_addr_lo = gotplt_entry_addr & 0xffff; + + // Initially point the .got.plt entry at the PLT header. + if (this->target_->is_output_n64()) + elfcpp::Swap<64, big_endian>::writeval(gotplt_pov, header_address); + else + elfcpp::Swap<32, big_endian>::writeval(gotplt_pov, header_address); + + // Now handle the PLT itself. First the standard entry. + if (mips_sym->has_mips_plt_offset()) + { + // Pick the load opcode (LW or LD). + uint64_t load = this->target_->is_output_n64() ? 0xdc000000 + : 0x8c000000; + + // Fill in the PLT entry itself. + elfcpp::Swap<32, big_endian>::writeval(pov, + plt_entry[0] | gotplt_entry_addr_hi); + elfcpp::Swap<32, big_endian>::writeval(pov + 4, + plt_entry[1] | gotplt_entry_addr_lo | load); + elfcpp::Swap<32, big_endian>::writeval(pov + 8, plt_entry[2]); + elfcpp::Swap<32, big_endian>::writeval(pov + 12, + plt_entry[3] | gotplt_entry_addr_lo); + pov += 16; + } + + // Now the compressed entry. They come after any standard ones. + if (mips_sym->has_comp_plt_offset()) + { + if (!this->target_->is_output_micromips()) + { + // Write MIPS16 PLT entry. + const uint32_t* plt_entry = plt_entry_mips16_o32; + + elfcpp::Swap<16, big_endian>::writeval(pov2, plt_entry[0]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 2, plt_entry[1]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 4, plt_entry[2]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 6, plt_entry[3]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 8, plt_entry[4]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 10, plt_entry[5]); + elfcpp::Swap<32, big_endian>::writeval(pov2 + 12, + gotplt_entry_addr); + pov2 += 16; + } + else if (this->target_->use_32bit_micromips_instructions()) + { + // Write microMIPS PLT entry in insn32 mode. + const uint32_t* plt_entry = plt_entry_micromips32_o32; + + elfcpp::Swap<16, big_endian>::writeval(pov2, plt_entry[0]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 2, + gotplt_entry_addr_hi); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 4, plt_entry[2]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 6, + gotplt_entry_addr_lo); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 8, plt_entry[4]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 10, plt_entry[5]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 12, plt_entry[6]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 14, + gotplt_entry_addr_lo); + pov2 += 16; + } + else + { + // Write microMIPS PLT entry. + const uint32_t* plt_entry = plt_entry_micromips_o32; + + gold_assert(gotplt_entry_addr % 4 == 0); + + Mips_address loc_address = plt_address + pov2 - oview; + int gotpc_offset = gotplt_entry_addr - ((loc_address | 3) ^ 3); + + // ADDIUPC has a span of +/-16MB, check we're in range. + if (gotpc_offset + 0x1000000 >= 0x2000000) + { + gold_error(_(".got.plt offset of %ld from .plt beyond the " + "range of ADDIUPC"), (long)gotpc_offset); + return; + } + + elfcpp::Swap<16, big_endian>::writeval(pov2, + plt_entry[0] | ((gotpc_offset >> 18) & 0x7f)); + elfcpp::Swap<16, big_endian>::writeval( + pov2 + 2, (gotpc_offset >> 2) & 0xffff); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 4, plt_entry[2]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 6, plt_entry[3]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 8, plt_entry[4]); + elfcpp::Swap<16, big_endian>::writeval(pov2 + 10, plt_entry[5]); + pov2 += 12; + } + } + } + + // Check the number of bytes written for standard entries. + gold_assert(static_cast<section_size_type>( + pov - oview - this->plt_header_size_) == this->plt_mips_offset_); + // Check the number of bytes written for compressed entries. + gold_assert((static_cast<section_size_type>(pov2 - pov) + == this->plt_comp_offset_)); + // Check the total number of bytes written. + gold_assert(static_cast<section_size_type>(pov2 - oview) == oview_size); + + gold_assert(static_cast<section_size_type>(gotplt_pov - gotplt_view) + == gotplt_size); + + of->write_output_view(offset, oview_size, oview); + of->write_output_view(gotplt_file_offset, gotplt_size, gotplt_view); +} + +// Mips_output_data_mips_stubs methods. + +// The format of the lazy binding stub when dynamic symbol count is less than +// 64K, dynamic symbol index is less than 32K, and ABI is not N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_normal_1[4] = +{ + 0x8f998010, // lw t9,0x8010(gp) + 0x03e07821, // addu t7,ra,zero + 0x0320f809, // jalr t9,ra + 0x24180000 // addiu t8,zero,DYN_INDEX sign extended +}; + +// The format of the lazy binding stub when dynamic symbol count is less than +// 64K, dynamic symbol index is less than 32K, and ABI is N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_normal_1_n64[4] = +{ + 0xdf998010, // ld t9,0x8010(gp) + 0x03e0782d, // daddu t7,ra,zero + 0x0320f809, // jalr t9,ra + 0x64180000 // daddiu t8,zero,DYN_INDEX sign extended +}; + +// The format of the lazy binding stub when dynamic symbol count is less than +// 64K, dynamic symbol index is between 32K and 64K, and ABI is not N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_normal_2[4] = +{ + 0x8f998010, // lw t9,0x8010(gp) + 0x03e07821, // addu t7,ra,zero + 0x0320f809, // jalr t9,ra + 0x34180000 // ori t8,zero,DYN_INDEX unsigned +}; + +// The format of the lazy binding stub when dynamic symbol count is less than +// 64K, dynamic symbol index is between 32K and 64K, and ABI is N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_normal_2_n64[4] = +{ + 0xdf998010, // ld t9,0x8010(gp) + 0x03e0782d, // daddu t7,ra,zero + 0x0320f809, // jalr t9,ra + 0x34180000 // ori t8,zero,DYN_INDEX unsigned +}; + +// The format of the lazy binding stub when dynamic symbol count is greater than +// 64K, and ABI is not N64. +template<int size, bool big_endian> +const uint32_t Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_big[5] = +{ + 0x8f998010, // lw t9,0x8010(gp) + 0x03e07821, // addu t7,ra,zero + 0x3c180000, // lui t8,DYN_INDEX + 0x0320f809, // jalr t9,ra + 0x37180000 // ori t8,t8,DYN_INDEX +}; + +// The format of the lazy binding stub when dynamic symbol count is greater than +// 64K, and ABI is N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_big_n64[5] = +{ + 0xdf998010, // ld t9,0x8010(gp) + 0x03e0782d, // daddu t7,ra,zero + 0x3c180000, // lui t8,DYN_INDEX + 0x0320f809, // jalr t9,ra + 0x37180000 // ori t8,t8,DYN_INDEX +}; + +// microMIPS stubs. + +// The format of the microMIPS lazy binding stub when dynamic symbol count is +// less than 64K, dynamic symbol index is less than 32K, and ABI is not N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_micromips_normal_1[] = +{ + 0xff3c, 0x8010, // lw t9,0x8010(gp) + 0x0dff, // move t7,ra + 0x45d9, // jalr t9 + 0x3300, 0x0000 // addiu t8,zero,DYN_INDEX sign extended +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol count is +// less than 64K, dynamic symbol index is less than 32K, and ABI is N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>:: +lazy_stub_micromips_normal_1_n64[] = +{ + 0xdf3c, 0x8010, // ld t9,0x8010(gp) + 0x0dff, // move t7,ra + 0x45d9, // jalr t9 + 0x5f00, 0x0000 // daddiu t8,zero,DYN_INDEX sign extended +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol +// count is less than 64K, dynamic symbol index is between 32K and 64K, +// and ABI is not N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_micromips_normal_2[] = +{ + 0xff3c, 0x8010, // lw t9,0x8010(gp) + 0x0dff, // move t7,ra + 0x45d9, // jalr t9 + 0x5300, 0x0000 // ori t8,zero,DYN_INDEX unsigned +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol +// count is less than 64K, dynamic symbol index is between 32K and 64K, +// and ABI is N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>:: +lazy_stub_micromips_normal_2_n64[] = +{ + 0xdf3c, 0x8010, // ld t9,0x8010(gp) + 0x0dff, // move t7,ra + 0x45d9, // jalr t9 + 0x5300, 0x0000 // ori t8,zero,DYN_INDEX unsigned +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol count is +// greater than 64K, and ABI is not N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_micromips_big[] = +{ + 0xff3c, 0x8010, // lw t9,0x8010(gp) + 0x0dff, // move t7,ra + 0x41b8, 0x0000, // lui t8,DYN_INDEX + 0x45d9, // jalr t9 + 0x5318, 0x0000 // ori t8,t8,DYN_INDEX +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol count is +// greater than 64K, and ABI is N64. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_micromips_big_n64[] = +{ + 0xdf3c, 0x8010, // ld t9,0x8010(gp) + 0x0dff, // move t7,ra + 0x41b8, 0x0000, // lui t8,DYN_INDEX + 0x45d9, // jalr t9 + 0x5318, 0x0000 // ori t8,t8,DYN_INDEX +}; + +// 32-bit microMIPS stubs. + +// The format of the microMIPS lazy binding stub when dynamic symbol count is +// less than 64K, dynamic symbol index is less than 32K, ABI is not N64, and we +// can use only 32-bit instructions. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>:: +lazy_stub_micromips32_normal_1[] = +{ + 0xff3c, 0x8010, // lw t9,0x8010(gp) + 0x001f, 0x7950, // addu t7,ra,zero + 0x03f9, 0x0f3c, // jalr ra,t9 + 0x3300, 0x0000 // addiu t8,zero,DYN_INDEX sign extended +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol count is +// less than 64K, dynamic symbol index is less than 32K, ABI is N64, and we can +// use only 32-bit instructions. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>:: +lazy_stub_micromips32_normal_1_n64[] = +{ + 0xdf3c, 0x8010, // ld t9,0x8010(gp) + 0x581f, 0x7950, // daddu t7,ra,zero + 0x03f9, 0x0f3c, // jalr ra,t9 + 0x5f00, 0x0000 // daddiu t8,zero,DYN_INDEX sign extended +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol +// count is less than 64K, dynamic symbol index is between 32K and 64K, +// ABI is not N64, and we can use only 32-bit instructions. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>:: +lazy_stub_micromips32_normal_2[] = +{ + 0xff3c, 0x8010, // lw t9,0x8010(gp) + 0x001f, 0x7950, // addu t7,ra,zero + 0x03f9, 0x0f3c, // jalr ra,t9 + 0x5300, 0x0000 // ori t8,zero,DYN_INDEX unsigned +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol +// count is less than 64K, dynamic symbol index is between 32K and 64K, +// ABI is N64, and we can use only 32-bit instructions. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>:: +lazy_stub_micromips32_normal_2_n64[] = +{ + 0xdf3c, 0x8010, // ld t9,0x8010(gp) + 0x581f, 0x7950, // daddu t7,ra,zero + 0x03f9, 0x0f3c, // jalr ra,t9 + 0x5300, 0x0000 // ori t8,zero,DYN_INDEX unsigned +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol count is +// greater than 64K, ABI is not N64, and we can use only 32-bit instructions. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_micromips32_big[] = +{ + 0xff3c, 0x8010, // lw t9,0x8010(gp) + 0x001f, 0x7950, // addu t7,ra,zero + 0x41b8, 0x0000, // lui t8,DYN_INDEX + 0x03f9, 0x0f3c, // jalr ra,t9 + 0x5318, 0x0000 // ori t8,t8,DYN_INDEX +}; + +// The format of the microMIPS lazy binding stub when dynamic symbol count is +// greater than 64K, ABI is N64, and we can use only 32-bit instructions. +template<int size, bool big_endian> +const uint32_t +Mips_output_data_mips_stubs<size, big_endian>::lazy_stub_micromips32_big_n64[] = +{ + 0xdf3c, 0x8010, // ld t9,0x8010(gp) + 0x581f, 0x7950, // daddu t7,ra,zero + 0x41b8, 0x0000, // lui t8,DYN_INDEX + 0x03f9, 0x0f3c, // jalr ra,t9 + 0x5318, 0x0000 // ori t8,t8,DYN_INDEX +}; + +// Create entry for a symbol. + +template<int size, bool big_endian> +void +Mips_output_data_mips_stubs<size, big_endian>::make_entry( + Mips_symbol<size>* gsym) +{ + if (!gsym->has_lazy_stub() && !gsym->has_plt_offset()) + { + this->symbols_.insert(gsym); + gsym->set_has_lazy_stub(true); + } +} + +// Remove entry for a symbol. + +template<int size, bool big_endian> +void +Mips_output_data_mips_stubs<size, big_endian>::remove_entry( + Mips_symbol<size>* gsym) +{ + if (gsym->has_lazy_stub()) + { + this->symbols_.erase(gsym); + gsym->set_has_lazy_stub(false); + } +} + +// Set stub offsets for symbols. This method expects that the number of +// entries in dynamic symbol table is set. + +template<int size, bool big_endian> +void +Mips_output_data_mips_stubs<size, big_endian>::set_lazy_stub_offsets() +{ + gold_assert(this->dynsym_count_ != -1U); + + if (this->stub_offsets_are_set_) + return; + + unsigned int stub_size = this->stub_size(); + unsigned int offset = 0; + for (typename Unordered_set<Mips_symbol<size>*>::const_iterator + p = this->symbols_.begin(); + p != this->symbols_.end(); + ++p, offset += stub_size) + { + Mips_symbol<size>* mips_sym = *p; + mips_sym->set_lazy_stub_offset(offset); + } + this->stub_offsets_are_set_ = true; +} + +template<int size, bool big_endian> +void +Mips_output_data_mips_stubs<size, big_endian>::set_needs_dynsym_value() +{ + for (typename Unordered_set<Mips_symbol<size>*>::const_iterator + p = this->symbols_.begin(); p != this->symbols_.end(); ++p) + { + Mips_symbol<size>* sym = *p; + if (sym->is_from_dynobj()) + sym->set_needs_dynsym_value(); + } +} + +// Write out the .MIPS.stubs. This uses the hand-coded instructions and +// adjusts them as needed. + +template<int size, bool big_endian> +void +Mips_output_data_mips_stubs<size, big_endian>::do_write(Output_file* of) +{ + const off_t offset = this->offset(); + const section_size_type oview_size = + convert_to_section_size_type(this->data_size()); + unsigned char* const oview = of->get_output_view(offset, oview_size); + + bool big_stub = this->dynsym_count_ > 0x10000; + + unsigned char* pov = oview; + for (typename Unordered_set<Mips_symbol<size>*>::const_iterator + p = this->symbols_.begin(); p != this->symbols_.end(); ++p) + { + Mips_symbol<size>* sym = *p; + const uint32_t* lazy_stub; + bool n64 = this->target_->is_output_n64(); + + if (!this->target_->is_output_micromips()) + { + // Write standard (non-microMIPS) stub. + if (!big_stub) + { + if (sym->dynsym_index() & ~0x7fff) + // Dynsym index is between 32K and 64K. + lazy_stub = n64 ? lazy_stub_normal_2_n64 : lazy_stub_normal_2; + else + // Dynsym index is less than 32K. + lazy_stub = n64 ? lazy_stub_normal_1_n64 : lazy_stub_normal_1; + } + else + lazy_stub = n64 ? lazy_stub_big_n64 : lazy_stub_big; + + unsigned int i = 0; + elfcpp::Swap<32, big_endian>::writeval(pov, lazy_stub[i]); + elfcpp::Swap<32, big_endian>::writeval(pov + 4, lazy_stub[i + 1]); + pov += 8; + + i += 2; + if (big_stub) + { + // LUI instruction of the big stub. Paste high 16 bits of the + // dynsym index. + elfcpp::Swap<32, big_endian>::writeval(pov, + lazy_stub[i] | ((sym->dynsym_index() >> 16) & 0x7fff)); + pov += 4; + i += 1; + } + elfcpp::Swap<32, big_endian>::writeval(pov, lazy_stub[i]); + // Last stub instruction. Paste low 16 bits of the dynsym index. + elfcpp::Swap<32, big_endian>::writeval(pov + 4, + lazy_stub[i + 1] | (sym->dynsym_index() & 0xffff)); + pov += 8; + } + else if (this->target_->use_32bit_micromips_instructions()) + { + // Write microMIPS stub in insn32 mode. + if (!big_stub) + { + if (sym->dynsym_index() & ~0x7fff) + // Dynsym index is between 32K and 64K. + lazy_stub = n64 ? lazy_stub_micromips32_normal_2_n64 + : lazy_stub_micromips32_normal_2; + else + // Dynsym index is less than 32K. + lazy_stub = n64 ? lazy_stub_micromips32_normal_1_n64 + : lazy_stub_micromips32_normal_1; + } + else + lazy_stub = n64 ? lazy_stub_micromips32_big_n64 + : lazy_stub_micromips32_big; + + unsigned int i = 0; + // First stub instruction. We emit 32-bit microMIPS instructions by + // emitting two 16-bit parts because on microMIPS the 16-bit part of + // the instruction where the opcode is must always come first, for + // both little and big endian. + elfcpp::Swap<16, big_endian>::writeval(pov, lazy_stub[i]); + elfcpp::Swap<16, big_endian>::writeval(pov + 2, lazy_stub[i + 1]); + // Second stub instruction. + elfcpp::Swap<16, big_endian>::writeval(pov + 4, lazy_stub[i + 2]); + elfcpp::Swap<16, big_endian>::writeval(pov + 6, lazy_stub[i + 3]); + pov += 8; + i += 4; + if (big_stub) + { + // LUI instruction of the big stub. Paste high 16 bits of the + // dynsym index. + elfcpp::Swap<16, big_endian>::writeval(pov, lazy_stub[i]); + elfcpp::Swap<16, big_endian>::writeval(pov + 2, + (sym->dynsym_index() >> 16) & 0x7fff); + pov += 4; + i += 2; + } + elfcpp::Swap<16, big_endian>::writeval(pov, lazy_stub[i]); + elfcpp::Swap<16, big_endian>::writeval(pov + 2, lazy_stub[i + 1]); + // Last stub instruction. Paste low 16 bits of the dynsym index. + elfcpp::Swap<16, big_endian>::writeval(pov + 4, lazy_stub[i + 2]); + elfcpp::Swap<16, big_endian>::writeval(pov + 6, + sym->dynsym_index() & 0xffff); + pov += 8; + } + else + { + // Write microMIPS stub. + if (!big_stub) + { + if (sym->dynsym_index() & ~0x7fff) + // Dynsym index is between 32K and 64K. + lazy_stub = n64 ? lazy_stub_micromips_normal_2_n64 + : lazy_stub_micromips_normal_2; + else + // Dynsym index is less than 32K. + lazy_stub = n64 ? lazy_stub_micromips_normal_1_n64 + : lazy_stub_micromips_normal_1; + } + else + lazy_stub = n64 ? lazy_stub_micromips_big_n64 + : lazy_stub_micromips_big; + + unsigned int i = 0; + // First stub instruction. We emit 32-bit microMIPS instructions by + // emitting two 16-bit parts because on microMIPS the 16-bit part of + // the instruction where the opcode is must always come first, for + // both little and big endian. + elfcpp::Swap<16, big_endian>::writeval(pov, lazy_stub[i]); + elfcpp::Swap<16, big_endian>::writeval(pov + 2, lazy_stub[i + 1]); + // Second stub instruction. + elfcpp::Swap<16, big_endian>::writeval(pov + 4, lazy_stub[i + 2]); + pov += 6; + i += 3; + if (big_stub) + { + // LUI instruction of the big stub. Paste high 16 bits of the + // dynsym index. + elfcpp::Swap<16, big_endian>::writeval(pov, lazy_stub[i]); + elfcpp::Swap<16, big_endian>::writeval(pov + 2, + (sym->dynsym_index() >> 16) & 0x7fff); + pov += 4; + i += 2; + } + elfcpp::Swap<16, big_endian>::writeval(pov, lazy_stub[i]); + // Last stub instruction. Paste low 16 bits of the dynsym index. + elfcpp::Swap<16, big_endian>::writeval(pov + 2, lazy_stub[i + 1]); + elfcpp::Swap<16, big_endian>::writeval(pov + 4, + sym->dynsym_index() & 0xffff); + pov += 6; + } + } + + // We always allocate 20 bytes for every stub, because final dynsym count is + // not known in method do_finalize_sections. There are 4 unused bytes per + // stub if final dynsym count is less than 0x10000. + unsigned int used = pov - oview; + unsigned int unused = big_stub ? 0 : this->symbols_.size() * 4; + gold_assert(static_cast<section_size_type>(used + unused) == oview_size); + + // Fill the unused space with zeroes. + // TODO(sasa): Can we strip unused bytes during the relaxation? + if (unused > 0) + memset(pov, 0, unused); + + of->write_output_view(offset, oview_size, oview); +} + +// Mips_output_section_reginfo methods. + +template<int size, bool big_endian> +void +Mips_output_section_reginfo<size, big_endian>::do_write(Output_file* of) +{ + off_t offset = this->offset(); + off_t data_size = this->data_size(); + + unsigned char* view = of->get_output_view(offset, data_size); + elfcpp::Swap<size, big_endian>::writeval(view, this->gprmask_); + elfcpp::Swap<size, big_endian>::writeval(view + 4, this->cprmask1_); + elfcpp::Swap<size, big_endian>::writeval(view + 8, this->cprmask2_); + elfcpp::Swap<size, big_endian>::writeval(view + 12, this->cprmask3_); + elfcpp::Swap<size, big_endian>::writeval(view + 16, this->cprmask4_); + // Write the gp value. + elfcpp::Swap<size, big_endian>::writeval(view + 20, + this->target_->gp_value()); + + of->write_output_view(offset, data_size, view); +} + +// Mips_copy_relocs methods. + +// Emit any saved relocs. + +template<int sh_type, int size, bool big_endian> +void +Mips_copy_relocs<sh_type, size, big_endian>::emit_mips( + Output_data_reloc<sh_type, true, size, big_endian>* reloc_section, + Symbol_table* symtab, Layout* layout, Target_mips<size, big_endian>* target) +{ + for (typename Copy_relocs<sh_type, size, big_endian>:: + Copy_reloc_entries::iterator p = this->entries_.begin(); + p != this->entries_.end(); + ++p) + emit_entry(*p, reloc_section, symtab, layout, target); + + // We no longer need the saved information. + this->entries_.clear(); +} + +// Emit the reloc if appropriate. + +template<int sh_type, int size, bool big_endian> +void +Mips_copy_relocs<sh_type, size, big_endian>::emit_entry( + Copy_reloc_entry& entry, + Output_data_reloc<sh_type, true, size, big_endian>* reloc_section, + Symbol_table* symtab, Layout* layout, Target_mips<size, big_endian>* target) +{ + // If the symbol is no longer defined in a dynamic object, then we + // emitted a COPY relocation, and we do not want to emit this + // dynamic relocation. + if (!entry.sym_->is_from_dynobj()) + return; + + bool can_make_dynamic = (entry.reloc_type_ == elfcpp::R_MIPS_32 + || entry.reloc_type_ == elfcpp::R_MIPS_REL32 + || entry.reloc_type_ == elfcpp::R_MIPS_64); + + Mips_symbol<size>* sym = Mips_symbol<size>::as_mips_sym(entry.sym_); + if (can_make_dynamic && !sym->has_static_relocs()) + { + Mips_relobj<size, big_endian>* object = + Mips_relobj<size, big_endian>::as_mips_relobj(entry.relobj_); + target->got_section(symtab, layout)->record_global_got_symbol( + sym, object, entry.reloc_type_, true, false); + if (!symbol_references_local(sym, sym->should_add_dynsym_entry(symtab))) + target->rel_dyn_section(layout)->add_global(sym, elfcpp::R_MIPS_REL32, + entry.output_section_, entry.relobj_, entry.shndx_, entry.address_); + else + target->rel_dyn_section(layout)->add_symbolless_global_addend( + sym, elfcpp::R_MIPS_REL32, entry.output_section_, entry.relobj_, + entry.shndx_, entry.address_); + } + else + this->make_copy_reloc(symtab, layout, + static_cast<Sized_symbol<size>*>(entry.sym_), + reloc_section); +} + +// Target_mips methods. + +// Return the value to use for a dynamic symbol which requires special +// treatment. This is how we support equality comparisons of function +// pointers across shared library boundaries, as described in the +// processor specific ABI supplement. + +template<int size, bool big_endian> +uint64_t +Target_mips<size, big_endian>::do_dynsym_value(const Symbol* gsym) const +{ + uint64_t value = 0; + const Mips_symbol<size>* mips_sym = Mips_symbol<size>::as_mips_sym(gsym); + + if (!mips_sym->has_lazy_stub()) + { + if (mips_sym->has_plt_offset()) + { + // We distinguish between PLT entries and lazy-binding stubs by + // giving the former an st_other value of STO_MIPS_PLT. Set the + // value to the stub address if there are any relocations in the + // binary where pointer equality matters. + if (mips_sym->pointer_equality_needed()) + { + // Prefer a standard MIPS PLT entry. + if (mips_sym->has_mips_plt_offset()) + value = this->plt_section()->mips_entry_address(mips_sym); + else + value = this->plt_section()->comp_entry_address(mips_sym) + 1; + } + else + value = 0; + } + } + else + { + // First, set stub offsets for symbols. This method expects that the + // number of entries in dynamic symbol table is set. + this->mips_stubs_section()->set_lazy_stub_offsets(); + + // The run-time linker uses the st_value field of the symbol + // to reset the global offset table entry for this external + // to its stub address when unlinking a shared object. + value = this->mips_stubs_section()->stub_address(mips_sym); + } + + if (mips_sym->has_mips16_fn_stub()) + { + // If we have a MIPS16 function with a stub, the dynamic symbol must + // refer to the stub, since only the stub uses the standard calling + // conventions. + value = mips_sym->template + get_mips16_fn_stub<big_endian>()->output_address(); + } + + return value; +} + +// Get the dynamic reloc section, creating it if necessary. It's always +// .rel.dyn, even for MIPS64. + +template<int size, bool big_endian> +typename Target_mips<size, big_endian>::Reloc_section* +Target_mips<size, big_endian>::rel_dyn_section(Layout* layout) +{ + if (this->rel_dyn_ == NULL) + { + gold_assert(layout != NULL); + this->rel_dyn_ = new Reloc_section(parameters->options().combreloc()); + layout->add_output_section_data(".rel.dyn", elfcpp::SHT_REL, + elfcpp::SHF_ALLOC, this->rel_dyn_, + ORDER_DYNAMIC_RELOCS, false); + + // First entry in .rel.dyn has to be null. + // This is hack - we define dummy output data and set its address to 0, + // and define absolute R_MIPS_NONE relocation with offset 0 against it. + // This ensures that the entry is null. + Output_data* od = new Output_data_zero_fill(0, 0); + od->set_address(0); + this->rel_dyn_->add_absolute(elfcpp::R_MIPS_NONE, od, 0); + } + return this->rel_dyn_; +} + +// Get the GOT section, creating it if necessary. + +template<int size, bool big_endian> +Mips_output_data_got<size, big_endian>* +Target_mips<size, big_endian>::got_section(Symbol_table* symtab, + Layout* layout) +{ + if (this->got_ == NULL) + { + gold_assert(symtab != NULL && layout != NULL); + + this->got_ = new Mips_output_data_got<size, big_endian>(this, symtab, + layout); + layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE | + elfcpp::SHF_MIPS_GPREL), + this->got_, ORDER_DATA, false); + + // Define _GLOBAL_OFFSET_TABLE_ at the start of the .got section. + symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL, + Symbol_table::PREDEFINED, + this->got_, + 0, 0, elfcpp::STT_OBJECT, + elfcpp::STB_GLOBAL, + elfcpp::STV_DEFAULT, 0, + false, false); + } + + return this->got_; +} + +// Calculate value of _gp symbol. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::set_gp(Layout* layout, Symbol_table* symtab) +{ + if (this->gp_ != NULL) + return; + + Output_data* section = layout->find_output_section(".got"); + if (section == NULL) + { + // If there is no .got section, gp should be based on .sdata. + // TODO(sasa): This is probably not needed. This was needed for older + // MIPS architectures which accessed both GOT and .sdata section using + // gp-relative addressing. Modern Mips Linux ELF architectures don't + // access .sdata using gp-relative addressing. + for (Layout::Section_list::const_iterator + p = layout->section_list().begin(); + p != layout->section_list().end(); + ++p) + { + if (strcmp((*p)->name(), ".sdata") == 0) + { + section = *p; + break; + } + } + } + + Sized_symbol<size>* gp = + static_cast<Sized_symbol<size>*>(symtab->lookup("_gp")); + if (gp != NULL) + { + if (gp->source() != Symbol::IS_CONSTANT && section != NULL) + gp->init_output_data(gp->name(), NULL, section, MIPS_GP_OFFSET, 0, + elfcpp::STT_OBJECT, + elfcpp::STB_GLOBAL, + elfcpp::STV_DEFAULT, 0, + false, false); + this->gp_ = gp; + } + else if (section != NULL) + { + gp = static_cast<Sized_symbol<size>*>(symtab->define_in_output_data( + "_gp", NULL, Symbol_table::PREDEFINED, + section, MIPS_GP_OFFSET, 0, + elfcpp::STT_OBJECT, + elfcpp::STB_GLOBAL, + elfcpp::STV_DEFAULT, + 0, false, false)); + this->gp_ = gp; + } +} + +// Set the dynamic symbol indexes. INDEX is the index of the first +// global dynamic symbol. Pointers to the symbols are stored into the +// vector SYMS. The names are added to DYNPOOL. This returns an +// updated dynamic symbol index. + +template<int size, bool big_endian> +unsigned int +Target_mips<size, big_endian>::do_set_dynsym_indexes( + std::vector<Symbol*>* dyn_symbols, unsigned int index, + std::vector<Symbol*>* syms, Stringpool* dynpool, + Versions* versions, Symbol_table* symtab) const +{ + std::vector<Symbol*> non_got_symbols; + std::vector<Symbol*> got_symbols; + + reorder_dyn_symbols<size, big_endian>(dyn_symbols, &non_got_symbols, + &got_symbols); + + for (std::vector<Symbol*>::iterator p = non_got_symbols.begin(); + p != non_got_symbols.end(); + ++p) + { + Symbol* sym = *p; + + // Note that SYM may already have a dynamic symbol index, since + // some symbols appear more than once in the symbol table, with + // and without a version. + + if (!sym->has_dynsym_index()) + { + sym->set_dynsym_index(index); + ++index; + syms->push_back(sym); + dynpool->add(sym->name(), false, NULL); + + // Record any version information. + if (sym->version() != NULL) + versions->record_version(symtab, dynpool, sym); + + // If the symbol is defined in a dynamic object and is + // referenced in a regular object, then mark the dynamic + // object as needed. This is used to implement --as-needed. + if (sym->is_from_dynobj() && sym->in_reg()) + sym->object()->set_is_needed(); + } + } + + for (std::vector<Symbol*>::iterator p = got_symbols.begin(); + p != got_symbols.end(); + ++p) + { + Symbol* sym = *p; + if (!sym->has_dynsym_index()) + { + // Record any version information. + if (sym->version() != NULL) + versions->record_version(symtab, dynpool, sym); + } + } + + index = versions->finalize(symtab, index, syms); + + int got_sym_count = 0; + for (std::vector<Symbol*>::iterator p = got_symbols.begin(); + p != got_symbols.end(); + ++p) + { + Symbol* sym = *p; + + if (!sym->has_dynsym_index()) + { + ++got_sym_count; + sym->set_dynsym_index(index); + ++index; + syms->push_back(sym); + dynpool->add(sym->name(), false, NULL); + + // If the symbol is defined in a dynamic object and is + // referenced in a regular object, then mark the dynamic + // object as needed. This is used to implement --as-needed. + if (sym->is_from_dynobj() && sym->in_reg()) + sym->object()->set_is_needed(); + } + } + + // Set index of the first symbol that has .got entry. + this->got_->set_first_global_got_dynsym_index( + got_sym_count > 0 ? index - got_sym_count : -1U); + + if (this->mips_stubs_ != NULL) + this->mips_stubs_->set_dynsym_count(index); + + return index; +} + +// Create a PLT entry for a global symbol referenced by r_type relocation. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::make_plt_entry(Symbol_table* symtab, + Layout* layout, + Mips_symbol<size>* gsym, + unsigned int r_type) +{ + if (gsym->has_lazy_stub() || gsym->has_plt_offset()) + return; + + if (this->plt_ == NULL) + { + // Create the GOT section first. + this->got_section(symtab, layout); + + this->got_plt_ = new Output_data_space(4, "** GOT PLT"); + layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), + this->got_plt_, ORDER_DATA, false); + + // The first two entries are reserved. + this->got_plt_->set_current_data_size(2 * size/8); + + this->plt_ = new Mips_output_data_plt<size, big_endian>(layout, + this->got_plt_, + this); + layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC + | elfcpp::SHF_EXECINSTR), + this->plt_, ORDER_PLT, false); + } + + this->plt_->add_entry(gsym, r_type); +} + + +// Get the .MIPS.stubs section, creating it if necessary. + +template<int size, bool big_endian> +Mips_output_data_mips_stubs<size, big_endian>* +Target_mips<size, big_endian>::mips_stubs_section(Layout* layout) +{ + if (this->mips_stubs_ == NULL) + { + this->mips_stubs_ = + new Mips_output_data_mips_stubs<size, big_endian>(this); + layout->add_output_section_data(".MIPS.stubs", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC + | elfcpp::SHF_EXECINSTR), + this->mips_stubs_, ORDER_PLT, false); + } + return this->mips_stubs_; +} + +// Get the LA25 stub section, creating it if necessary. + +template<int size, bool big_endian> +Mips_output_data_la25_stub<size, big_endian>* +Target_mips<size, big_endian>::la25_stub_section(Layout* layout) +{ + if (this->la25_stub_ == NULL) + { + this->la25_stub_ = new Mips_output_data_la25_stub<size, big_endian>(); + layout->add_output_section_data(".text", elfcpp::SHT_PROGBITS, + (elfcpp::SHF_ALLOC + | elfcpp::SHF_EXECINSTR), + this->la25_stub_, ORDER_TEXT, false); + } + return this->la25_stub_; +} + +// Process the relocations to determine unreferenced sections for +// garbage collection. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::gc_process_relocs( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols) +{ + typedef Target_mips<size, big_endian> Mips; + typedef typename Target_mips<size, big_endian>::Scan Scan; + + gold::gc_process_relocs<size, big_endian, Mips, elfcpp::SHT_REL, Scan, + typename Target_mips::Relocatable_size_for_reloc>( + symtab, + layout, + this, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols); +} + +// Scan relocations for a section. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::scan_relocs( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols) +{ + typedef Target_mips<size, big_endian> Mips; + typedef typename Target_mips<size, big_endian>::Scan Scan; + + if (sh_type == elfcpp::SHT_REL) + gold::scan_relocs<size, big_endian, Mips, elfcpp::SHT_REL, Scan>( + symtab, + layout, + this, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols); + else if (sh_type == elfcpp::SHT_RELA) + gold::scan_relocs<size, big_endian, Mips, elfcpp::SHT_RELA, Scan>( + symtab, + layout, + this, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols); +} + +template<int size, bool big_endian> +bool +Target_mips<size, big_endian>::mips_32bit_flags(elfcpp::Elf_Word flags) +{ + return ((flags & elfcpp::EF_MIPS_32BITMODE) != 0 + || (flags & elfcpp::EF_MIPS_ABI) == elfcpp::E_MIPS_ABI_O32 + || (flags & elfcpp::EF_MIPS_ABI) == elfcpp::E_MIPS_ABI_EABI32 + || (flags & elfcpp::EF_MIPS_ARCH) == elfcpp::E_MIPS_ARCH_1 + || (flags & elfcpp::EF_MIPS_ARCH) == elfcpp::E_MIPS_ARCH_2 + || (flags & elfcpp::EF_MIPS_ARCH) == elfcpp::E_MIPS_ARCH_32 + || (flags & elfcpp::EF_MIPS_ARCH) == elfcpp::E_MIPS_ARCH_32R2); +} + +// Return the MACH for a MIPS e_flags value. +template<int size, bool big_endian> +unsigned int +Target_mips<size, big_endian>::elf_mips_mach(elfcpp::Elf_Word flags) +{ + switch (flags & elfcpp::EF_MIPS_MACH) + { + case elfcpp::E_MIPS_MACH_3900: + return mach_mips3900; + + case elfcpp::E_MIPS_MACH_4010: + return mach_mips4010; + + case elfcpp::E_MIPS_MACH_4100: + return mach_mips4100; + + case elfcpp::E_MIPS_MACH_4111: + return mach_mips4111; + + case elfcpp::E_MIPS_MACH_4120: + return mach_mips4120; + + case elfcpp::E_MIPS_MACH_4650: + return mach_mips4650; + + case elfcpp::E_MIPS_MACH_5400: + return mach_mips5400; + + case elfcpp::E_MIPS_MACH_5500: + return mach_mips5500; + + case elfcpp::E_MIPS_MACH_9000: + return mach_mips9000; + + case elfcpp::E_MIPS_MACH_SB1: + return mach_mips_sb1; + + case elfcpp::E_MIPS_MACH_LS2E: + return mach_mips_loongson_2e; + + case elfcpp::E_MIPS_MACH_LS2F: + return mach_mips_loongson_2f; + + case elfcpp::E_MIPS_MACH_LS3A: + return mach_mips_loongson_3a; + + case elfcpp::E_MIPS_MACH_OCTEON2: + return mach_mips_octeon2; + + case elfcpp::E_MIPS_MACH_OCTEON: + return mach_mips_octeon; + + case elfcpp::E_MIPS_MACH_XLR: + return mach_mips_xlr; + + default: + switch (flags & elfcpp::EF_MIPS_ARCH) + { + default: + case elfcpp::E_MIPS_ARCH_1: + return mach_mips3000; + + case elfcpp::E_MIPS_ARCH_2: + return mach_mips6000; + + case elfcpp::E_MIPS_ARCH_3: + return mach_mips4000; + + case elfcpp::E_MIPS_ARCH_4: + return mach_mips8000; + + case elfcpp::E_MIPS_ARCH_5: + return mach_mips5; + + case elfcpp::E_MIPS_ARCH_32: + return mach_mipsisa32; + + case elfcpp::E_MIPS_ARCH_64: + return mach_mipsisa64; + + case elfcpp::E_MIPS_ARCH_32R2: + return mach_mipsisa32r2; + + case elfcpp::E_MIPS_ARCH_64R2: + return mach_mipsisa64r2; + } + } + + return 0; +} + +// Check whether machine EXTENSION is an extension of machine BASE. +template<int size, bool big_endian> +bool +Target_mips<size, big_endian>::mips_mach_extends(unsigned int base, + unsigned int extension) +{ + if (extension == base) + return true; + + if ((base == mach_mipsisa32) + && this->mips_mach_extends(mach_mipsisa64, extension)) + return true; + + if ((base == mach_mipsisa32r2) + && this->mips_mach_extends(mach_mipsisa64r2, extension)) + return true; + + for (unsigned int i = 0; i < this->mips_mach_extensions_.size(); ++i) + if (extension == this->mips_mach_extensions_[i].first) + { + extension = this->mips_mach_extensions_[i].second; + if (extension == base) + return true; + } + + return false; +} + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::merge_processor_specific_flags( + const std::string& name, elfcpp::Elf_Word in_flags, + unsigned char in_ei_class, bool dyn_obj) +{ + // If flags are not set yet, just copy them. + if (!this->are_processor_specific_flags_set()) + { + this->set_processor_specific_flags(in_flags); + this->ei_class_ = in_ei_class; + this->mach_ = this->elf_mips_mach(in_flags); + return; + } + + elfcpp::Elf_Word new_flags = in_flags; + elfcpp::Elf_Word old_flags = this->processor_specific_flags(); + elfcpp::Elf_Word merged_flags = this->processor_specific_flags(); + merged_flags |= new_flags & elfcpp::EF_MIPS_NOREORDER; + + // Check flag compatibility. + new_flags &= ~elfcpp::EF_MIPS_NOREORDER; + old_flags &= ~elfcpp::EF_MIPS_NOREORDER; + + // Some IRIX 6 BSD-compatibility objects have this bit set. It + // doesn't seem to matter. + new_flags &= ~elfcpp::EF_MIPS_XGOT; + old_flags &= ~elfcpp::EF_MIPS_XGOT; + + // MIPSpro generates ucode info in n64 objects. Again, we should + // just be able to ignore this. + new_flags &= ~elfcpp::EF_MIPS_UCODE; + old_flags &= ~elfcpp::EF_MIPS_UCODE; + + // DSOs should only be linked with CPIC code. + if (dyn_obj) + new_flags |= elfcpp::EF_MIPS_PIC | elfcpp::EF_MIPS_CPIC; + + if (new_flags == old_flags) + { + this->set_processor_specific_flags(merged_flags); + return; + } + + if (((new_flags & (elfcpp::EF_MIPS_PIC | elfcpp::EF_MIPS_CPIC)) != 0) + != ((old_flags & (elfcpp::EF_MIPS_PIC | elfcpp::EF_MIPS_CPIC)) != 0)) + gold_warning(_("%s: linking abicalls files with non-abicalls files"), + name.c_str()); + + if (new_flags & (elfcpp::EF_MIPS_PIC | elfcpp::EF_MIPS_CPIC)) + merged_flags |= elfcpp::EF_MIPS_CPIC; + if (!(new_flags & elfcpp::EF_MIPS_PIC)) + merged_flags &= ~elfcpp::EF_MIPS_PIC; + + new_flags &= ~(elfcpp::EF_MIPS_PIC | elfcpp::EF_MIPS_CPIC); + old_flags &= ~(elfcpp::EF_MIPS_PIC | elfcpp::EF_MIPS_CPIC); + + // Compare the ISAs. + if (mips_32bit_flags(old_flags) != mips_32bit_flags(new_flags)) + gold_error(_("%s: linking 32-bit code with 64-bit code"), name.c_str()); + else if (!this->mips_mach_extends(this->elf_mips_mach(in_flags), this->mach_)) + { + // Output ISA isn't the same as, or an extension of, input ISA. + if (this->mips_mach_extends(this->mach_, this->elf_mips_mach(in_flags))) + { + // Copy the architecture info from input object to output. Also copy + // the 32-bit flag (if set) so that we continue to recognise + // output as a 32-bit binary. + this->mach_ = this->elf_mips_mach(in_flags); + merged_flags &= ~(elfcpp::EF_MIPS_ARCH | elfcpp::EF_MIPS_MACH); + merged_flags |= (new_flags & (elfcpp::EF_MIPS_ARCH + | elfcpp::EF_MIPS_MACH | elfcpp::EF_MIPS_32BITMODE)); + + // Copy across the ABI flags if output doesn't use them + // and if that was what caused us to treat input object as 32-bit. + if ((old_flags & elfcpp::EF_MIPS_ABI) == 0 + && this->mips_32bit_flags(new_flags) + && !this->mips_32bit_flags(new_flags & ~elfcpp::EF_MIPS_ABI)) + merged_flags |= new_flags & elfcpp::EF_MIPS_ABI; + } + else + // The ISAs aren't compatible. + gold_error(_("%s: linking %s module with previous %s modules"), + name.c_str(), this->elf_mips_mach_name(in_flags), + this->elf_mips_mach_name(merged_flags)); + } + + new_flags &= (~(elfcpp::EF_MIPS_ARCH | elfcpp::EF_MIPS_MACH + | elfcpp::EF_MIPS_32BITMODE)); + old_flags &= (~(elfcpp::EF_MIPS_ARCH | elfcpp::EF_MIPS_MACH + | elfcpp::EF_MIPS_32BITMODE)); + + // Compare ABIs. The 64-bit ABI does not use EF_MIPS_ABI. But, it does set + // EI_CLASS differently from any 32-bit ABI. + if ((new_flags & elfcpp::EF_MIPS_ABI) != (old_flags & elfcpp::EF_MIPS_ABI) + || (in_ei_class != this->ei_class_)) + { + // Only error if both are set (to different values). + if (((new_flags & elfcpp::EF_MIPS_ABI) + && (old_flags & elfcpp::EF_MIPS_ABI)) + || (in_ei_class != this->ei_class_)) + gold_error(_("%s: ABI mismatch: linking %s module with " + "previous %s modules"), name.c_str(), + this->elf_mips_abi_name(in_flags, in_ei_class), + this->elf_mips_abi_name(merged_flags, this->ei_class_)); + + new_flags &= ~elfcpp::EF_MIPS_ABI; + old_flags &= ~elfcpp::EF_MIPS_ABI; + } + + // Compare ASEs. Forbid linking MIPS16 and microMIPS ASE modules together + // and allow arbitrary mixing of the remaining ASEs (retain the union). + if ((new_flags & elfcpp::EF_MIPS_ARCH_ASE) + != (old_flags & elfcpp::EF_MIPS_ARCH_ASE)) + { + int old_micro = old_flags & elfcpp::EF_MIPS_ARCH_ASE_MICROMIPS; + int new_micro = new_flags & elfcpp::EF_MIPS_ARCH_ASE_MICROMIPS; + int old_m16 = old_flags & elfcpp::EF_MIPS_ARCH_ASE_M16; + int new_m16 = new_flags & elfcpp::EF_MIPS_ARCH_ASE_M16; + int micro_mis = old_m16 && new_micro; + int m16_mis = old_micro && new_m16; + + if (m16_mis || micro_mis) + gold_error(_("%s: ASE mismatch: linking %s module with " + "previous %s modules"), name.c_str(), + m16_mis ? "MIPS16" : "microMIPS", + m16_mis ? "microMIPS" : "MIPS16"); + + merged_flags |= new_flags & elfcpp::EF_MIPS_ARCH_ASE; + + new_flags &= ~ elfcpp::EF_MIPS_ARCH_ASE; + old_flags &= ~ elfcpp::EF_MIPS_ARCH_ASE; + } + + // Warn about any other mismatches. + if (new_flags != old_flags) + gold_error(_("%s: uses different e_flags (0x%x) fields than previous " + "modules (0x%x)"), name.c_str(), new_flags, old_flags); + + this->set_processor_specific_flags(merged_flags); +} + +// Adjust ELF file header. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::do_adjust_elf_header( + unsigned char* view, + int len) +{ + gold_assert(len == elfcpp::Elf_sizes<size>::ehdr_size); + + elfcpp::Ehdr<size, big_endian> ehdr(view); + unsigned char e_ident[elfcpp::EI_NIDENT]; + memcpy(e_ident, ehdr.get_e_ident(), elfcpp::EI_NIDENT); + + e_ident[elfcpp::EI_CLASS] = this->ei_class_; + + elfcpp::Ehdr_write<size, big_endian> oehdr(view); + oehdr.put_e_ident(e_ident); + if (this->entry_symbol_is_compressed_) + oehdr.put_e_entry(ehdr.get_e_entry() + 1); +} + +// do_make_elf_object to override the same function in the base class. +// We need to use a target-specific sub-class of +// Sized_relobj_file<size, big_endian> to store Mips specific information. +// Hence we need to have our own ELF object creation. + +template<int size, bool big_endian> +Object* +Target_mips<size, big_endian>::do_make_elf_object( + const std::string& name, + Input_file* input_file, + off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr) +{ + int et = ehdr.get_e_type(); + // ET_EXEC files are valid input for --just-symbols/-R, + // and we treat them as relocatable objects. + if (et == elfcpp::ET_REL + || (et == elfcpp::ET_EXEC && input_file->just_symbols())) + { + Mips_relobj<size, big_endian>* obj = + new Mips_relobj<size, big_endian>(name, input_file, offset, ehdr); + obj->setup(); + return obj; + } + else if (et == elfcpp::ET_DYN) + { + // TODO(sasa): Should we create Mips_dynobj? + return Target::do_make_elf_object(name, input_file, offset, ehdr); + } + else + { + gold_error(_("%s: unsupported ELF file type %d"), + name.c_str(), et); + return NULL; + } +} + +// Finalize the sections. + +template <int size, bool big_endian> +void +Target_mips<size, big_endian>::do_finalize_sections(Layout* layout, + const Input_objects* input_objects, + Symbol_table* symtab) +{ + // Add +1 to MIPS16 and microMIPS init_ and _fini symbols so that DT_INIT and + // DT_FINI have correct values. + Mips_symbol<size>* init = static_cast<Mips_symbol<size>*>( + symtab->lookup(parameters->options().init())); + if (init != NULL && (init->is_mips16() || init->is_micromips())) + init->set_value(init->value() | 1); + Mips_symbol<size>* fini = static_cast<Mips_symbol<size>*>( + symtab->lookup(parameters->options().fini())); + if (fini != NULL && (fini->is_mips16() || fini->is_micromips())) + fini->set_value(fini->value() | 1); + + // Check whether the entry symbol is mips16 or micromips. This is needed to + // adjust entry address in ELF header. + Mips_symbol<size>* entry = + static_cast<Mips_symbol<size>*>(symtab->lookup(this->entry_symbol_name())); + this->entry_symbol_is_compressed_ = (entry != NULL && (entry->is_mips16() + || entry->is_micromips())); + + if (!parameters->doing_static_link() + && (strcmp(parameters->options().hash_style(), "gnu") == 0 + || strcmp(parameters->options().hash_style(), "both") == 0)) + { + // .gnu.hash and the MIPS ABI require .dynsym to be sorted in different + // ways. .gnu.hash needs symbols to be grouped by hash code whereas the + // MIPS ABI requires a mapping between the GOT and the symbol table. + gold_error(".gnu.hash is incompatible with the MIPS ABI"); + } + + // Check whether the final section that was scanned has HI16 or GOT16 + // relocations without the corresponding LO16 part. + if (this->got16_addends_.size() > 0) + gold_error("Can't find matching LO16 reloc"); + + // Set _gp value. + this->set_gp(layout, symtab); + + // Check for any mips16 stub sections that we can discard. + if (!parameters->options().relocatable()) + { + for (Input_objects::Relobj_iterator p = input_objects->relobj_begin(); + p != input_objects->relobj_end(); + ++p) + { + Mips_relobj<size, big_endian>* object = + Mips_relobj<size, big_endian>::as_mips_relobj(*p); + object->discard_mips16_stub_sections(symtab); + } + } + + // Merge processor-specific flags. + for (Input_objects::Relobj_iterator p = input_objects->relobj_begin(); + p != input_objects->relobj_end(); + ++p) + { + Mips_relobj<size, big_endian>* relobj = + Mips_relobj<size, big_endian>::as_mips_relobj(*p); + + Input_file::Format format = relobj->input_file()->format(); + if (format == Input_file::FORMAT_ELF) + { + // Read processor-specific flags in ELF file header. + const unsigned char* pehdr = relobj->get_view( + elfcpp::file_header_offset, + elfcpp::Elf_sizes<size>::ehdr_size, + true, false); + + elfcpp::Ehdr<size, big_endian> ehdr(pehdr); + elfcpp::Elf_Word in_flags = ehdr.get_e_flags(); + unsigned char ei_class = ehdr.get_e_ident()[elfcpp::EI_CLASS]; + + this->merge_processor_specific_flags(relobj->name(), in_flags, + ei_class, false); + } + } + + for (Input_objects::Dynobj_iterator p = input_objects->dynobj_begin(); + p != input_objects->dynobj_end(); + ++p) + { + Sized_dynobj<size, big_endian>* dynobj = + static_cast<Sized_dynobj<size, big_endian>*>(*p); + + // Read processor-specific flags. + const unsigned char* pehdr = dynobj->get_view(elfcpp::file_header_offset, + elfcpp::Elf_sizes<size>::ehdr_size, + true, false); + + elfcpp::Ehdr<size, big_endian> ehdr(pehdr); + elfcpp::Elf_Word in_flags = ehdr.get_e_flags(); + unsigned char ei_class = ehdr.get_e_ident()[elfcpp::EI_CLASS]; + + this->merge_processor_specific_flags(dynobj->name(), in_flags, ei_class, + true); + } + + // Merge .reginfo contents of input objects. + Valtype gprmask = 0; + Valtype cprmask1 = 0; + Valtype cprmask2 = 0; + Valtype cprmask3 = 0; + Valtype cprmask4 = 0; + for (Input_objects::Relobj_iterator p = input_objects->relobj_begin(); + p != input_objects->relobj_end(); + ++p) + { + Mips_relobj<size, big_endian>* relobj = + Mips_relobj<size, big_endian>::as_mips_relobj(*p); + + gprmask |= relobj->gprmask(); + cprmask1 |= relobj->cprmask1(); + cprmask2 |= relobj->cprmask2(); + cprmask3 |= relobj->cprmask3(); + cprmask4 |= relobj->cprmask4(); + } + + if (this->plt_ != NULL) + { + // Set final PLT offsets for symbols. + this->plt_section()->set_plt_offsets(); + + // Define _PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section. + // Set STO_MICROMIPS flag if the output has microMIPS code, but only if + // there are no standard PLT entries present. + unsigned char nonvis = 0; + if (this->is_output_micromips() + && !this->plt_section()->has_standard_entries()) + nonvis = elfcpp::STO_MICROMIPS >> 2; + symtab->define_in_output_data("_PROCEDURE_LINKAGE_TABLE_", NULL, + Symbol_table::PREDEFINED, + this->plt_, + 0, 0, elfcpp::STT_FUNC, + elfcpp::STB_LOCAL, + elfcpp::STV_DEFAULT, nonvis, + false, false); + } + + if (this->mips_stubs_ != NULL) + { + // Define _MIPS_STUBS_ at the start of the .MIPS.stubs section. + unsigned char nonvis = 0; + if (this->is_output_micromips()) + nonvis = elfcpp::STO_MICROMIPS >> 2; + symtab->define_in_output_data("_MIPS_STUBS_", NULL, + Symbol_table::PREDEFINED, + this->mips_stubs_, + 0, 0, elfcpp::STT_FUNC, + elfcpp::STB_LOCAL, + elfcpp::STV_DEFAULT, nonvis, + false, false); + } + + if (!parameters->options().relocatable() && !parameters->doing_static_link()) + // In case there is no .got section, create one. + this->got_section(symtab, layout); + + // Emit any relocs we saved in an attempt to avoid generating COPY + // relocs. + if (this->copy_relocs_.any_saved_relocs()) + this->copy_relocs_.emit_mips(this->rel_dyn_section(layout), symtab, layout, + this); + + // Emit dynamic relocs. + for (typename std::vector<Dyn_reloc>::iterator p = this->dyn_relocs_.begin(); + p != this->dyn_relocs_.end(); + ++p) + p->emit(this->rel_dyn_section(layout), this->got_section(), symtab); + + if (this->has_got_section()) + this->got_section()->lay_out_got(layout, symtab, input_objects); + + if (this->mips_stubs_ != NULL) + this->mips_stubs_->set_needs_dynsym_value(); + + // Check for functions that might need $25 to be valid on entry. + // TODO(sasa): Can we do this without iterating over all symbols? + typedef Symbol_visitor_check_symbols<size, big_endian> Symbol_visitor; + symtab->for_all_symbols<size, Symbol_visitor>(Symbol_visitor(this, layout, + symtab)); + + // Add NULL segment. + if (!parameters->options().relocatable()) + layout->make_output_segment(elfcpp::PT_NULL, 0); + + for (Layout::Section_list::const_iterator p = layout->section_list().begin(); + p != layout->section_list().end(); + ++p) + { + if ((*p)->type() == elfcpp::SHT_MIPS_REGINFO) + { + Mips_output_section_reginfo<size, big_endian>* reginfo = + Mips_output_section_reginfo<size, big_endian>:: + as_mips_output_section_reginfo(*p); + + reginfo->set_masks(gprmask, cprmask1, cprmask2, cprmask3, cprmask4); + + if (!parameters->options().relocatable()) + { + Output_segment* reginfo_segment = + layout->make_output_segment(elfcpp::PT_MIPS_REGINFO, + elfcpp::PF_R); + reginfo_segment->add_output_section_to_nonload(reginfo, + elfcpp::PF_R); + } + } + } + + // Fill in some more dynamic tags. + // TODO(sasa): Add more dynamic tags. + const Reloc_section* rel_plt = (this->plt_ == NULL + ? NULL : this->plt_->rel_plt()); + layout->add_target_dynamic_tags(true, this->got_, rel_plt, + this->rel_dyn_, true, false); + + Output_data_dynamic* const odyn = layout->dynamic_data(); + if (odyn != NULL + && !parameters->options().relocatable() + && !parameters->doing_static_link()) + { + unsigned int d_val; + // This element holds a 32-bit version id for the Runtime + // Linker Interface. This will start at integer value 1. + d_val = 0x01; + odyn->add_constant(elfcpp::DT_MIPS_RLD_VERSION, d_val); + + // Dynamic flags + d_val = elfcpp::RHF_NOTPOT; + odyn->add_constant(elfcpp::DT_MIPS_FLAGS, d_val); + + // Save layout for using when emiting custom dynamic tags. + this->layout_ = layout; + + // This member holds the base address of the segment. + odyn->add_custom(elfcpp::DT_MIPS_BASE_ADDRESS); + + // This member holds the number of entries in the .dynsym section. + odyn->add_custom(elfcpp::DT_MIPS_SYMTABNO); + + // This member holds the index of the first dynamic symbol + // table entry that corresponds to an entry in the global offset table. + odyn->add_custom(elfcpp::DT_MIPS_GOTSYM); + + // This member holds the number of local GOT entries. + odyn->add_constant(elfcpp::DT_MIPS_LOCAL_GOTNO, + this->got_->get_local_gotno()); + + if (this->plt_ != NULL) + // DT_MIPS_PLTGOT dynamic tag + odyn->add_section_address(elfcpp::DT_MIPS_PLTGOT, this->got_plt_); + } + } + +// Get the custom dynamic tag value. +template<int size, bool big_endian> +unsigned int +Target_mips<size, big_endian>::do_dynamic_tag_custom_value(elfcpp::DT tag) const +{ + switch (tag) + { + case elfcpp::DT_MIPS_BASE_ADDRESS: + { + // The base address of the segment. + // At this point, the segment list has been sorted into final order, + // so just return vaddr of the first readable PT_LOAD segment. + Output_segment* seg = + this->layout_->find_output_segment(elfcpp::PT_LOAD, elfcpp::PF_R, 0); + gold_assert(seg != NULL); + return seg->vaddr(); + } + + case elfcpp::DT_MIPS_SYMTABNO: + // The number of entries in the .dynsym section. + return this->get_dt_mips_symtabno(); + + case elfcpp::DT_MIPS_GOTSYM: + { + // The index of the first dynamic symbol table entry that corresponds + // to an entry in the GOT. + if (this->got_->first_global_got_dynsym_index() != -1U) + return this->got_->first_global_got_dynsym_index(); + else + // In case if we don't have global GOT symbols we default to setting + // DT_MIPS_GOTSYM to the same value as DT_MIPS_SYMTABNO. + return this->get_dt_mips_symtabno(); + } + + default: + gold_error(_("Unknown dynamic tag 0x%x"), (unsigned int)tag); + } + + return (unsigned int)-1; +} + +// Relocate section data. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::relocate_section( + const Relocate_info<size, big_endian>* relinfo, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + unsigned char* view, + Mips_address address, + section_size_type view_size, + const Reloc_symbol_changes* reloc_symbol_changes) +{ + typedef Target_mips<size, big_endian> Mips; + typedef typename Target_mips<size, big_endian>::Relocate Mips_relocate; + + if (sh_type == elfcpp::SHT_REL) + gold::relocate_section<size, big_endian, Mips, elfcpp::SHT_REL, + Mips_relocate, gold::Default_comdat_behavior>( + relinfo, + this, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + view, + address, + view_size, + reloc_symbol_changes); + else if (sh_type == elfcpp::SHT_RELA) + gold::relocate_section<size, big_endian, Mips, elfcpp::SHT_RELA, + Mips_relocate, gold::Default_comdat_behavior>( + relinfo, + this, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + view, + address, + view_size, + reloc_symbol_changes); +} + +// Return the size of a relocation while scanning during a relocatable +// link. + +template<int size, bool big_endian> +unsigned int +Target_mips<size, big_endian>::Relocatable_size_for_reloc::get_size_for_reloc( + unsigned int r_type, + Relobj* object) +{ + switch (r_type) + { + case elfcpp::R_MIPS_NONE: + case elfcpp::R_MIPS_TLS_DTPMOD64: + case elfcpp::R_MIPS_TLS_DTPREL64: + case elfcpp::R_MIPS_TLS_TPREL64: + return 0; + + case elfcpp::R_MIPS_32: + case elfcpp::R_MIPS_TLS_DTPMOD32: + case elfcpp::R_MIPS_TLS_DTPREL32: + case elfcpp::R_MIPS_TLS_TPREL32: + case elfcpp::R_MIPS_REL32: + case elfcpp::R_MIPS_PC32: + case elfcpp::R_MIPS_GPREL32: + case elfcpp::R_MIPS_JALR: + return 4; + + case elfcpp::R_MIPS_16: + case elfcpp::R_MIPS_HI16: + case elfcpp::R_MIPS_LO16: + case elfcpp::R_MIPS_GPREL16: + case elfcpp::R_MIPS16_HI16: + case elfcpp::R_MIPS16_LO16: + case elfcpp::R_MIPS_PC16: + case elfcpp::R_MIPS_GOT16: + case elfcpp::R_MIPS16_GOT16: + case elfcpp::R_MIPS_CALL16: + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MIPS_GOT_HI16: + case elfcpp::R_MIPS_CALL_HI16: + case elfcpp::R_MIPS_GOT_LO16: + case elfcpp::R_MIPS_CALL_LO16: + case elfcpp::R_MIPS_TLS_DTPREL_HI16: + case elfcpp::R_MIPS_TLS_DTPREL_LO16: + case elfcpp::R_MIPS_TLS_TPREL_HI16: + case elfcpp::R_MIPS_TLS_TPREL_LO16: + case elfcpp::R_MIPS16_GPREL: + case elfcpp::R_MIPS_GOT_DISP: + case elfcpp::R_MIPS_LITERAL: + case elfcpp::R_MIPS_GOT_PAGE: + case elfcpp::R_MIPS_GOT_OFST: + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS_TLS_GOTTPREL: + return 2; + + // These relocations are not byte sized + case elfcpp::R_MIPS_26: + case elfcpp::R_MIPS16_26: + return 4; + + case elfcpp::R_MIPS_COPY: + case elfcpp::R_MIPS_JUMP_SLOT: + object->error(_("unexpected reloc %u in object file"), r_type); + return 0; + + default: + object->error(_("unsupported reloc %u in object file"), r_type); + return 0; + } +} + +// Scan the relocs during a relocatable link. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::scan_relocatable_relocs( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_symbols, + Relocatable_relocs* rr) +{ + gold_assert(sh_type == elfcpp::SHT_REL); + + typedef Mips_scan_relocatable_relocs<big_endian, elfcpp::SHT_REL, + Relocatable_size_for_reloc> Scan_relocatable_relocs; + + gold::scan_relocatable_relocs<size, big_endian, elfcpp::SHT_REL, + Scan_relocatable_relocs>( + symtab, + layout, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols, + rr); +} + +// Emit relocations for a section. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::relocate_relocs( + const Relocate_info<size, big_endian>* relinfo, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + typename elfcpp::Elf_types<size>::Elf_Off + offset_in_output_section, + const Relocatable_relocs* rr, + unsigned char* view, + Mips_address view_address, + section_size_type view_size, + unsigned char* reloc_view, + section_size_type reloc_view_size) +{ + gold_assert(sh_type == elfcpp::SHT_REL); + + gold::relocate_relocs<size, big_endian, elfcpp::SHT_REL>( + relinfo, + prelocs, + reloc_count, + output_section, + offset_in_output_section, + rr, + view, + view_address, + view_size, + reloc_view, + reloc_view_size); +} + +// Perform target-specific processing in a relocatable link. This is +// only used if we use the relocation strategy RELOC_SPECIAL. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::relocate_special_relocatable( + const Relocate_info<size, big_endian>* relinfo, + unsigned int sh_type, + const unsigned char* preloc_in, + size_t relnum, + Output_section* output_section, + typename elfcpp::Elf_types<size>::Elf_Off offset_in_output_section, + unsigned char* view, + Mips_address view_address, + section_size_type, + unsigned char* preloc_out) +{ + // We can only handle REL type relocation sections. + gold_assert(sh_type == elfcpp::SHT_REL); + + typedef typename Reloc_types<elfcpp::SHT_REL, size, big_endian>::Reloc + Reltype; + typedef typename Reloc_types<elfcpp::SHT_REL, size, big_endian>::Reloc_write + Reltype_write; + + typedef Mips_relocate_functions<size, big_endian> Reloc_funcs; + + const Mips_address invalid_address = static_cast<Mips_address>(0) - 1; + + Mips_relobj<size, big_endian>* object = + Mips_relobj<size, big_endian>::as_mips_relobj(relinfo->object); + const unsigned int local_count = object->local_symbol_count(); + + Reltype reloc(preloc_in); + Reltype_write reloc_write(preloc_out); + + elfcpp::Elf_types<32>::Elf_WXword r_info = reloc.get_r_info(); + const unsigned int r_sym = elfcpp::elf_r_sym<size>(r_info); + const unsigned int r_type = elfcpp::elf_r_type<size>(r_info); + + // Get the new symbol index. + // We only use RELOC_SPECIAL strategy in local relocations. + gold_assert(r_sym < local_count); + + // We are adjusting a section symbol. We need to find + // the symbol table index of the section symbol for + // the output section corresponding to input section + // in which this symbol is defined. + bool is_ordinary; + unsigned int shndx = object->local_symbol_input_shndx(r_sym, &is_ordinary); + gold_assert(is_ordinary); + Output_section* os = object->output_section(shndx); + gold_assert(os != NULL); + gold_assert(os->needs_symtab_index()); + unsigned int new_symndx = os->symtab_index(); + + // Get the new offset--the location in the output section where + // this relocation should be applied. + + Mips_address offset = reloc.get_r_offset(); + Mips_address new_offset; + if (offset_in_output_section != invalid_address) + new_offset = offset + offset_in_output_section; + else + { + section_offset_type sot_offset = + convert_types<section_offset_type, Mips_address>(offset); + section_offset_type new_sot_offset = + output_section->output_offset(object, relinfo->data_shndx, + sot_offset); + gold_assert(new_sot_offset != -1); + new_offset = new_sot_offset; + } + + // In an object file, r_offset is an offset within the section. + // In an executable or dynamic object, generated by + // --emit-relocs, r_offset is an absolute address. + if (!parameters->options().relocatable()) + { + new_offset += view_address; + if (offset_in_output_section != invalid_address) + new_offset -= offset_in_output_section; + } + + reloc_write.put_r_offset(new_offset); + reloc_write.put_r_info(elfcpp::elf_r_info<32>(new_symndx, r_type)); + + // Handle the reloc addend. + // The relocation uses a section symbol in the input file. + // We are adjusting it to use a section symbol in the output + // file. The input section symbol refers to some address in + // the input section. We need the relocation in the output + // file to refer to that same address. This adjustment to + // the addend is the same calculation we use for a simple + // absolute relocation for the input section symbol. + + const Symbol_value<size>* psymval = object->local_symbol(r_sym); + + unsigned char* paddend = view + offset; + typename Reloc_funcs::Status reloc_status = Reloc_funcs::STATUS_OKAY; + switch (r_type) + { + case elfcpp::R_MIPS_26: + reloc_status = Reloc_funcs::rel26(paddend, object, psymval, + offset_in_output_section, true, 0, sh_type == elfcpp::SHT_REL, NULL, + false /*TODO(sasa): cross mode jump*/, r_type, this->jal_to_bal()); + break; + + default: + gold_unreachable(); + } + + // Report any errors. + switch (reloc_status) + { + case Reloc_funcs::STATUS_OKAY: + break; + case Reloc_funcs::STATUS_OVERFLOW: + gold_error_at_location(relinfo, relnum, reloc.get_r_offset(), + _("relocation overflow")); + break; + case Reloc_funcs::STATUS_BAD_RELOC: + gold_error_at_location(relinfo, relnum, reloc.get_r_offset(), + _("unexpected opcode while processing relocation")); + break; + default: + gold_unreachable(); + } +} + +// Optimize the TLS relocation type based on what we know about the +// symbol. IS_FINAL is true if the final address of this symbol is +// known at link time. + +template<int size, bool big_endian> +tls::Tls_optimization +Target_mips<size, big_endian>::optimize_tls_reloc(bool, int) +{ + // FIXME: Currently we do not do any TLS optimization. + return tls::TLSOPT_NONE; +} + +// Scan a relocation for a local symbol. + +template<int size, bool big_endian> +inline void +Target_mips<size, big_endian>::Scan::local( + Symbol_table* symtab, + Layout* layout, + Target_mips<size, big_endian>* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>* rela, + const elfcpp::Rel<size, big_endian>* rel, + unsigned int rel_type, + unsigned int r_type, + const elfcpp::Sym<size, big_endian>& lsym, + bool is_discarded) +{ + if (is_discarded) + return; + + Mips_address r_offset; + typename elfcpp::Elf_types<size>::Elf_WXword r_info; + typename elfcpp::Elf_types<size>::Elf_Swxword r_addend; + + if (rel_type == elfcpp::SHT_RELA) + { + r_offset = rela->get_r_offset(); + r_info = rela->get_r_info(); + r_addend = rela->get_r_addend(); + } + else + { + r_offset = rel->get_r_offset(); + r_info = rel->get_r_info(); + r_addend = 0; + } + + unsigned int r_sym = elfcpp::elf_r_sym<size>(r_info); + Mips_relobj<size, big_endian>* mips_obj = + Mips_relobj<size, big_endian>::as_mips_relobj(object); + + if (mips_obj->is_mips16_stub_section(data_shndx)) + { + mips_obj->get_mips16_stub_section(data_shndx) + ->new_local_reloc_found(r_type, r_sym); + } + + if (r_type == elfcpp::R_MIPS_NONE) + // R_MIPS_NONE is used in mips16 stub sections, to define the target of the + // mips16 stub. + return; + + if (!mips16_call_reloc(r_type) + && !mips_obj->section_allows_mips16_refs(data_shndx)) + // This reloc would need to refer to a MIPS16 hard-float stub, if + // there is one. We ignore MIPS16 stub sections and .pdr section when + // looking for relocs that would need to refer to MIPS16 stubs. + mips_obj->add_local_non_16bit_call(r_sym); + + if (r_type == elfcpp::R_MIPS16_26 + && !mips_obj->section_allows_mips16_refs(data_shndx)) + mips_obj->add_local_16bit_call(r_sym); + + switch (r_type) + { + case elfcpp::R_MIPS_GOT16: + case elfcpp::R_MIPS_CALL16: + case elfcpp::R_MIPS_CALL_HI16: + case elfcpp::R_MIPS_CALL_LO16: + case elfcpp::R_MIPS_GOT_HI16: + case elfcpp::R_MIPS_GOT_LO16: + case elfcpp::R_MIPS_GOT_PAGE: + case elfcpp::R_MIPS_GOT_OFST: + case elfcpp::R_MIPS_GOT_DISP: + case elfcpp::R_MIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS16_GOT16: + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MIPS16_TLS_LDM: + case elfcpp::R_MICROMIPS_GOT16: + case elfcpp::R_MICROMIPS_CALL16: + case elfcpp::R_MICROMIPS_CALL_HI16: + case elfcpp::R_MICROMIPS_CALL_LO16: + case elfcpp::R_MICROMIPS_GOT_HI16: + case elfcpp::R_MICROMIPS_GOT_LO16: + case elfcpp::R_MICROMIPS_GOT_PAGE: + case elfcpp::R_MICROMIPS_GOT_OFST: + case elfcpp::R_MICROMIPS_GOT_DISP: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_LDM: + // We need a GOT section. + target->got_section(symtab, layout); + break; + + default: + break; + } + + if (call_lo16_reloc(r_type) + || got_lo16_reloc(r_type) + || got_disp_reloc(r_type)) + { + // We may need a local GOT entry for this relocation. We + // don't count R_MIPS_GOT_PAGE because we can estimate the + // maximum number of pages needed by looking at the size of + // the segment. Similar comments apply to R_MIPS*_GOT16 and + // R_MIPS*_CALL16. We don't count R_MIPS_GOT_HI16, or + // R_MIPS_CALL_HI16 because these are always followed by an + // R_MIPS_GOT_LO16 or R_MIPS_CALL_LO16. + Mips_output_data_got<size, big_endian>* got = + target->got_section(symtab, layout); + unsigned int r_sym = elfcpp::elf_r_sym<size>(r_info); + got->record_local_got_symbol(mips_obj, r_sym, r_addend, r_type, -1U); + } + + switch (r_type) + { + case elfcpp::R_MIPS_CALL16: + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MICROMIPS_CALL16: + gold_error(_("CALL16 reloc at 0x%lx not against global symbol "), + (unsigned long)r_offset); + return; + + case elfcpp::R_MIPS_GOT_PAGE: + case elfcpp::R_MICROMIPS_GOT_PAGE: + case elfcpp::R_MIPS16_GOT16: + case elfcpp::R_MIPS_GOT16: + case elfcpp::R_MIPS_GOT_HI16: + case elfcpp::R_MIPS_GOT_LO16: + case elfcpp::R_MICROMIPS_GOT16: + case elfcpp::R_MICROMIPS_GOT_HI16: + case elfcpp::R_MICROMIPS_GOT_LO16: + { + // This relocation needs a page entry in the GOT. + // Get the section contents. + section_size_type view_size = 0; + const unsigned char* view = object->section_contents(data_shndx, + &view_size, false); + view += r_offset; + + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(view); + Valtype32 addend = (rel_type == elfcpp::SHT_REL ? val & 0xffff + : r_addend); + + if (rel_type == elfcpp::SHT_REL && got16_reloc(r_type)) + target->got16_addends_.push_back(got16_addend<size, big_endian>( + object, data_shndx, r_type, r_sym, addend)); + else + target->got_section()->record_got_page_entry(mips_obj, r_sym, addend); + break; + } + + case elfcpp::R_MIPS_HI16: + case elfcpp::R_MIPS16_HI16: + case elfcpp::R_MICROMIPS_HI16: + // Record the reloc so that we can check whether the corresponding LO16 + // part exists. + if (rel_type == elfcpp::SHT_REL) + target->got16_addends_.push_back(got16_addend<size, big_endian>( + object, data_shndx, r_type, r_sym, 0)); + break; + + case elfcpp::R_MIPS_LO16: + case elfcpp::R_MIPS16_LO16: + case elfcpp::R_MICROMIPS_LO16: + { + if (rel_type != elfcpp::SHT_REL) + break; + + // Find corresponding GOT16/HI16 relocation. + + // According to the MIPS ELF ABI, the R_MIPS_LO16 relocation must + // be immediately following. However, for the IRIX6 ABI, the next + // relocation may be a composed relocation consisting of several + // relocations for the same address. In that case, the R_MIPS_LO16 + // relocation may occur as one of these. We permit a similar + // extension in general, as that is useful for GCC. + + // In some cases GCC dead code elimination removes the LO16 but + // keeps the corresponding HI16. This is strictly speaking a + // violation of the ABI but not immediately harmful. + + typename std::list<got16_addend<size, big_endian> >::iterator it = + target->got16_addends_.begin(); + while (it != target->got16_addends_.end()) + { + got16_addend<size, big_endian> _got16_addend = *it; + + // TODO(sasa): Split got16_addends_ list into two lists - one for + // GOT16 relocs and the other for HI16 relocs. + + // Report an error if we find HI16 or GOT16 reloc from the + // previous section without the matching LO16 part. + if (_got16_addend.object != object + || _got16_addend.shndx != data_shndx) + { + gold_error("Can't find matching LO16 reloc"); + break; + } + + if (_got16_addend.r_sym != r_sym + || !is_matching_lo16_reloc(_got16_addend.r_type, r_type)) + { + ++it; + continue; + } + + // We found a matching HI16 or GOT16 reloc for this LO16 reloc. + // For GOT16, we need to calculate combined addend and record GOT page + // entry. + if (got16_reloc(_got16_addend.r_type)) + { + + section_size_type view_size = 0; + const unsigned char* view = object->section_contents(data_shndx, + &view_size, + false); + view += r_offset; + + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(view); + int32_t addend = Bits<16>::sign_extend32(val & 0xffff); + + addend = (_got16_addend.addend << 16) + addend; + target->got_section()->record_got_page_entry(mips_obj, r_sym, + addend); + } + + it = target->got16_addends_.erase(it); + } + break; + } + } + + switch (r_type) + { + case elfcpp::R_MIPS_32: + case elfcpp::R_MIPS_REL32: + case elfcpp::R_MIPS_64: + { + if (parameters->options().output_is_position_independent()) + { + // If building a shared library (or a position-independent + // executable), we need to create a dynamic relocation for + // this location. + Reloc_section* rel_dyn = target->rel_dyn_section(layout); + unsigned int r_sym = elfcpp::elf_r_sym<32>(r_info); + rel_dyn->add_symbolless_local_addend(object, r_sym, + elfcpp::R_MIPS_REL32, + output_section, data_shndx, + r_offset); + } + break; + } + + case elfcpp::R_MIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS16_TLS_LDM: + case elfcpp::R_MICROMIPS_TLS_LDM: + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_GD: + { + unsigned int r_sym = elfcpp::elf_r_sym<size>(r_info); + bool output_is_shared = parameters->options().shared(); + const tls::Tls_optimization optimized_type + = Target_mips<size, big_endian>::optimize_tls_reloc( + !output_is_shared, r_type); + switch (r_type) + { + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_GD: + if (optimized_type == tls::TLSOPT_NONE) + { + // Create a pair of GOT entries for the module index and + // dtv-relative offset. + Mips_output_data_got<size, big_endian>* got = + target->got_section(symtab, layout); + unsigned int shndx = lsym.get_st_shndx(); + bool is_ordinary; + shndx = object->adjust_sym_shndx(r_sym, shndx, &is_ordinary); + if (!is_ordinary) + { + object->error(_("local symbol %u has bad shndx %u"), + r_sym, shndx); + break; + } + got->record_local_got_symbol(mips_obj, r_sym, r_addend, r_type, + shndx); + } + else + { + // FIXME: TLS optimization not supported yet. + gold_unreachable(); + } + break; + + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS16_TLS_LDM: + case elfcpp::R_MICROMIPS_TLS_LDM: + if (optimized_type == tls::TLSOPT_NONE) + { + // We always record LDM symbols as local with index 0. + target->got_section()->record_local_got_symbol(mips_obj, 0, + r_addend, r_type, + -1U); + } + else + { + // FIXME: TLS optimization not supported yet. + gold_unreachable(); + } + break; + case elfcpp::R_MIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + layout->set_has_static_tls(); + if (optimized_type == tls::TLSOPT_NONE) + { + // Create a GOT entry for the tp-relative offset. + Mips_output_data_got<size, big_endian>* got = + target->got_section(symtab, layout); + got->record_local_got_symbol(mips_obj, r_sym, r_addend, r_type, + -1U); + } + else + { + // FIXME: TLS optimization not supported yet. + gold_unreachable(); + } + break; + + default: + gold_unreachable(); + } + } + break; + + default: + break; + } + + // Refuse some position-dependent relocations when creating a + // shared library. Do not refuse R_MIPS_32 / R_MIPS_64; they're + // not PIC, but we can create dynamic relocations and the result + // will be fine. Also do not refuse R_MIPS_LO16, which can be + // combined with R_MIPS_GOT16. + if (parameters->options().shared()) + { + switch (r_type) + { + case elfcpp::R_MIPS16_HI16: + case elfcpp::R_MIPS_HI16: + case elfcpp::R_MICROMIPS_HI16: + // Don't refuse a high part relocation if it's against + // no symbol (e.g. part of a compound relocation). + if (r_sym == 0) + break; + + // FALLTHROUGH + + case elfcpp::R_MIPS16_26: + case elfcpp::R_MIPS_26: + case elfcpp::R_MICROMIPS_26_S1: + gold_error(_("%s: relocation %u against `%s' can not be used when " + "making a shared object; recompile with -fPIC"), + object->name().c_str(), r_type, "a local symbol"); + default: + break; + } + } +} + +template<int size, bool big_endian> +inline void +Target_mips<size, big_endian>::Scan::local( + Symbol_table* symtab, + Layout* layout, + Target_mips<size, big_endian>* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rel<size, big_endian>& reloc, + unsigned int r_type, + const elfcpp::Sym<size, big_endian>& lsym, + bool is_discarded) +{ + if (is_discarded) + return; + + local( + symtab, + layout, + target, + object, + data_shndx, + output_section, + (const elfcpp::Rela<size, big_endian>*) NULL, + &reloc, + elfcpp::SHT_REL, + r_type, + lsym, is_discarded); +} + + +template<int size, bool big_endian> +inline void +Target_mips<size, big_endian>::Scan::local( + Symbol_table* symtab, + Layout* layout, + Target_mips<size, big_endian>* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>& reloc, + unsigned int r_type, + const elfcpp::Sym<size, big_endian>& lsym, + bool is_discarded) +{ + if (is_discarded) + return; + + local( + symtab, + layout, + target, + object, + data_shndx, + output_section, + &reloc, + (const elfcpp::Rel<size, big_endian>*) NULL, + elfcpp::SHT_RELA, + r_type, + lsym, is_discarded); +} + +// Scan a relocation for a global symbol. + +template<int size, bool big_endian> +inline void +Target_mips<size, big_endian>::Scan::global( + Symbol_table* symtab, + Layout* layout, + Target_mips<size, big_endian>* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>* rela, + const elfcpp::Rel<size, big_endian>* rel, + unsigned int rel_type, + unsigned int r_type, + Symbol* gsym) +{ + Mips_address r_offset; + typename elfcpp::Elf_types<size>::Elf_WXword r_info; + typename elfcpp::Elf_types<size>::Elf_Swxword r_addend; + + if (rel_type == elfcpp::SHT_RELA) + { + r_offset = rela->get_r_offset(); + r_info = rela->get_r_info(); + r_addend = rela->get_r_addend(); + } + else + { + r_offset = rel->get_r_offset(); + r_info = rel->get_r_info(); + r_addend = 0; + } + + unsigned int r_sym = elfcpp::elf_r_sym<size>(r_info); + Mips_relobj<size, big_endian>* mips_obj = + Mips_relobj<size, big_endian>::as_mips_relobj(object); + Mips_symbol<size>* mips_sym = Mips_symbol<size>::as_mips_sym(gsym); + + if (mips_obj->is_mips16_stub_section(data_shndx)) + { + mips_obj->get_mips16_stub_section(data_shndx) + ->new_global_reloc_found(r_type, mips_sym); + } + + if (r_type == elfcpp::R_MIPS_NONE) + // R_MIPS_NONE is used in mips16 stub sections, to define the target of the + // mips16 stub. + return; + + if (!mips16_call_reloc(r_type) + && !mips_obj->section_allows_mips16_refs(data_shndx)) + // This reloc would need to refer to a MIPS16 hard-float stub, if + // there is one. We ignore MIPS16 stub sections and .pdr section when + // looking for relocs that would need to refer to MIPS16 stubs. + mips_sym->set_need_fn_stub(); + + // A reference to _GLOBAL_OFFSET_TABLE_ implies that we need a got + // section. We check here to avoid creating a dynamic reloc against + // _GLOBAL_OFFSET_TABLE_. + if (!target->has_got_section() + && strcmp(gsym->name(), "_GLOBAL_OFFSET_TABLE_") == 0) + target->got_section(symtab, layout); + + // We need PLT entries if there are static-only relocations against + // an externally-defined function. This can technically occur for + // shared libraries if there are branches to the symbol, although it + // is unlikely that this will be used in practice due to the short + // ranges involved. It can occur for any relative or absolute relocation + // in executables; in that case, the PLT entry becomes the function's + // canonical address. + bool static_reloc = false; + + // Set CAN_MAKE_DYNAMIC to true if we can convert this + // relocation into a dynamic one. + bool can_make_dynamic = false; + switch (r_type) + { + case elfcpp::R_MIPS_GOT16: + case elfcpp::R_MIPS_CALL16: + case elfcpp::R_MIPS_CALL_HI16: + case elfcpp::R_MIPS_CALL_LO16: + case elfcpp::R_MIPS_GOT_HI16: + case elfcpp::R_MIPS_GOT_LO16: + case elfcpp::R_MIPS_GOT_PAGE: + case elfcpp::R_MIPS_GOT_OFST: + case elfcpp::R_MIPS_GOT_DISP: + case elfcpp::R_MIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS16_GOT16: + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MIPS16_TLS_LDM: + case elfcpp::R_MICROMIPS_GOT16: + case elfcpp::R_MICROMIPS_CALL16: + case elfcpp::R_MICROMIPS_CALL_HI16: + case elfcpp::R_MICROMIPS_CALL_LO16: + case elfcpp::R_MICROMIPS_GOT_HI16: + case elfcpp::R_MICROMIPS_GOT_LO16: + case elfcpp::R_MICROMIPS_GOT_PAGE: + case elfcpp::R_MICROMIPS_GOT_OFST: + case elfcpp::R_MICROMIPS_GOT_DISP: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_LDM: + // We need a GOT section. + target->got_section(symtab, layout); + break; + + // This is just a hint; it can safely be ignored. Don't set + // has_static_relocs for the corresponding symbol. + case elfcpp::R_MIPS_JALR: + case elfcpp::R_MICROMIPS_JALR: + break; + + case elfcpp::R_MIPS_GPREL16: + case elfcpp::R_MIPS_GPREL32: + case elfcpp::R_MIPS16_GPREL: + case elfcpp::R_MICROMIPS_GPREL16: + // TODO(sasa) + // GP-relative relocations always resolve to a definition in a + // regular input file, ignoring the one-definition rule. This is + // important for the GP setup sequence in NewABI code, which + // always resolves to a local function even if other relocations + // against the symbol wouldn't. + //constrain_symbol_p = FALSE; + break; + + case elfcpp::R_MIPS_32: + case elfcpp::R_MIPS_REL32: + case elfcpp::R_MIPS_64: + if (parameters->options().shared() + || strcmp(gsym->name(), "__gnu_local_gp") != 0) + { + if (r_type != elfcpp::R_MIPS_REL32) + { + static_reloc = true; + mips_sym->set_pointer_equality_needed(); + } + can_make_dynamic = true; + break; + } + // Fall through. + + default: + // Most static relocations require pointer equality, except + // for branches. + mips_sym->set_pointer_equality_needed(); + + // Fall through. + + case elfcpp::R_MIPS_26: + case elfcpp::R_MIPS_PC16: + case elfcpp::R_MIPS16_26: + case elfcpp::R_MICROMIPS_26_S1: + case elfcpp::R_MICROMIPS_PC7_S1: + case elfcpp::R_MICROMIPS_PC10_S1: + case elfcpp::R_MICROMIPS_PC16_S1: + case elfcpp::R_MICROMIPS_PC23_S2: + static_reloc = true; + mips_sym->set_has_static_relocs(); + break; + } + + // If there are call relocations against an externally-defined symbol, + // see whether we can create a MIPS lazy-binding stub for it. We can + // only do this if all references to the function are through call + // relocations, and in that case, the traditional lazy-binding stubs + // are much more efficient than PLT entries. + switch (r_type) + { + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MIPS_CALL16: + case elfcpp::R_MIPS_CALL_HI16: + case elfcpp::R_MIPS_CALL_LO16: + case elfcpp::R_MIPS_JALR: + case elfcpp::R_MICROMIPS_CALL16: + case elfcpp::R_MICROMIPS_CALL_HI16: + case elfcpp::R_MICROMIPS_CALL_LO16: + case elfcpp::R_MICROMIPS_JALR: + if (!mips_sym->no_lazy_stub()) + { + if ((mips_sym->needs_plt_entry() && mips_sym->is_from_dynobj()) + // Calls from shared objects to undefined symbols of type + // STT_NOTYPE need lazy-binding stub. + || (mips_sym->is_undefined() && parameters->options().shared())) + target->mips_stubs_section(layout)->make_entry(mips_sym); + } + break; + default: + { + // We must not create a stub for a symbol that has relocations + // related to taking the function's address. + mips_sym->set_no_lazy_stub(); + target->remove_lazy_stub_entry(mips_sym); + break; + } + } + + if (relocation_needs_la25_stub<size, big_endian>(mips_obj, r_type, + mips_sym->is_mips16())) + mips_sym->set_has_nonpic_branches(); + + // R_MIPS_HI16 against _gp_disp is used for $gp setup, + // and has a special meaning. + bool gp_disp_against_hi16 = (!mips_obj->is_newabi() + && strcmp(gsym->name(), "_gp_disp") == 0 + && (hi16_reloc(r_type) || lo16_reloc(r_type))); + if (static_reloc && gsym->needs_plt_entry()) + { + target->make_plt_entry(symtab, layout, mips_sym, r_type); + + // Since this is not a PC-relative relocation, we may be + // taking the address of a function. In that case we need to + // set the entry in the dynamic symbol table to the address of + // the PLT entry. + if (gsym->is_from_dynobj() && !parameters->options().shared()) + { + gsym->set_needs_dynsym_value(); + // We distinguish between PLT entries and lazy-binding stubs by + // giving the former an st_other value of STO_MIPS_PLT. Set the + // flag if there are any relocations in the binary where pointer + // equality matters. + if (mips_sym->pointer_equality_needed()) + mips_sym->set_mips_plt(); + } + } + if ((static_reloc || can_make_dynamic) && !gp_disp_against_hi16) + { + // Absolute addressing relocations. + // Make a dynamic relocation if necessary. + if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) + { + if (gsym->may_need_copy_reloc()) + { + target->copy_reloc(symtab, layout, object, + data_shndx, output_section, gsym, *rel); + } + else if (can_make_dynamic) + { + // Create .rel.dyn section. + target->rel_dyn_section(layout); + target->dynamic_reloc(mips_sym, elfcpp::R_MIPS_REL32, mips_obj, + data_shndx, output_section, r_offset); + } + else + gold_error(_("non-dynamic relocations refer to dynamic symbol %s"), + gsym->name()); + } + } + + bool for_call = false; + switch (r_type) + { + case elfcpp::R_MIPS_CALL16: + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MICROMIPS_CALL16: + case elfcpp::R_MIPS_CALL_HI16: + case elfcpp::R_MIPS_CALL_LO16: + case elfcpp::R_MICROMIPS_CALL_HI16: + case elfcpp::R_MICROMIPS_CALL_LO16: + for_call = true; + // Fall through. + + case elfcpp::R_MIPS16_GOT16: + case elfcpp::R_MIPS_GOT16: + case elfcpp::R_MIPS_GOT_HI16: + case elfcpp::R_MIPS_GOT_LO16: + case elfcpp::R_MICROMIPS_GOT16: + case elfcpp::R_MICROMIPS_GOT_HI16: + case elfcpp::R_MICROMIPS_GOT_LO16: + case elfcpp::R_MIPS_GOT_DISP: + case elfcpp::R_MICROMIPS_GOT_DISP: + { + // The symbol requires a GOT entry. + Mips_output_data_got<size, big_endian>* got = + target->got_section(symtab, layout); + got->record_global_got_symbol(mips_sym, mips_obj, r_type, false, + for_call); + mips_sym->set_global_got_area(GGA_NORMAL); + } + break; + + case elfcpp::R_MIPS_GOT_PAGE: + case elfcpp::R_MICROMIPS_GOT_PAGE: + { + // This relocation needs a page entry in the GOT. + // Get the section contents. + section_size_type view_size = 0; + const unsigned char* view = + object->section_contents(data_shndx, &view_size, false); + view += r_offset; + + Valtype32 val = elfcpp::Swap<32, big_endian>::readval(view); + Valtype32 addend = (rel_type == elfcpp::SHT_REL ? val & 0xffff + : r_addend); + Mips_output_data_got<size, big_endian>* got = + target->got_section(symtab, layout); + got->record_got_page_entry(mips_obj, r_sym, addend); + + // If this is a global, overridable symbol, GOT_PAGE will + // decay to GOT_DISP, so we'll need a GOT entry for it. + bool def_regular = (mips_sym->source() == Symbol::FROM_OBJECT + && !mips_sym->object()->is_dynamic() + && !mips_sym->is_undefined()); + if (!def_regular + || (parameters->options().output_is_position_independent() + && !parameters->options().Bsymbolic() + && !mips_sym->is_forced_local())) + { + got->record_global_got_symbol(mips_sym, mips_obj, r_type, false, + for_call); + mips_sym->set_global_got_area(GGA_NORMAL); + } + } + break; + + case elfcpp::R_MIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS16_TLS_LDM: + case elfcpp::R_MICROMIPS_TLS_LDM: + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_GD: + { + const bool is_final = gsym->final_value_is_known(); + const tls::Tls_optimization optimized_type = + Target_mips<size, big_endian>::optimize_tls_reloc(is_final, r_type); + + switch (r_type) + { + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_GD: + if (optimized_type == tls::TLSOPT_NONE) + { + // Create a pair of GOT entries for the module index and + // dtv-relative offset. + Mips_output_data_got<size, big_endian>* got = + target->got_section(symtab, layout); + got->record_global_got_symbol(mips_sym, mips_obj, r_type, false, + false); + } + else + { + // FIXME: TLS optimization not supported yet. + gold_unreachable(); + } + break; + + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS16_TLS_LDM: + case elfcpp::R_MICROMIPS_TLS_LDM: + if (optimized_type == tls::TLSOPT_NONE) + { + // We always record LDM symbols as local with index 0. + target->got_section()->record_local_got_symbol(mips_obj, 0, + r_addend, r_type, + -1U); + } + else + { + // FIXME: TLS optimization not supported yet. + gold_unreachable(); + } + break; + case elfcpp::R_MIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + layout->set_has_static_tls(); + if (optimized_type == tls::TLSOPT_NONE) + { + // Create a GOT entry for the tp-relative offset. + Mips_output_data_got<size, big_endian>* got = + target->got_section(symtab, layout); + got->record_global_got_symbol(mips_sym, mips_obj, r_type, false, + false); + } + else + { + // FIXME: TLS optimization not supported yet. + gold_unreachable(); + } + break; + + default: + gold_unreachable(); + } + } + break; + case elfcpp::R_MIPS_COPY: + case elfcpp::R_MIPS_JUMP_SLOT: + // These are relocations which should only be seen by the + // dynamic linker, and should never be seen here. + gold_error(_("%s: unexpected reloc %u in object file"), + object->name().c_str(), r_type); + break; + + default: + break; + } + + // Refuse some position-dependent relocations when creating a + // shared library. Do not refuse R_MIPS_32 / R_MIPS_64; they're + // not PIC, but we can create dynamic relocations and the result + // will be fine. Also do not refuse R_MIPS_LO16, which can be + // combined with R_MIPS_GOT16. + if (parameters->options().shared()) + { + switch (r_type) + { + case elfcpp::R_MIPS16_HI16: + case elfcpp::R_MIPS_HI16: + case elfcpp::R_MICROMIPS_HI16: + // Don't refuse a high part relocation if it's against + // no symbol (e.g. part of a compound relocation). + if (r_sym == 0) + break; + + // R_MIPS_HI16 against _gp_disp is used for $gp setup, + // and has a special meaning. + if (!mips_obj->is_newabi() && strcmp(gsym->name(), "_gp_disp") == 0) + break; + + // FALLTHROUGH + + case elfcpp::R_MIPS16_26: + case elfcpp::R_MIPS_26: + case elfcpp::R_MICROMIPS_26_S1: + gold_error(_("%s: relocation %u against `%s' can not be used when " + "making a shared object; recompile with -fPIC"), + object->name().c_str(), r_type, gsym->name()); + default: + break; + } + } +} + +template<int size, bool big_endian> +inline void +Target_mips<size, big_endian>::Scan::global( + Symbol_table* symtab, + Layout* layout, + Target_mips<size, big_endian>* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rela<size, big_endian>& reloc, + unsigned int r_type, + Symbol* gsym) +{ + global( + symtab, + layout, + target, + object, + data_shndx, + output_section, + &reloc, + (const elfcpp::Rel<size, big_endian>*) NULL, + elfcpp::SHT_RELA, + r_type, + gsym); +} + +template<int size, bool big_endian> +inline void +Target_mips<size, big_endian>::Scan::global( + Symbol_table* symtab, + Layout* layout, + Target_mips<size, big_endian>* target, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + Output_section* output_section, + const elfcpp::Rel<size, big_endian>& reloc, + unsigned int r_type, + Symbol* gsym) +{ + global( + symtab, + layout, + target, + object, + data_shndx, + output_section, + (const elfcpp::Rela<size, big_endian>*) NULL, + &reloc, + elfcpp::SHT_REL, + r_type, + gsym); +} + +// Return whether a R_MIPS_32 relocation needs to be applied. + +template<int size, bool big_endian> +inline bool +Target_mips<size, big_endian>::Relocate::should_apply_r_mips_32_reloc( + const Mips_symbol<size>* gsym, + unsigned int r_type, + Output_section* output_section, + Target_mips* target) +{ + // If the output section is not allocated, then we didn't call + // scan_relocs, we didn't create a dynamic reloc, and we must apply + // the reloc here. + if ((output_section->flags() & elfcpp::SHF_ALLOC) == 0) + return true; + + if (gsym == NULL) + return true; + else + { + // For global symbols, we use the same helper routines used in the + // scan pass. + if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type)) + && !gsym->may_need_copy_reloc()) + { + // We have generated dynamic reloc (R_MIPS_REL32). + + bool multi_got = false; + if (target->has_got_section()) + multi_got = target->got_section()->multi_got(); + bool has_got_offset; + if (!multi_got) + has_got_offset = gsym->has_got_offset(GOT_TYPE_STANDARD); + else + has_got_offset = gsym->global_gotoffset() != -1U; + if (!has_got_offset) + return true; + else + // Apply the relocation only if the symbol is in the local got. + // Do not apply the relocation if the symbol is in the global + // got. + return symbol_references_local(gsym, gsym->has_dynsym_index()); + } + else + // We have not generated dynamic reloc. + return true; + } +} + +// Perform a relocation. + +template<int size, bool big_endian> +inline bool +Target_mips<size, big_endian>::Relocate::relocate( + const Relocate_info<size, big_endian>* relinfo, + Target_mips* target, + Output_section* output_section, + size_t relnum, + const elfcpp::Rela<size, big_endian>* rela, + const elfcpp::Rel<size, big_endian>* rel, + unsigned int rel_type, + unsigned int r_type, + const Sized_symbol<size>* gsym, + const Symbol_value<size>* psymval, + unsigned char* view, + Mips_address address, + section_size_type) +{ + Mips_address r_offset; + typename elfcpp::Elf_types<size>::Elf_WXword r_info; + typename elfcpp::Elf_types<size>::Elf_Swxword r_addend; + + if (rel_type == elfcpp::SHT_RELA) + { + r_offset = rela->get_r_offset(); + r_info = rela->get_r_info(); + r_addend = rela->get_r_addend(); + } + else + { + r_offset = rel->get_r_offset(); + r_info = rel->get_r_info(); + r_addend = 0; + } + + typedef Mips_relocate_functions<size, big_endian> Reloc_funcs; + typename Reloc_funcs::Status reloc_status = Reloc_funcs::STATUS_OKAY; + + Mips_relobj<size, big_endian>* object = + Mips_relobj<size, big_endian>::as_mips_relobj(relinfo->object); + + unsigned int r_sym = elfcpp::elf_r_sym<size>(r_info); + bool target_is_16_bit_code = false; + bool target_is_micromips_code = false; + bool cross_mode_jump; + + Symbol_value<size> symval; + + const Mips_symbol<size>* mips_sym = Mips_symbol<size>::as_mips_sym(gsym); + + bool changed_symbol_value = false; + if (gsym == NULL) + { + target_is_16_bit_code = object->local_symbol_is_mips16(r_sym); + target_is_micromips_code = object->local_symbol_is_micromips(r_sym); + if (target_is_16_bit_code || target_is_micromips_code) + { + // MIPS16/microMIPS text labels should be treated as odd. + symval.set_output_value(psymval->value(object, 1)); + psymval = &symval; + changed_symbol_value = true; + } + } + else + { + target_is_16_bit_code = mips_sym->is_mips16(); + target_is_micromips_code = mips_sym->is_micromips(); + + // If this is a mips16/microMIPS text symbol, add 1 to the value to make + // it odd. This will cause something like .word SYM to come up with + // the right value when it is loaded into the PC. + + if ((mips_sym->is_mips16() || mips_sym->is_micromips()) + && psymval->value(object, 0) != 0) + { + symval.set_output_value(psymval->value(object, 0) | 1); + psymval = &symval; + changed_symbol_value = true; + } + + // Pick the value to use for symbols defined in shared objects. + if (mips_sym->use_plt_offset(Scan::get_reference_flags(r_type)) + || mips_sym->has_lazy_stub()) + { + Mips_address value; + if (!mips_sym->has_lazy_stub()) + { + // Prefer a standard MIPS PLT entry. + if (mips_sym->has_mips_plt_offset()) + { + value = target->plt_section()->mips_entry_address(mips_sym); + target_is_micromips_code = false; + target_is_16_bit_code = false; + } + else + { + value = (target->plt_section()->comp_entry_address(mips_sym) + + 1); + if (target->is_output_micromips()) + target_is_micromips_code = true; + else + target_is_16_bit_code = true; + } + } + else + value = target->mips_stubs_section()->stub_address(mips_sym); + + symval.set_output_value(value); + psymval = &symval; + } + } + + // TRUE if the symbol referred to by this relocation is "_gp_disp". + // Note that such a symbol must always be a global symbol. + bool gp_disp = (gsym != NULL && (strcmp(gsym->name(), "_gp_disp") == 0) + && !object->is_newabi()); + + // TRUE if the symbol referred to by this relocation is "__gnu_local_gp". + // Note that such a symbol must always be a global symbol. + bool gnu_local_gp = gsym && (strcmp(gsym->name(), "__gnu_local_gp") == 0); + + + if (gp_disp) + { + if (!hi16_reloc(r_type) && !lo16_reloc(r_type)) + gold_error_at_location(relinfo, relnum, r_offset, + _("relocations against _gp_disp are permitted only" + " with R_MIPS_HI16 and R_MIPS_LO16 relocations.")); + } + else if (gnu_local_gp) + { + // __gnu_local_gp is _gp symbol. + symval.set_output_value(target->adjusted_gp_value(object)); + psymval = &symval; + } + + // If this is a reference to a 16-bit function with a stub, we need + // to redirect the relocation to the stub unless: + // + // (a) the relocation is for a MIPS16 JAL; + // + // (b) the relocation is for a MIPS16 PIC call, and there are no + // non-MIPS16 uses of the GOT slot; or + // + // (c) the section allows direct references to MIPS16 functions. + if (r_type != elfcpp::R_MIPS16_26 + && !parameters->options().relocatable() + && ((mips_sym != NULL + && mips_sym->has_mips16_fn_stub() + && (r_type != elfcpp::R_MIPS16_CALL16 || mips_sym->need_fn_stub())) + || (mips_sym == NULL + && object->get_local_mips16_fn_stub(r_sym) != NULL)) + && !object->section_allows_mips16_refs(relinfo->data_shndx)) + { + // This is a 32- or 64-bit call to a 16-bit function. We should + // have already noticed that we were going to need the + // stub. + Mips_address value; + if (mips_sym == NULL) + value = object->get_local_mips16_fn_stub(r_sym)->output_address(); + else + { + gold_assert(mips_sym->need_fn_stub()); + if (mips_sym->has_la25_stub()) + value = target->la25_stub_section()->stub_address(mips_sym); + else + { + value = mips_sym->template + get_mips16_fn_stub<big_endian>()->output_address(); + } + } + symval.set_output_value(value); + psymval = &symval; + changed_symbol_value = true; + + // The target is 16-bit, but the stub isn't. + target_is_16_bit_code = false; + } + // If this is a MIPS16 call with a stub, that is made through the PLT or + // to a standard MIPS function, we need to redirect the call to the stub. + // Note that we specifically exclude R_MIPS16_CALL16 from this behavior; + // indirect calls should use an indirect stub instead. + else if (r_type == elfcpp::R_MIPS16_26 && !parameters->options().relocatable() + && ((mips_sym != NULL + && (mips_sym->has_mips16_call_stub() + || mips_sym->has_mips16_call_fp_stub())) + || (mips_sym == NULL + && object->get_local_mips16_call_stub(r_sym) != NULL)) + && ((mips_sym != NULL && mips_sym->has_plt_offset()) + || !target_is_16_bit_code)) + { + Mips16_stub_section<size, big_endian>* call_stub; + if (mips_sym == NULL) + call_stub = object->get_local_mips16_call_stub(r_sym); + else + { + // If both call_stub and call_fp_stub are defined, we can figure + // out which one to use by checking which one appears in the input + // file. + if (mips_sym->has_mips16_call_stub() + && mips_sym->has_mips16_call_fp_stub()) + { + call_stub = NULL; + for (unsigned int i = 1; i < object->shnum(); ++i) + { + if (object->is_mips16_call_fp_stub_section(i)) + { + call_stub = mips_sym->template + get_mips16_call_fp_stub<big_endian>(); + break; + } + + } + if (call_stub == NULL) + call_stub = + mips_sym->template get_mips16_call_stub<big_endian>(); + } + else if (mips_sym->has_mips16_call_stub()) + call_stub = mips_sym->template get_mips16_call_stub<big_endian>(); + else + call_stub = mips_sym->template get_mips16_call_fp_stub<big_endian>(); + } + + symval.set_output_value(call_stub->output_address()); + psymval = &symval; + changed_symbol_value = true; + } + // If this is a direct call to a PIC function, redirect to the + // non-PIC stub. + else if (mips_sym != NULL + && mips_sym->has_la25_stub() + && relocation_needs_la25_stub<size, big_endian>( + object, r_type, target_is_16_bit_code)) + { + Mips_address value = target->la25_stub_section()->stub_address(mips_sym); + if (mips_sym->is_micromips()) + value += 1; + symval.set_output_value(value); + psymval = &symval; + } + // For direct MIPS16 and microMIPS calls make sure the compressed PLT + // entry is used if a standard PLT entry has also been made. + else if ((r_type == elfcpp::R_MIPS16_26 + || r_type == elfcpp::R_MICROMIPS_26_S1) + && !parameters->options().relocatable() + && mips_sym != NULL + && mips_sym->has_plt_offset() + && mips_sym->has_comp_plt_offset() + && mips_sym->has_mips_plt_offset()) + { + Mips_address value = (target->plt_section()->comp_entry_address(mips_sym) + + 1); + symval.set_output_value(value); + psymval = &symval; + + target_is_16_bit_code = !target->is_output_micromips(); + target_is_micromips_code = target->is_output_micromips(); + } + + // Make sure MIPS16 and microMIPS are not used together. + if ((r_type == elfcpp::R_MIPS16_26 && target_is_micromips_code) + || (micromips_branch_reloc(r_type) && target_is_16_bit_code)) + { + gold_error(_("MIPS16 and microMIPS functions cannot call each other")); + } + + // Calls from 16-bit code to 32-bit code and vice versa require the + // mode change. However, we can ignore calls to undefined weak symbols, + // which should never be executed at runtime. This exception is important + // because the assembly writer may have "known" that any definition of the + // symbol would be 16-bit code, and that direct jumps were therefore + // acceptable. + cross_mode_jump = + (!parameters->options().relocatable() + && !(gsym != NULL && gsym->is_weak_undefined()) + && ((r_type == elfcpp::R_MIPS16_26 && !target_is_16_bit_code) + || (r_type == elfcpp::R_MICROMIPS_26_S1 && !target_is_micromips_code) + || ((r_type == elfcpp::R_MIPS_26 || r_type == elfcpp::R_MIPS_JALR) + && (target_is_16_bit_code || target_is_micromips_code)))); + + bool local = (mips_sym == NULL + || (mips_sym->got_only_for_calls() + ? symbol_calls_local(mips_sym, mips_sym->has_dynsym_index()) + : symbol_references_local(mips_sym, + mips_sym->has_dynsym_index()))); + + // Global R_MIPS_GOT_PAGE/R_MICROMIPS_GOT_PAGE relocations are equivalent + // to R_MIPS_GOT_DISP/R_MICROMIPS_GOT_DISP. The addend is applied by the + // corresponding R_MIPS_GOT_OFST/R_MICROMIPS_GOT_OFST. + if (got_page_reloc(r_type) && !local) + r_type = (micromips_reloc(r_type) ? elfcpp::R_MICROMIPS_GOT_DISP + : elfcpp::R_MIPS_GOT_DISP); + + unsigned int got_offset = 0; + int gp_offset = 0; + + bool update_got_entry = false; + bool extract_addend = rel_type == elfcpp::SHT_REL; + switch (r_type) + { + case elfcpp::R_MIPS_NONE: + break; + case elfcpp::R_MIPS_16: + reloc_status = Reloc_funcs::rel16(view, object, psymval, r_addend, + extract_addend, r_type); + break; + + case elfcpp::R_MIPS_32: + if (should_apply_r_mips_32_reloc(mips_sym, r_type, output_section, + target)) + reloc_status = Reloc_funcs::rel32(view, object, psymval, r_addend, + extract_addend, r_type); + if (mips_sym != NULL + && (mips_sym->is_mips16() || mips_sym->is_micromips()) + && mips_sym->global_got_area() == GGA_RELOC_ONLY) + { + // If mips_sym->has_mips16_fn_stub() is false, symbol value is + // already updated by adding +1. + if (mips_sym->has_mips16_fn_stub()) + { + gold_assert(mips_sym->need_fn_stub()); + Mips16_stub_section<size, big_endian>* fn_stub = + mips_sym->template get_mips16_fn_stub<big_endian>(); + + symval.set_output_value(fn_stub->output_address()); + psymval = &symval; + } + got_offset = mips_sym->global_gotoffset(); + update_got_entry = true; + } + break; + + case elfcpp::R_MIPS_REL32: + gold_unreachable(); + + case elfcpp::R_MIPS_PC32: + reloc_status = Reloc_funcs::relpc32(view, object, psymval, address, + r_addend, extract_addend, r_type); + break; + + case elfcpp::R_MIPS16_26: + // The calculation for R_MIPS16_26 is just the same as for an + // R_MIPS_26. It's only the storage of the relocated field into + // the output file that's different. So, we just fall through to the + // R_MIPS_26 case here. + case elfcpp::R_MIPS_26: + case elfcpp::R_MICROMIPS_26_S1: + reloc_status = Reloc_funcs::rel26(view, object, psymval, address, + gsym == NULL, r_addend, extract_addend, gsym, cross_mode_jump, r_type, + target->jal_to_bal()); + break; + + case elfcpp::R_MIPS_HI16: + case elfcpp::R_MIPS16_HI16: + case elfcpp::R_MICROMIPS_HI16: + reloc_status = Reloc_funcs::relhi16(view, object, psymval, r_addend, + address, gp_disp, r_type, + extract_addend); + break; + + case elfcpp::R_MIPS_LO16: + case elfcpp::R_MIPS16_LO16: + case elfcpp::R_MICROMIPS_LO16: + case elfcpp::R_MICROMIPS_HI0_LO16: + reloc_status = Reloc_funcs::rello16(target, view, object, psymval, + r_addend, extract_addend, address, + gp_disp, r_type); + break; + + case elfcpp::R_MIPS_LITERAL: + case elfcpp::R_MICROMIPS_LITERAL: + // Because we don't merge literal sections, we can handle this + // just like R_MIPS_GPREL16. In the long run, we should merge + // shared literals, and then we will need to additional work + // here. + + // Fall through. + + case elfcpp::R_MIPS_GPREL16: + case elfcpp::R_MIPS16_GPREL: + case elfcpp::R_MICROMIPS_GPREL7_S2: + case elfcpp::R_MICROMIPS_GPREL16: + reloc_status = Reloc_funcs::relgprel(view, object, psymval, + target->adjusted_gp_value(object), + r_addend, extract_addend, + gsym == NULL, r_type); + break; + + case elfcpp::R_MIPS_PC16: + reloc_status = Reloc_funcs::relpc16(view, object, psymval, address, + r_addend, extract_addend, r_type); + break; + case elfcpp::R_MICROMIPS_PC7_S1: + reloc_status = Reloc_funcs::relmicromips_pc7_s1(view, object, psymval, + address, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MICROMIPS_PC10_S1: + reloc_status = Reloc_funcs::relmicromips_pc10_s1(view, object, psymval, + address, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MICROMIPS_PC16_S1: + reloc_status = Reloc_funcs::relmicromips_pc16_s1(view, object, psymval, + address, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MIPS_GPREL32: + reloc_status = Reloc_funcs::relgprel32(view, object, psymval, + target->adjusted_gp_value(object), + r_addend, extract_addend, r_type); + break; + case elfcpp::R_MIPS_GOT_HI16: + case elfcpp::R_MIPS_CALL_HI16: + case elfcpp::R_MICROMIPS_GOT_HI16: + case elfcpp::R_MICROMIPS_CALL_HI16: + if (gsym != NULL) + got_offset = target->got_section()->got_offset(gsym, GOT_TYPE_STANDARD, + object); + else + got_offset = target->got_section()->got_offset(r_sym, GOT_TYPE_STANDARD, + object); + gp_offset = target->got_section()->gp_offset(got_offset, object); + reloc_status = Reloc_funcs::relgot_hi16(view, gp_offset, r_type); + update_got_entry = changed_symbol_value; + break; + + case elfcpp::R_MIPS_GOT_LO16: + case elfcpp::R_MIPS_CALL_LO16: + case elfcpp::R_MICROMIPS_GOT_LO16: + case elfcpp::R_MICROMIPS_CALL_LO16: + if (gsym != NULL) + got_offset = target->got_section()->got_offset(gsym, GOT_TYPE_STANDARD, + object); + else + got_offset = target->got_section()->got_offset(r_sym, GOT_TYPE_STANDARD, + object); + gp_offset = target->got_section()->gp_offset(got_offset, object); + reloc_status = Reloc_funcs::relgot_lo16(view, gp_offset, r_type); + update_got_entry = changed_symbol_value; + break; + + case elfcpp::R_MIPS_GOT_DISP: + case elfcpp::R_MICROMIPS_GOT_DISP: + if (gsym != NULL) + got_offset = target->got_section()->got_offset(gsym, GOT_TYPE_STANDARD, + object); + else + got_offset = target->got_section()->got_offset(r_sym, GOT_TYPE_STANDARD, + object); + gp_offset = target->got_section()->gp_offset(got_offset, object); + reloc_status = Reloc_funcs::relgot(view, gp_offset, r_type); + break; + + case elfcpp::R_MIPS_CALL16: + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MICROMIPS_CALL16: + gold_assert(gsym != NULL); + got_offset = target->got_section()->got_offset(gsym, GOT_TYPE_STANDARD, + object); + gp_offset = target->got_section()->gp_offset(got_offset, object); + reloc_status = Reloc_funcs::relgot(view, gp_offset, r_type); + // TODO(sasa): We should also initialize update_got_entry in other places + // where relgot is called. + update_got_entry = changed_symbol_value; + break; + + case elfcpp::R_MIPS_GOT16: + case elfcpp::R_MIPS16_GOT16: + case elfcpp::R_MICROMIPS_GOT16: + if (gsym != NULL) + { + got_offset = target->got_section()->got_offset(gsym, + GOT_TYPE_STANDARD, + object); + gp_offset = target->got_section()->gp_offset(got_offset, object); + reloc_status = Reloc_funcs::relgot(view, gp_offset, r_type); + } + else + reloc_status = Reloc_funcs::relgot16_local(view, object, psymval, + r_addend, extract_addend, + r_type); + update_got_entry = changed_symbol_value; + break; + + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_GD: + if (gsym != NULL) + got_offset = target->got_section()->got_offset(gsym, GOT_TYPE_TLS_PAIR, + object); + else + got_offset = target->got_section()->got_offset(r_sym, GOT_TYPE_TLS_PAIR, + object); + gp_offset = target->got_section()->gp_offset(got_offset, object); + reloc_status = Reloc_funcs::relgot(view, gp_offset, r_type); + break; + + case elfcpp::R_MIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + if (gsym != NULL) + got_offset = target->got_section()->got_offset(gsym, + GOT_TYPE_TLS_OFFSET, + object); + else + got_offset = target->got_section()->got_offset(r_sym, + GOT_TYPE_TLS_OFFSET, + object); + gp_offset = target->got_section()->gp_offset(got_offset, object); + reloc_status = Reloc_funcs::relgot(view, gp_offset, r_type); + break; + + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS16_TLS_LDM: + case elfcpp::R_MICROMIPS_TLS_LDM: + // Relocate the field with the offset of the GOT entry for + // the module index. + got_offset = target->got_section()->tls_ldm_offset(object); + gp_offset = target->got_section()->gp_offset(got_offset, object); + reloc_status = Reloc_funcs::relgot(view, gp_offset, r_type); + break; + + case elfcpp::R_MIPS_GOT_PAGE: + case elfcpp::R_MICROMIPS_GOT_PAGE: + reloc_status = Reloc_funcs::relgotpage(target, view, object, psymval, + r_addend, extract_addend, r_type); + break; + + case elfcpp::R_MIPS_GOT_OFST: + case elfcpp::R_MICROMIPS_GOT_OFST: + reloc_status = Reloc_funcs::relgotofst(target, view, object, psymval, + r_addend, extract_addend, local, + r_type); + break; + + case elfcpp::R_MIPS_JALR: + case elfcpp::R_MICROMIPS_JALR: + // This relocation is only a hint. In some cases, we optimize + // it into a bal instruction. But we don't try to optimize + // when the symbol does not resolve locally. + if (gsym == NULL || symbol_calls_local(gsym, gsym->has_dynsym_index())) + reloc_status = Reloc_funcs::reljalr(view, object, psymval, address, + r_addend, extract_addend, + cross_mode_jump, r_type, + target->jalr_to_bal(), + target->jr_to_b()); + break; + + case elfcpp::R_MIPS_TLS_DTPREL_HI16: + case elfcpp::R_MIPS16_TLS_DTPREL_HI16: + case elfcpp::R_MICROMIPS_TLS_DTPREL_HI16: + reloc_status = Reloc_funcs::tlsrelhi16(view, object, psymval, + elfcpp::DTP_OFFSET, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MIPS_TLS_DTPREL_LO16: + case elfcpp::R_MIPS16_TLS_DTPREL_LO16: + case elfcpp::R_MICROMIPS_TLS_DTPREL_LO16: + reloc_status = Reloc_funcs::tlsrello16(view, object, psymval, + elfcpp::DTP_OFFSET, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MIPS_TLS_DTPREL32: + case elfcpp::R_MIPS_TLS_DTPREL64: + reloc_status = Reloc_funcs::tlsrel32(view, object, psymval, + elfcpp::DTP_OFFSET, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MIPS_TLS_TPREL_HI16: + case elfcpp::R_MIPS16_TLS_TPREL_HI16: + case elfcpp::R_MICROMIPS_TLS_TPREL_HI16: + reloc_status = Reloc_funcs::tlsrelhi16(view, object, psymval, + elfcpp::TP_OFFSET, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MIPS_TLS_TPREL_LO16: + case elfcpp::R_MIPS16_TLS_TPREL_LO16: + case elfcpp::R_MICROMIPS_TLS_TPREL_LO16: + reloc_status = Reloc_funcs::tlsrello16(view, object, psymval, + elfcpp::TP_OFFSET, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MIPS_TLS_TPREL32: + case elfcpp::R_MIPS_TLS_TPREL64: + reloc_status = Reloc_funcs::tlsrel32(view, object, psymval, + elfcpp::TP_OFFSET, r_addend, + extract_addend, r_type); + break; + case elfcpp::R_MIPS_SUB: + case elfcpp::R_MICROMIPS_SUB: + reloc_status = Reloc_funcs::relsub(view, object, psymval, r_addend, + extract_addend, r_type); + break; + default: + gold_error_at_location(relinfo, relnum, r_offset, + _("unsupported reloc %u"), r_type); + break; + } + + if (update_got_entry) + { + Mips_output_data_got<size, big_endian>* got = target->got_section(); + if (mips_sym != NULL && mips_sym->get_applied_secondary_got_fixup()) + got->update_got_entry(got->get_primary_got_offset(mips_sym), + psymval->value(object, 0)); + else + got->update_got_entry(got_offset, psymval->value(object, 0)); + } + + // Report any errors. + switch (reloc_status) + { + case Reloc_funcs::STATUS_OKAY: + break; + case Reloc_funcs::STATUS_OVERFLOW: + gold_error_at_location(relinfo, relnum, r_offset, + _("relocation overflow")); + break; + case Reloc_funcs::STATUS_BAD_RELOC: + gold_error_at_location(relinfo, relnum, r_offset, + _("unexpected opcode while processing relocation")); + break; + default: + gold_unreachable(); + } + + return true; +} + +template<int size, bool big_endian> +inline bool +Target_mips<size, big_endian>::Relocate::relocate( + const Relocate_info<size, big_endian>* relinfo, + Target_mips* target, + Output_section* output_section, + size_t relnum, + const elfcpp::Rela<size, big_endian>& reloc, + unsigned int r_type, + const Sized_symbol<size>* gsym, + const Symbol_value<size>* psymval, + unsigned char* view, + Mips_address address, + section_size_type view_size) +{ + return relocate( + relinfo, + target, + output_section, + relnum, + &reloc, + (const elfcpp::Rel<size, big_endian>*) NULL, + elfcpp::SHT_RELA, + r_type, + gsym, + psymval, + view, + address, + view_size); +} + +template<int size, bool big_endian> +inline bool +Target_mips<size, big_endian>::Relocate::relocate( + const Relocate_info<size, big_endian>* relinfo, + Target_mips* target, + Output_section* output_section, + size_t relnum, + const elfcpp::Rel<size, big_endian>& reloc, + unsigned int r_type, + const Sized_symbol<size>* gsym, + const Symbol_value<size>* psymval, + unsigned char* view, + Mips_address address, + section_size_type view_size) +{ + return relocate( + relinfo, + target, + output_section, + relnum, + (const elfcpp::Rela<size, big_endian>*) NULL, + &reloc, + elfcpp::SHT_REL, + r_type, + gsym, + psymval, + view, + address, + view_size); +} + +// Get the Reference_flags for a particular relocation. + +template<int size, bool big_endian> +int +Target_mips<size, big_endian>::Scan::get_reference_flags( + unsigned int r_type) +{ + switch (r_type) + { + case elfcpp::R_MIPS_NONE: + // No symbol reference. + return 0; + + case elfcpp::R_MIPS_16: + case elfcpp::R_MIPS_32: + case elfcpp::R_MIPS_64: + case elfcpp::R_MIPS_HI16: + case elfcpp::R_MIPS_LO16: + case elfcpp::R_MIPS16_HI16: + case elfcpp::R_MIPS16_LO16: + case elfcpp::R_MICROMIPS_HI16: + case elfcpp::R_MICROMIPS_LO16: + return Symbol::ABSOLUTE_REF; + + case elfcpp::R_MIPS_26: + case elfcpp::R_MIPS16_26: + case elfcpp::R_MICROMIPS_26_S1: + return Symbol::FUNCTION_CALL | Symbol::ABSOLUTE_REF; + + case elfcpp::R_MIPS_GPREL32: + case elfcpp::R_MIPS_GPREL16: + case elfcpp::R_MIPS_REL32: + case elfcpp::R_MIPS16_GPREL: + return Symbol::RELATIVE_REF; + + case elfcpp::R_MIPS_PC16: + case elfcpp::R_MIPS_PC32: + case elfcpp::R_MIPS_JALR: + case elfcpp::R_MICROMIPS_JALR: + return Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; + + case elfcpp::R_MIPS_GOT16: + case elfcpp::R_MIPS_CALL16: + case elfcpp::R_MIPS_GOT_DISP: + case elfcpp::R_MIPS_GOT_HI16: + case elfcpp::R_MIPS_GOT_LO16: + case elfcpp::R_MIPS_CALL_HI16: + case elfcpp::R_MIPS_CALL_LO16: + case elfcpp::R_MIPS_LITERAL: + case elfcpp::R_MIPS_GOT_PAGE: + case elfcpp::R_MIPS_GOT_OFST: + case elfcpp::R_MIPS16_GOT16: + case elfcpp::R_MIPS16_CALL16: + case elfcpp::R_MICROMIPS_GOT16: + case elfcpp::R_MICROMIPS_CALL16: + case elfcpp::R_MICROMIPS_GOT_HI16: + case elfcpp::R_MICROMIPS_GOT_LO16: + case elfcpp::R_MICROMIPS_CALL_HI16: + case elfcpp::R_MICROMIPS_CALL_LO16: + // Absolute in GOT. + return Symbol::RELATIVE_REF; + + case elfcpp::R_MIPS_TLS_DTPMOD32: + case elfcpp::R_MIPS_TLS_DTPREL32: + case elfcpp::R_MIPS_TLS_DTPMOD64: + case elfcpp::R_MIPS_TLS_DTPREL64: + case elfcpp::R_MIPS_TLS_GD: + case elfcpp::R_MIPS_TLS_LDM: + case elfcpp::R_MIPS_TLS_DTPREL_HI16: + case elfcpp::R_MIPS_TLS_DTPREL_LO16: + case elfcpp::R_MIPS_TLS_GOTTPREL: + case elfcpp::R_MIPS_TLS_TPREL32: + case elfcpp::R_MIPS_TLS_TPREL64: + case elfcpp::R_MIPS_TLS_TPREL_HI16: + case elfcpp::R_MIPS_TLS_TPREL_LO16: + case elfcpp::R_MIPS16_TLS_GD: + case elfcpp::R_MIPS16_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_GD: + case elfcpp::R_MICROMIPS_TLS_GOTTPREL: + case elfcpp::R_MICROMIPS_TLS_TPREL_HI16: + case elfcpp::R_MICROMIPS_TLS_TPREL_LO16: + return Symbol::TLS_REF; + + case elfcpp::R_MIPS_COPY: + case elfcpp::R_MIPS_JUMP_SLOT: + default: + gold_unreachable(); + // Not expected. We will give an error later. + return 0; + } +} + +// Report an unsupported relocation against a local symbol. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::Scan::unsupported_reloc_local( + Sized_relobj_file<size, big_endian>* object, + unsigned int r_type) +{ + gold_error(_("%s: unsupported reloc %u against local symbol"), + object->name().c_str(), r_type); +} + +// Report an unsupported relocation against a global symbol. + +template<int size, bool big_endian> +void +Target_mips<size, big_endian>::Scan::unsupported_reloc_global( + Sized_relobj_file<size, big_endian>* object, + unsigned int r_type, + Symbol* gsym) +{ + gold_error(_("%s: unsupported reloc %u against global symbol %s"), + object->name().c_str(), r_type, gsym->demangled_name().c_str()); +} + +// Return printable name for ABI. +template<int size, bool big_endian> +const char* +Target_mips<size, big_endian>::elf_mips_abi_name(elfcpp::Elf_Word e_flags, + unsigned char ei_class) +{ + switch (e_flags & elfcpp::EF_MIPS_ABI) + { + case 0: + if ((e_flags & elfcpp::EF_MIPS_ABI2) != 0) + return "N32"; + else if (elfcpp::abi_64(ei_class)) + return "64"; + else + return "none"; + case elfcpp::E_MIPS_ABI_O32: + return "O32"; + case elfcpp::E_MIPS_ABI_O64: + return "O64"; + case elfcpp::E_MIPS_ABI_EABI32: + return "EABI32"; + case elfcpp::E_MIPS_ABI_EABI64: + return "EABI64"; + default: + return "unknown abi"; + } +} + +template<int size, bool big_endian> +const char* +Target_mips<size, big_endian>::elf_mips_mach_name(elfcpp::Elf_Word e_flags) +{ + switch (e_flags & elfcpp::EF_MIPS_MACH) + { + case elfcpp::E_MIPS_MACH_3900: + return "mips:3900"; + case elfcpp::E_MIPS_MACH_4010: + return "mips:4010"; + case elfcpp::E_MIPS_MACH_4100: + return "mips:4100"; + case elfcpp::E_MIPS_MACH_4111: + return "mips:4111"; + case elfcpp::E_MIPS_MACH_4120: + return "mips:4120"; + case elfcpp::E_MIPS_MACH_4650: + return "mips:4650"; + case elfcpp::E_MIPS_MACH_5400: + return "mips:5400"; + case elfcpp::E_MIPS_MACH_5500: + return "mips:5500"; + case elfcpp::E_MIPS_MACH_SB1: + return "mips:sb1"; + case elfcpp::E_MIPS_MACH_9000: + return "mips:9000"; + case elfcpp::E_MIPS_MACH_LS2E: + return "mips:loongson-2e"; + case elfcpp::E_MIPS_MACH_LS2F: + return "mips:loongson-2f"; + case elfcpp::E_MIPS_MACH_LS3A: + return "mips:loongson-3a"; + case elfcpp::E_MIPS_MACH_OCTEON: + return "mips:octeon"; + case elfcpp::E_MIPS_MACH_OCTEON2: + return "mips:octeon2"; + case elfcpp::E_MIPS_MACH_XLR: + return "mips:xlr"; + default: + switch (e_flags & elfcpp::EF_MIPS_ARCH) + { + default: + case elfcpp::E_MIPS_ARCH_1: + return "mips:3000"; + + case elfcpp::E_MIPS_ARCH_2: + return "mips:6000"; + + case elfcpp::E_MIPS_ARCH_3: + return "mips:4000"; + + case elfcpp::E_MIPS_ARCH_4: + return "mips:8000"; + + case elfcpp::E_MIPS_ARCH_5: + return "mips:mips5"; + + case elfcpp::E_MIPS_ARCH_32: + return "mips:isa32"; + + case elfcpp::E_MIPS_ARCH_64: + return "mips:isa64"; + + case elfcpp::E_MIPS_ARCH_32R2: + return "mips:isa32r2"; + + case elfcpp::E_MIPS_ARCH_64R2: + return "mips:isa64r2"; + } + } + return "unknown CPU"; +} + +template<int size, bool big_endian> +const Target::Target_info Target_mips<size, big_endian>::mips_info = +{ + size, // size + big_endian, // is_big_endian + elfcpp::EM_MIPS, // machine_code + true, // has_make_symbol + false, // has_resolve + false, // has_code_fill + true, // is_default_stack_executable + false, // can_icf_inline_merge_sections + '\0', // wrap_char + "/lib/ld.so.1", // dynamic_linker + 0x400000, // default_text_segment_address + 64 * 1024, // abi_pagesize (overridable by -z max-page-size) + 4 * 1024, // common_pagesize (overridable by -z common-page-size) + false, // isolate_execinstr + 0, // rosegment_gap + elfcpp::SHN_UNDEF, // small_common_shndx + elfcpp::SHN_UNDEF, // large_common_shndx + 0, // small_common_section_flags + 0, // large_common_section_flags + NULL, // attributes_section + NULL, // attributes_vendor + "__start" // entry_symbol_name +}; + +template<int size, bool big_endian> +class Target_mips_nacl : public Target_mips<size, big_endian> +{ + public: + Target_mips_nacl() + : Target_mips<size, big_endian>(&mips_nacl_info) + { } + + private: + static const Target::Target_info mips_nacl_info; +}; + +template<int size, bool big_endian> +const Target::Target_info Target_mips_nacl<size, big_endian>::mips_nacl_info = +{ + size, // size + big_endian, // is_big_endian + elfcpp::EM_MIPS, // machine_code + true, // has_make_symbol + false, // has_resolve + false, // has_code_fill + true, // is_default_stack_executable + false, // can_icf_inline_merge_sections + '\0', // wrap_char + "/lib/ld.so.1", // dynamic_linker + 0x20000, // default_text_segment_address + 0x10000, // abi_pagesize (overridable by -z max-page-size) + 0x10000, // common_pagesize (overridable by -z common-page-size) + true, // isolate_execinstr + 0x10000000, // rosegment_gap + elfcpp::SHN_UNDEF, // small_common_shndx + elfcpp::SHN_UNDEF, // large_common_shndx + 0, // small_common_section_flags + 0, // large_common_section_flags + NULL, // attributes_section + NULL, // attributes_vendor + "_start" // entry_symbol_name +}; + +// Target selector for Mips. Note this is never instantiated directly. +// It's only used in Target_selector_mips_nacl, below. + +template<int size, bool big_endian> +class Target_selector_mips : public Target_selector +{ +public: + Target_selector_mips() + : Target_selector(elfcpp::EM_MIPS, size, big_endian, + (size == 64 ? + (big_endian ? "elf64-tradbigmips" : "elf64-tradlittlemips") : + (big_endian ? "elf32-tradbigmips" : "elf32-tradlittlemips")), + (size == 64 ? + (big_endian ? "elf64-tradbigmips" : "elf64-tradlittlemips") : + (big_endian ? "elf32-tradbigmips" : "elf32-tradlittlemips"))) + { } + + Target* do_instantiate_target() + { return new Target_mips<size, big_endian>(); } +}; + +template<int size, bool big_endian> +class Target_selector_mips_nacl + : public Target_selector_nacl<Target_selector_mips<size, big_endian>, + Target_mips_nacl<size, big_endian> > +{ + public: + Target_selector_mips_nacl() + : Target_selector_nacl<Target_selector_mips<size, big_endian>, + Target_mips_nacl<size, big_endian> >( + // NaCl currently supports only MIPS32 little-endian. + "mipsel", "elf32-tradlittlemips-nacl", "elf32-tradlittlemips-nacl") + { } +}; + +Target_selector_mips_nacl<32, true> target_selector_mips32; +Target_selector_mips_nacl<32, false> target_selector_mips32el; +Target_selector_mips_nacl<64, true> target_selector_mips64; +Target_selector_mips_nacl<64, false> target_selector_mips64el; + +} // End anonymous namespace. diff --git a/binutils-2.25/gold/mremap.c b/binutils-2.25/gold/mremap.c index e165634..9c0fe6e 100644 --- a/binutils-2.25/gold/mremap.c +++ b/binutils-2.25/gold/mremap.c @@ -1,6 +1,6 @@ /* mremap.c -- version of mremap for gold. */ -/* Copyright 2009, 2011 Free Software Foundation, Inc. +/* Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/nacl.cc b/binutils-2.25/gold/nacl.cc index b22248c..047f92e 100644 --- a/binutils-2.25/gold/nacl.cc +++ b/binutils-2.25/gold/nacl.cc @@ -1,6 +1,6 @@ // nacl.cc -- Native Client support for gold -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // This file is part of gold. diff --git a/binutils-2.25/gold/nacl.h b/binutils-2.25/gold/nacl.h index 323f804..cb0e9d1 100644 --- a/binutils-2.25/gold/nacl.h +++ b/binutils-2.25/gold/nacl.h @@ -1,6 +1,6 @@ // nacl.h -- Native Client support for gold -*- C++ -*- -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // This file is part of gold. diff --git a/binutils-2.25/gold/object.cc b/binutils-2.25/gold/object.cc index b1feacc..6ab84ce 100644 --- a/binutils-2.25/gold/object.cc +++ b/binutils-2.25/gold/object.cc @@ -1,7 +1,6 @@ // object.cc -- support for an object file for linking in gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -335,7 +334,9 @@ Relobj::is_section_name_included(const char* name) || (is_prefix_of(".sdata", name) && strstr(name, "personality")) || (is_prefix_of(".gnu.linkonce.d", name) - && strstr(name, "personality"))) + && strstr(name, "personality")) + || (is_prefix_of(".rodata", name) + && strstr(name, "nptl_version"))) { return true; } @@ -756,6 +757,16 @@ template<int size, bool big_endian> void Sized_relobj_file<size, big_endian>::do_read_symbols(Read_symbols_data* sd) { + this->base_read_symbols(sd); +} + +// Read the sections and symbols from an object file. This is common +// code for all target-specific overrides of do_read_symbols(). + +template<int size, bool big_endian> +void +Sized_relobj_file<size, big_endian>::base_read_symbols(Read_symbols_data* sd) +{ this->read_section_data(&this->elf_file_, sd); const unsigned char* const pshdrs = sd->section_headers->data(); @@ -1633,7 +1644,7 @@ Sized_relobj_file<size, big_endian>::do_layout(Symbol_table* symtab, symtab->icf()->get_folded_section(this, i); Relobj* folded_obj = reinterpret_cast<Relobj*>(folded.first); - gold_info(_("%s: ICF folding section '%s' in file '%s'" + gold_info(_("%s: ICF folding section '%s' in file '%s' " "into '%s' in file '%s'"), program_name, this->section_name(i).c_str(), this->name().c_str(), @@ -1849,7 +1860,7 @@ Sized_relobj_file<size, big_endian>::do_layout_deferred_sections(Layout* layout) // Reading the symbols again here may be slow. Read_symbols_data sd; - this->read_symbols(&sd); + this->base_read_symbols(&sd); this->layout_eh_frame_section(layout, sd.symbols->data(), sd.symbols_size, @@ -2348,7 +2359,9 @@ Sized_relobj_file<size, big_endian>::compute_final_local_value_internal( lv_out->set_merged_symbol_value(msv); } } - else if (lv_in->is_tls_symbol()) + else if (lv_in->is_tls_symbol() + || (lv_in->is_section_symbol() + && (os->flags() & elfcpp::SHF_TLS))) lv_out->set_output_value(os->tls_offset() + secoffset + lv_in->input_value()); diff --git a/binutils-2.25/gold/object.h b/binutils-2.25/gold/object.h index 88263b4..754b1d2 100644 --- a/binutils-2.25/gold/object.h +++ b/binutils-2.25/gold/object.h @@ -1,7 +1,6 @@ // object.h -- support for an object file for linking in gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -508,7 +507,7 @@ class Object // Return the name of a section given a section index. std::string - section_name(unsigned int shndx) + section_name(unsigned int shndx) const { return this->do_section_name(shndx); } // Return the section flags given a section index. @@ -823,7 +822,7 @@ class Object // Get the name of a section--implemented by child class. virtual std::string - do_section_name(unsigned int shndx) = 0; + do_section_name(unsigned int shndx) const = 0; // Get section flags--implemented by child class. virtual uint64_t @@ -2215,6 +2214,11 @@ class Sized_relobj_file : public Sized_relobj<size, big_endian> void do_read_symbols(Read_symbols_data*); + // Read the symbols. This is common code for all target-specific + // overrides of do_read_symbols. + void + base_read_symbols(Read_symbols_data*); + // Return the value of a local symbol. uint64_t do_local_symbol_value(unsigned int symndx, uint64_t addend) const @@ -2311,7 +2315,7 @@ class Sized_relobj_file : public Sized_relobj<size, big_endian> // Get the name of a section. std::string - do_section_name(unsigned int shndx) + do_section_name(unsigned int shndx) const { return this->elf_file_.section_name(shndx); } // Return the location of the contents of a section. diff --git a/binutils-2.25/gold/options.cc b/binutils-2.25/gold/options.cc index 000e6d0..731061d 100644 --- a/binutils-2.25/gold/options.cc +++ b/binutils-2.25/gold/options.cc @@ -1,7 +1,6 @@ // options.c -- handle command line options for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -549,6 +548,7 @@ General_options::parse_dynamic_list(const char*, const char* arg, { if (!read_dynamic_list(arg, cmdline, &this->dynamic_list_)) gold::gold_fatal(_("unable to parse dynamic-list script file %s"), arg); + this->have_dynamic_list_ = true; } void @@ -918,6 +918,7 @@ General_options::General_options() do_demangle_(false), plugins_(NULL), dynamic_list_(), + have_dynamic_list_(false), incremental_mode_(INCREMENTAL_OFF), incremental_disposition_(INCREMENTAL_STARTUP), incremental_startup_disposition_(INCREMENTAL_CHECK), @@ -1199,6 +1200,13 @@ General_options::finalize() // in the path, as appropriate. this->add_sysroot(); + // --dynamic-list overrides -Bsymbolic and -Bsymbolic-functions. + if (this->have_dynamic_list()) + { + this->set_Bsymbolic(false); + this->set_Bsymbolic_functions(false); + } + // Now that we've normalized the options, check for contradictory ones. if (this->shared() && this->is_static()) gold_fatal(_("-shared and -static are incompatible")); diff --git a/binutils-2.25/gold/options.h b/binutils-2.25/gold/options.h index a2f5a88..cf3b705 100644 --- a/binutils-2.25/gold/options.h +++ b/binutils-2.25/gold/options.h @@ -1,7 +1,6 @@ // options.h -- handle command line options for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -973,9 +972,11 @@ class General_options N_("(ARM only) Ignore for backward compatibility"), NULL); DEFINE_bool(pie, options::ONE_DASH, '\0', false, - N_("Create a position independent executable"), NULL); + N_("Create a position independent executable"), + N_("Do not create a position independent executable")); DEFINE_bool_alias(pic_executable, pie, options::TWO_DASHES, '\0', - N_("Create a position independent executable"), NULL, + N_("Create a position independent executable"), + N_("Do not create a position independent executable"), false); DEFINE_bool(pipeline_knowledge, options::ONE_DASH, '\0', false, @@ -1438,6 +1439,11 @@ class General_options in_dynamic_list(const char* symbol) const { return this->dynamic_list_.version_script_info()->symbol_is_local(symbol); } + // True if a --dynamic-list script was provided. + bool + have_dynamic_list() const + { return this->have_dynamic_list_; } + // Finalize the dynamic list. void finalize_dynamic_list() @@ -1591,6 +1597,8 @@ class General_options // script.cc, we store this as a Script_options object, even though // we only use a single Version_tree from it. Script_options dynamic_list_; + // Whether a --dynamic-list file was provided. + bool have_dynamic_list_; // The incremental linking mode. Incremental_mode incremental_mode_; // The disposition given by the --incremental-changed, diff --git a/binutils-2.25/gold/output.cc b/binutils-2.25/gold/output.cc index 348ad64..3361991 100644 --- a/binutils-2.25/gold/output.cc +++ b/binutils-2.25/gold/output.cc @@ -1,7 +1,6 @@ // output.cc -- manage the output file for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -1797,6 +1796,10 @@ Output_data_dynamic::Dynamic_entry::write( val = pool->get_offset(this->u_.str); break; + case DYNAMIC_CUSTOM: + val = parameters->target().dynamic_tag_custom_value(this->tag_); + break; + default: val = this->u_.od->address() + this->offset_; break; @@ -3203,18 +3206,17 @@ class Output_section::Input_section_sort_entry { public: Input_section_sort_entry() - : input_section_(), index_(-1U), section_has_name_(false), - section_name_() + : input_section_(), index_(-1U), section_name_() { } Input_section_sort_entry(const Input_section& input_section, unsigned int index, - bool must_sort_attached_input_sections) - : input_section_(input_section), index_(index), - section_has_name_(input_section.is_input_section() - || input_section.is_relaxed_input_section()) + bool must_sort_attached_input_sections, + const char* output_section_name) + : input_section_(input_section), index_(index), section_name_() { - if (this->section_has_name_ + if ((input_section.is_input_section() + || input_section.is_relaxed_input_section()) && must_sort_attached_input_sections) { // This is only called single-threaded from Layout::finalize, @@ -3230,6 +3232,12 @@ class Output_section::Input_section_sort_entry // Layout::layout if this becomes a speed problem. this->section_name_ = obj->section_name(input_section.shndx()); } + else if (input_section.is_output_section_data() + && must_sort_attached_input_sections) + { + // For linker-generated sections, use the output section name. + this->section_name_.assign(output_section_name); + } } // Return the Input_section. @@ -3249,16 +3257,10 @@ class Output_section::Input_section_sort_entry return this->index_; } - // Whether there is a section name. - bool - section_has_name() const - { return this->section_has_name_; } - // The section name. const std::string& section_name() const { - gold_assert(this->section_has_name_); return this->section_name_; } @@ -3267,7 +3269,6 @@ class Output_section::Input_section_sort_entry bool has_priority() const { - gold_assert(this->section_has_name_); return this->section_name_.find('.', 1) != std::string::npos; } @@ -3277,7 +3278,6 @@ class Output_section::Input_section_sort_entry unsigned int get_priority() const { - gold_assert(this->section_has_name_); bool is_ctors; if (is_prefix_of(".ctors.", this->section_name_.c_str()) || is_prefix_of(".dtors.", this->section_name_.c_str())) @@ -3336,9 +3336,6 @@ class Output_section::Input_section_sort_entry Input_section input_section_; // The index of this Input_section in the original list. unsigned int index_; - // Whether this Input_section has a section name--it won't if this - // is some random Output_section_data. - bool section_has_name_; // The section name if there is one. std::string section_name_; }; @@ -3374,16 +3371,6 @@ Output_section::Input_section_sort_compare::operator()( return s1.index() < s2.index(); } - // We sort all the sections with no names to the end. - if (!s1.section_has_name() || !s2.section_has_name()) - { - if (s1.section_has_name()) - return true; - if (s2.section_has_name()) - return false; - return s1.index() < s2.index(); - } - // A section with a priority follows a section without a priority. bool s1_has_priority = s1.has_priority(); bool s2_has_priority = s2.has_priority(); @@ -3415,16 +3402,6 @@ Output_section::Input_section_sort_init_fini_compare::operator()( const Output_section::Input_section_sort_entry& s1, const Output_section::Input_section_sort_entry& s2) const { - // We sort all the sections with no names to the end. - if (!s1.section_has_name() || !s2.section_has_name()) - { - if (s1.section_has_name()) - return true; - if (s2.section_has_name()) - return false; - return s1.index() < s2.index(); - } - // A section without a priority follows a section with a priority. // This is the reverse of .ctors and .dtors sections. bool s1_has_priority = s1.has_priority(); @@ -3500,16 +3477,6 @@ Output_section::Input_section_sort_section_prefix_special_ordering_compare const Output_section::Input_section_sort_entry& s1, const Output_section::Input_section_sort_entry& s2) const { - // We sort all the sections with no names to the end. - if (!s1.section_has_name() || !s2.section_has_name()) - { - if (s1.section_has_name()) - return true; - if (s2.section_has_name()) - return false; - return s1.index() < s2.index(); - } - // Some input section names have special ordering requirements. int o1 = Layout::special_ordering_of_input_section(s1.section_name().c_str()); int o2 = Layout::special_ordering_of_input_section(s2.section_name().c_str()); @@ -3536,16 +3503,6 @@ Output_section::Input_section_sort_section_name_compare const Output_section::Input_section_sort_entry& s1, const Output_section::Input_section_sort_entry& s2) const { - // We sort all the sections with no names to the end. - if (!s1.section_has_name() || !s2.section_has_name()) - { - if (s1.section_has_name()) - return true; - if (s2.section_has_name()) - return false; - return s1.index() < s2.index(); - } - // We sort by name. int compare = s1.section_name().compare(s2.section_name()); if (compare != 0) @@ -3613,7 +3570,8 @@ Output_section::sort_attached_input_sections() p != this->input_sections_.end(); ++p, ++i) sort_list.push_back(Input_section_sort_entry(*p, i, - this->must_sort_attached_input_sections())); + this->must_sort_attached_input_sections(), + this->name())); // Sort the input sections. if (this->must_sort_attached_input_sections()) diff --git a/binutils-2.25/gold/output.h b/binutils-2.25/gold/output.h index 574d270..ba0cdaa 100644 --- a/binutils-2.25/gold/output.h +++ b/binutils-2.25/gold/output.h @@ -1,7 +1,6 @@ // output.h -- manage the output file for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -2578,6 +2577,11 @@ class Output_data_dynamic : public Output_section_data add_string(elfcpp::DT tag, const std::string& str) { this->add_string(tag, str.c_str()); } + // Add a new dynamic entry with custom value. + void + add_custom(elfcpp::DT tag) + { this->add_entry(Dynamic_entry(tag)); } + protected: // Adjust the output section to set the entry size. void @@ -2642,6 +2646,11 @@ class Output_data_dynamic : public Output_section_data : tag_(tag), offset_(DYNAMIC_STRING) { this->u_.str = str; } + // Create an entry with a custom value. + Dynamic_entry(elfcpp::DT tag) + : tag_(tag), offset_(DYNAMIC_CUSTOM) + { } + // Return the tag of this entry. elfcpp::DT tag() const @@ -2665,7 +2674,9 @@ class Output_data_dynamic : public Output_section_data // Symbol adress. DYNAMIC_SYMBOL = -3U, // String. - DYNAMIC_STRING = -4U + DYNAMIC_STRING = -4U, + // Custom value. + DYNAMIC_CUSTOM = -5U // Any other value indicates a section address plus OFFSET. }; diff --git a/binutils-2.25/gold/parameters.cc b/binutils-2.25/gold/parameters.cc index 7410e7f..588f448 100644 --- a/binutils-2.25/gold/parameters.cc +++ b/binutils-2.25/gold/parameters.cc @@ -1,7 +1,6 @@ // parameters.cc -- general parameters for a link using gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/parameters.h b/binutils-2.25/gold/parameters.h index 8d1ec2e..fe5db15 100644 --- a/binutils-2.25/gold/parameters.h +++ b/binutils-2.25/gold/parameters.h @@ -1,6 +1,6 @@ // parameters.h -- general parameters for a link using gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2013 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/plugin.cc b/binutils-2.25/gold/plugin.cc index e932c1c..0339d42 100644 --- a/binutils-2.25/gold/plugin.cc +++ b/binutils-2.25/gold/plugin.cc @@ -1,6 +1,6 @@ // plugin.cc -- plugin manager for gold -*- C++ -*- -// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. @@ -1053,8 +1053,6 @@ Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table* symtab, elfcpp::Sym<size, big_endian> sym(symbuf); elfcpp::Sym_write<size, big_endian> osym(symbuf); - typedef typename elfcpp::Elf_types<size>::Elf_WXword Elf_size_type; - this->symbols_.resize(this->nsyms_); for (int i = 0; i < this->nsyms_; ++i) @@ -1125,7 +1123,7 @@ Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table* symtab, osym.put_st_name(0); osym.put_st_value(0); - osym.put_st_size(static_cast<Elf_size_type>(isym->size)); + osym.put_st_size(0); osym.put_st_info(bind, elfcpp::STT_NOTYPE); osym.put_st_other(vis, 0); osym.put_st_shndx(shndx); @@ -1209,7 +1207,7 @@ Sized_pluginobj<size, big_endian>::do_section_size(unsigned int) template<int size, bool big_endian> std::string -Sized_pluginobj<size, big_endian>::do_section_name(unsigned int) +Sized_pluginobj<size, big_endian>::do_section_name(unsigned int) const { gold_unreachable(); return std::string(); diff --git a/binutils-2.25/gold/plugin.h b/binutils-2.25/gold/plugin.h index e4289ff..9ef2812 100644 --- a/binutils-2.25/gold/plugin.h +++ b/binutils-2.25/gold/plugin.h @@ -1,6 +1,6 @@ // plugin.h -- plugin manager for gold -*- C++ -*- -// Copyright 2008, 2009, 2010, 2011, 2013 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. @@ -490,7 +490,7 @@ class Sized_pluginobj : public Pluginobj // Get the name of a section. std::string - do_section_name(unsigned int shndx); + do_section_name(unsigned int shndx) const; // Return a view of the contents of a section. const unsigned char* diff --git a/binutils-2.25/gold/po/Make-in b/binutils-2.25/gold/po/Make-in index 3f0fc76..8212bf7 100644 --- a/binutils-2.25/gold/po/Make-in +++ b/binutils-2.25/gold/po/Make-in @@ -1,6 +1,6 @@ # Makefile for program source directory in GNU NLS utilities package. # Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu> -# Copyright 2003, 2006, 2007, 2009 Free Software Foundation, Inc. +# Copyright (C) 2003-2014 Free Software Foundation, Inc. # # This file may be copied and used freely without restrictions. It can # be used in projects which are not available under the GNU Public License diff --git a/binutils-2.25/gold/po/POTFILES.in b/binutils-2.25/gold/po/POTFILES.in index 53ed816..8d66e22 100644 --- a/binutils-2.25/gold/po/POTFILES.in +++ b/binutils-2.25/gold/po/POTFILES.in @@ -1,3 +1,6 @@ +aarch64-reloc-property.cc +aarch64-reloc-property.h +aarch64.cc archive.cc archive.h arm-reloc-property.cc @@ -53,6 +56,7 @@ mapfile.cc mapfile.h merge.cc merge.h +mips.cc nacl.cc nacl.h object.cc diff --git a/binutils-2.25/gold/po/gold.pot b/binutils-2.25/gold/po/gold.pot index d58054a..6340518 100644 --- a/binutils-2.25/gold/po/gold.pot +++ b/binutils-2.25/gold/po/gold.pot @@ -8,166 +8,415 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: bug-binutils@gnu.org\n" -"POT-Creation-Date: 2010-03-03 15:08+0100\n" +"POT-Creation-Date: 2014-02-10 09:42+1030\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: archive.cc:119 +#: archive.cc:135 +#, c-format +msgid "script or expression reference to %s" +msgstr "" + +#: archive.cc:229 #, c-format msgid "%s: no archive symbol table (run ranlib)" msgstr "" -#: archive.cc:204 +#: archive.cc:317 #, c-format msgid "%s: bad archive symbol table names" msgstr "" -#: archive.cc:236 +#: archive.cc:349 #, c-format msgid "%s: malformed archive header at %zu" msgstr "" -#: archive.cc:256 +#: archive.cc:369 #, c-format msgid "%s: malformed archive header size at %zu" msgstr "" -#: archive.cc:267 +#: archive.cc:380 #, c-format msgid "%s: malformed archive header name at %zu" msgstr "" -#: archive.cc:297 +#: archive.cc:411 #, c-format msgid "%s: bad extended name index at %zu" msgstr "" -#: archive.cc:307 +#: archive.cc:421 #, c-format msgid "%s: bad extended name entry at header %zu" msgstr "" -#: archive.cc:404 +#: archive.cc:518 #, c-format msgid "%s: short archive header at %zu" msgstr "" -#: archive.cc:560 +#: archive.cc:702 #, c-format msgid "%s: member at %zu is not an ELF object" msgstr "" -#: archive.cc:879 +#: archive.cc:1043 #, c-format msgid "%s: archive libraries: %u\n" msgstr "" -#: archive.cc:881 +#: archive.cc:1045 #, c-format msgid "%s: total archive members: %u\n" msgstr "" -#: archive.cc:883 +#: archive.cc:1047 #, c-format msgid "%s: loaded archive members: %u\n" msgstr "" -#: arm.cc:1149 i386.cc:536 sparc.cc:1087 x86_64.cc:565 +#: archive.cc:1277 +#, c-format +msgid "%s: lib groups: %u\n" +msgstr "" + +#: archive.cc:1279 +#, c-format +msgid "%s: total lib groups members: %u\n" +msgstr "" + +#: archive.cc:1281 +#, c-format +msgid "%s: loaded lib groups members: %u\n" +msgstr "" + +#: arm-reloc-property.cc:303 +#, c-format +msgid "invalid reloc %u" +msgstr "" + +#: arm-reloc-property.cc:316 +msgid "reloc " +msgstr "" + +#: arm-reloc-property.cc:316 +msgid "unimplemented reloc " +msgstr "" + +#: arm-reloc-property.cc:319 +msgid "dynamic reloc " +msgstr "" + +#: arm-reloc-property.cc:322 +msgid "private reloc " +msgstr "" + +#: arm-reloc-property.cc:325 +msgid "obsolete reloc " +msgstr "" + +#: arm.cc:1074 +msgid "** ARM cantunwind" +msgstr "" + +#: arm.cc:4037 +#, c-format +msgid "%s: Thumb BLX instruction targets thumb function '%s'." +msgstr "" + +#: arm.cc:4183 +msgid "conditional branch to PLT in THUMB-2 not supported yet." +msgstr "" + +#: arm.cc:5263 +msgid "PREL31 overflow in EXIDX_CANTUNWIND entry" +msgstr "" + +#. Something is wrong with this section. Better not touch it. +#: arm.cc:5509 +#, c-format +msgid "uneven .ARM.exidx section size in %s section %u" +msgstr "" + +#: arm.cc:5835 +msgid "Found non-EXIDX input sections in EXIDX output section" +msgstr "" + +#: arm.cc:5889 arm.cc:5893 +#, c-format +msgid "" +"unwinding may not work because EXIDX input section %u of %s is not in EXIDX " +"output section" +msgstr "" + +#: arm.cc:6179 +#, c-format +msgid "" +"cannot scan executable section %u of %s for Cortex-A8 erratum because it has " +"no mapping symbols." +msgstr "" + +#: arm.cc:6381 object.cc:818 +#, c-format +msgid "invalid symbol table name index: %u" +msgstr "" + +#: arm.cc:6389 object.cc:824 +#, c-format +msgid "symbol table name section has wrong type: %u" +msgstr "" + +#: arm.cc:6639 +#, c-format +msgid "EXIDX section %s(%u) links to invalid section %u in %s" +msgstr "" + +#: arm.cc:6648 +#, c-format +msgid "EXIDX sections %s(%u) and %s(%u) both link to text section%s(%u) in %s" +msgstr "" + +#: arm.cc:6662 +#, c-format +msgid "EXIDX section %s(%u) links to non-allocated section %s(%u) in %s" +msgstr "" + +#. I would like to make this an error but currently ld just ignores +#. this. +#: arm.cc:6672 +#, c-format +msgid "EXIDX section %s(%u) links to non-executable section %s(%u) in %s" +msgstr "" + +#: arm.cc:6756 +#, c-format +msgid "SHF_LINK_ORDER not set in EXIDX section %s of %s" +msgstr "" + +#: arm.cc:6789 +#, c-format +msgid "relocation section %u has invalid info %u" +msgstr "" + +#: arm.cc:6795 +#, c-format +msgid "section %u has multiple relocation sections %u and %u" +msgstr "" + +#: arm.cc:7155 +#, c-format +msgid "undefined or discarded local symbol %u from object %s in GOT" +msgstr "" + +#: arm.cc:7177 +#, c-format +msgid "undefined or discarded symbol %s in GOT" +msgstr "" + +#: arm.cc:7293 i386.cc:168 sparc.cc:1349 tilegx.cc:182 x86_64.cc:257 msgid "** PLT" msgstr "" -#: arm.cc:1364 i386.cc:880 powerpc.cc:1014 sparc.cc:1502 x86_64.cc:955 -#: x86_64.cc:1265 +#: arm.cc:7800 i386.cc:1685 powerpc.cc:5111 sparc.cc:2117 tilegx.cc:3123 +#: tilegx.cc:3575 x86_64.cc:2169 x86_64.cc:2598 #, c-format msgid "%s: unsupported reloc %u against local symbol" msgstr "" -#: arm.cc:1404 powerpc.cc:1105 sparc.cc:1592 x86_64.cc:992 -msgid "requires unsupported dynamic reloc; recompile with -fPIC" +#: arm.cc:7844 +#, c-format +msgid "requires unsupported dynamic reloc %s; recompile with -fPIC" +msgstr "" + +#: arm.cc:7935 i386.cc:1775 x86_64.cc:2377 +#, c-format +msgid "section symbol %u has bad shndx %u" msgstr "" #. These are relocations which should only be seen by the #. dynamic linker, and should never be seen here. -#: arm.cc:1519 arm.cc:1739 arm.cc:2354 i386.cc:1002 i386.cc:1334 -#: powerpc.cc:1223 powerpc.cc:1432 sparc.cc:1877 sparc.cc:2238 x86_64.cc:1145 -#: x86_64.cc:1453 +#: arm.cc:8044 arm.cc:8477 i386.cc:1844 i386.cc:2293 sparc.cc:2532 +#: sparc.cc:3009 tilegx.cc:3570 tilegx.cc:4123 x86_64.cc:2470 x86_64.cc:2931 #, c-format msgid "%s: unexpected reloc %u in object file" msgstr "" -#: arm.cc:1538 i386.cc:1171 powerpc.cc:1242 sparc.cc:1896 x86_64.cc:1279 -#: x86_64.cc:1571 +#: arm.cc:8076 i386.cc:1878 sparc.cc:2431 tilegx.cc:3474 x86_64.cc:2502 +#, c-format +msgid "local symbol %u has bad shndx %u" +msgstr "" + +#: arm.cc:8177 i386.cc:2021 powerpc.cc:5655 sparc.cc:2551 tilegx.cc:3591 +#: tilegx.cc:4128 x86_64.cc:2614 x86_64.cc:3053 #, c-format msgid "%s: unsupported reloc %u against global symbol %s" msgstr "" -#: arm.cc:1804 i386.cc:1542 +#: arm.cc:8635 i386.cc:2503 #, c-format msgid "%s: unsupported RELA reloc section" msgstr "" -#: arm.cc:2047 +#: arm.cc:8725 msgid "" -"relocation R_ARM_MOVW_ABS_NC cannot be used when makinga shared object; " -"recompile with -fPIC" +"unable to provide V4BX reloc interworking fix up; the target profile does " +"not support BX instruction" msgstr "" -#: arm.cc:2056 -msgid "" -"relocation R_ARM_MOVT_ABS cannot be used when makinga shared object; " -"recompile with -fPIC" +#: arm.cc:8859 +#, c-format +msgid "cannot relocate %s in object file" msgstr "" -#: arm.cc:2067 +#: arm.cc:9333 arm.cc:9914 +#, c-format +msgid "relocation overflow in %s" +msgstr "" + +#: arm.cc:9341 arm.cc:9919 +#, c-format +msgid "unexpected opcode while processing relocation %s" +msgstr "" + +#: arm.cc:9485 i386.cc:2841 i386.cc:2923 i386.cc:2994 i386.cc:3030 +#: i386.cc:3102 powerpc.cc:7562 sparc.cc:3589 sparc.cc:3780 sparc.cc:3841 +#: sparc.cc:3948 tilegx.cc:4712 x86_64.cc:3486 x86_64.cc:3586 x86_64.cc:3664 +#: x86_64.cc:3698 +#, c-format +msgid "unsupported reloc %u" +msgstr "" + +#: arm.cc:9564 +#, c-format +msgid "%s: unexpected %s in object file" +msgstr "" + +#: arm.cc:9899 +#, c-format +msgid "cannot handle %s in a relocatable link" +msgstr "" + +#: arm.cc:10003 +#, c-format +msgid "Source object %s has EABI version %d but output has EABI version %d." +msgstr "" + +#: arm.cc:10100 powerpc.cc:2077 target.cc:94 +#, c-format +msgid "%s: unsupported ELF file type %d" +msgstr "" + +#: arm.cc:10296 +#, c-format +msgid "%s: unknown CPU architecture" +msgstr "" + +#: arm.cc:10333 +#, c-format +msgid "%s: conflicting CPU architectures %d/%d" +msgstr "" + +#: arm.cc:10471 +#, c-format +msgid "%s has both the current and legacy Tag_MPextension_use attributes" +msgstr "" + +#: arm.cc:10499 +#, c-format +msgid "%s uses VFP register arguments, output does not" +msgstr "" + +#: arm.cc:10645 +#, c-format +msgid "conflicting architecture profiles %c/%c" +msgstr "" + +#. It's sometimes ok to mix different configs, so this is only +#. a warning. +#: arm.cc:10703 +#, c-format +msgid "%s: conflicting platform configuration" +msgstr "" + +#: arm.cc:10712 +#, c-format +msgid "%s: conflicting use of R9" +msgstr "" + +#: arm.cc:10725 +#, c-format +msgid "%s: SB relative addressing conflicts with use of R9" +msgstr "" + +#: arm.cc:10740 +#, c-format msgid "" -"relocation R_ARM_THM_MOVW_ABS_NC cannot be used whenmaking a shared object; " -"recompile with -fPIC" +"%s uses %u-byte wchar_t yet the output is to use %u-byte wchar_t; use of " +"wchar_t values across objects may fail" msgstr "" -#: arm.cc:2077 +#: arm.cc:10766 +#, c-format msgid "" -"relocation R_ARM_THM_MOVT_ABS cannot be used whenmaking a shared object; " -"recompile with -fPIC" +"%s uses %s enums yet the output is to use %s enums; use of enum values " +"across objects may fail" msgstr "" -#: arm.cc:2141 -msgid "cannot find origin of R_ARM_BASE_PREL" +#: arm.cc:10782 +#, c-format +msgid "%s uses iWMMXt register arguments, output does not" msgstr "" -#: arm.cc:2169 -msgid "cannot find origin of R_ARM_BASE_ABS" +#: arm.cc:10803 +#, c-format +msgid "fp16 format mismatch between %s and output" msgstr "" -#: arm.cc:2230 i386.cc:1820 i386.cc:2521 powerpc.cc:1798 sparc.cc:2711 -#: x86_64.cc:1935 x86_64.cc:2518 +#: arm.cc:10849 #, c-format -msgid "unexpected reloc %u in object file" +msgid "%s has has both the current and legacy Tag_MPextension_use attributes" msgstr "" -#: arm.cc:2236 i386.cc:1852 i386.cc:1931 i386.cc:1983 i386.cc:2014 -#: i386.cc:2076 powerpc.cc:1804 sparc.cc:2717 sparc.cc:2900 sparc.cc:2961 -#: sparc.cc:3068 x86_64.cc:1956 x86_64.cc:2039 x86_64.cc:2094 x86_64.cc:2119 +#: arm.cc:10895 arm.cc:10988 #, c-format -msgid "unsupported reloc %u" +msgid "%s: unknown mandatory EABI object attribute %d" msgstr "" -#: arm.cc:2248 +#: arm.cc:10899 arm.cc:10993 #, c-format -msgid "relocation overflow in relocation %u" +msgid "%s: unknown EABI object attribute %d" msgstr "" -#: arm.cc:2256 +#: arm.cc:11345 #, c-format -msgid "unexpected opcode while processing relocation %u" +msgid "cannot handle branch to local %u in a merged section %s" +msgstr "" + +#: arm.cc:11425 target-reloc.h:390 +msgid "relocation refers to discarded section" msgstr "" -#: arm.cc:2359 i386.cc:2535 +#. We cannot handle this now. +#: arm.cc:11589 #, c-format -msgid "unsupported reloc %u in object file" +msgid "multiple SHT_ARM_EXIDX sections %s and %s in a non-relocatable link" +msgstr "" + +#: attributes.cc:410 +#, c-format +msgid "%s: must be processed by '%s' toolchain" +msgstr "" + +#: attributes.cc:418 +#, c-format +msgid "%s: object tag '%d, %s' is incompatible with tag '%d, %s'" msgstr "" #: binary.cc:129 @@ -175,211 +424,249 @@ msgstr "" msgid "cannot open %s: %s:" msgstr "" -#: compressed_output.cc:128 +#: common.cc:352 output.cc:2432 output.cc:2531 +#, c-format +msgid "out of patch space in section %s; relink with --incremental-full" +msgstr "" + +#: compressed_output.cc:225 msgid "not compressing section data: zlib error" msgstr "" -#: cref.cc:244 +#: cref.cc:384 #, c-format msgid "cannot open symbol count file %s: %s" msgstr "" -#: descriptors.cc:116 +#: cref.cc:398 +#, c-format +msgid "" +"\n" +"Cross Reference Table\n" +"\n" +msgstr "" + +#: cref.cc:399 +msgid "Symbol" +msgstr "" + +#: cref.cc:401 +msgid "File" +msgstr "" + +#: descriptors.cc:125 #, c-format msgid "file %s was removed during the link" msgstr "" -#: descriptors.cc:169 +#: descriptors.cc:177 msgid "out of file descriptors and couldn't close any" msgstr "" -#: descriptors.cc:190 descriptors.cc:226 +#: descriptors.cc:198 descriptors.cc:234 descriptors.cc:267 #, c-format msgid "while closing %s: %s" msgstr "" -#: dirsearch.cc:71 +#: dirsearch.cc:73 #, c-format msgid "%s: can not read directory: %s" msgstr "" -#: dwarf_reader.cc:53 dwarf_reader.cc:84 -msgid "Unusually large LEB128 decoded, debug information may be corrupted" +#: dwarf_reader.cc:454 +#, c-format +msgid "" +"%s: DWARF info may be corrupt; offsets in a range list entry are in " +"different sections" msgstr "" -#: dynobj.cc:164 +#: dwarf_reader.cc:1513 +#, c-format +msgid "%s: corrupt debug info in %s" +msgstr "" + +#: dynobj.cc:176 #, c-format msgid "unexpected duplicate type %u section: %u, %u" msgstr "" -#: dynobj.cc:200 +#: dynobj.cc:231 #, c-format msgid "unexpected link in section %u header: %u != %u" msgstr "" -#: dynobj.cc:236 +#: dynobj.cc:267 #, c-format msgid "DYNAMIC section %u link out of range: %u" msgstr "" -#: dynobj.cc:244 +#: dynobj.cc:275 #, c-format msgid "DYNAMIC section %u link %u is not a strtab" msgstr "" -#: dynobj.cc:273 +#: dynobj.cc:304 #, c-format msgid "DT_SONAME value out of range: %lld >= %lld" msgstr "" -#: dynobj.cc:285 +#: dynobj.cc:316 #, c-format msgid "DT_NEEDED value out of range: %lld >= %lld" msgstr "" -#: dynobj.cc:298 +#: dynobj.cc:329 msgid "missing DT_NULL in dynamic segment" msgstr "" -#: dynobj.cc:344 +#: dynobj.cc:382 #, c-format msgid "invalid dynamic symbol table name index: %u" msgstr "" -#: dynobj.cc:351 +#: dynobj.cc:389 #, c-format msgid "dynamic symbol table name section has wrong type: %u" msgstr "" -#: dynobj.cc:438 object.cc:463 object.cc:1106 +#: dynobj.cc:476 object.cc:690 object.cc:1453 #, c-format msgid "bad section name offset for section %u: %lu" msgstr "" -#: dynobj.cc:468 +#: dynobj.cc:506 #, c-format msgid "duplicate definition for version %u" msgstr "" -#: dynobj.cc:497 +#: dynobj.cc:535 #, c-format msgid "unexpected verdef version %u" msgstr "" -#: dynobj.cc:513 +#: dynobj.cc:551 #, c-format msgid "verdef vd_cnt field too small: %u" msgstr "" -#: dynobj.cc:521 +#: dynobj.cc:559 #, c-format msgid "verdef vd_aux field out of range: %u" msgstr "" -#: dynobj.cc:532 +#: dynobj.cc:570 #, c-format msgid "verdaux vda_name field out of range: %u" msgstr "" -#: dynobj.cc:542 +#: dynobj.cc:580 #, c-format msgid "verdef vd_next field out of range: %u" msgstr "" -#: dynobj.cc:576 +#: dynobj.cc:614 #, c-format msgid "unexpected verneed version %u" msgstr "" -#: dynobj.cc:585 +#: dynobj.cc:623 #, c-format msgid "verneed vn_aux field out of range: %u" msgstr "" -#: dynobj.cc:599 +#: dynobj.cc:637 #, c-format msgid "vernaux vna_name field out of range: %u" msgstr "" -#: dynobj.cc:610 +#: dynobj.cc:648 #, c-format msgid "verneed vna_next field out of range: %u" msgstr "" -#: dynobj.cc:621 +#: dynobj.cc:659 #, c-format msgid "verneed vn_next field out of range: %u" msgstr "" -#: dynobj.cc:670 +#: dynobj.cc:708 msgid "size of dynamic symbols is not multiple of symbol size" msgstr "" -#: dynobj.cc:1435 +#: dynobj.cc:1524 #, c-format msgid "symbol %s has undefined version %s" msgstr "" -#: ehframe.h:82 +#: ehframe.cc:381 +msgid "overflow in PLT unwind data; unwinding through PLT may fail" +msgstr "" + +#: ehframe.h:78 msgid "** eh_frame_hdr" msgstr "" -#: ehframe.h:353 +#: ehframe.h:419 msgid "** eh_frame" msgstr "" -#: errors.cc:81 +#: errors.cc:81 errors.cc:92 #, c-format msgid "%s: fatal error: " msgstr "" -#: errors.cc:92 +#: errors.cc:103 errors.cc:139 #, c-format msgid "%s: error: " msgstr "" -#: errors.cc:104 +#: errors.cc:115 errors.cc:155 #, c-format msgid "%s: warning: " msgstr "" -#: errors.cc:128 -#, c-format -msgid "%s: %s: error: " +#: errors.cc:179 +msgid "warning" msgstr "" -#: errors.cc:144 +#: errors.cc:184 +msgid "error" +msgstr "" + +#: errors.cc:190 #, c-format -msgid "%s: %s: warning: " +msgid "%s: %s: undefined reference to '%s'\n" msgstr "" -#: errors.cc:167 +#: errors.cc:194 #, c-format -msgid "%s: %s: error: undefined reference to '%s'\n" +msgid "%s: %s: undefined reference to '%s', version '%s'\n" msgstr "" -#: errors.cc:172 +#: errors.cc:198 #, c-format -msgid "%s: %s: error: undefined reference to '%s', version '%s'\n" +msgid "" +"%s: the vtable symbol may be undefined because the class is missing its key " +"function" msgstr "" -#: errors.cc:182 +#: errors.cc:208 #, c-format msgid "%s: " msgstr "" -#: expression.cc:172 +#: expression.cc:192 #, c-format msgid "undefined symbol '%s' referenced in expression" msgstr "" -#: expression.cc:209 +#: expression.cc:230 msgid "invalid reference to dot symbol outside of SECTIONS clause" msgstr "" #. Handle unary operators. We use a preprocessor macro as a hack to #. capture the C operator. -#: expression.cc:278 +#: expression.cc:302 msgid "unary " msgstr "" @@ -391,125 +678,149 @@ msgstr "" #. if the right operand is zero. WARN means that we should warn if #. used on section relative values in a relocatable link. We always #. warn if used on values in different sections in a relocatable link. -#: expression.cc:400 +#: expression.cc:446 msgid "binary " msgstr "" -#: expression.cc:404 +#: expression.cc:450 msgid " by zero" msgstr "" -#: expression.cc:575 +#: expression.cc:636 msgid "max applied to section relative value" msgstr "" -#: expression.cc:610 +#: expression.cc:687 msgid "min applied to section relative value" msgstr "" -#: expression.cc:740 +#: expression.cc:828 msgid "aligning to section relative value" msgstr "" -#: expression.cc:895 +#: expression.cc:993 #, c-format msgid "unknown constant %s" msgstr "" -#: expression.cc:1126 -msgid "SEGMENT_START not implemented" -msgstr "" - -#: expression.cc:1135 -msgid "ORIGIN not implemented" -msgstr "" - -#: expression.cc:1141 -msgid "LENGTH not implemented" -msgstr "" - -#: fileread.cc:65 +#: fileread.cc:141 #, c-format msgid "munmap failed: %s" msgstr "" -#: fileread.cc:129 +#: fileread.cc:209 #, c-format msgid "%s: fstat failed: %s" msgstr "" -#: fileread.cc:169 +#: fileread.cc:250 #, c-format msgid "could not reopen file %s" msgstr "" -#: fileread.cc:302 +#: fileread.cc:401 #, c-format msgid "%s: pread failed: %s" msgstr "" -#: fileread.cc:308 +#: fileread.cc:415 #, c-format msgid "%s: file too short: read only %lld of %lld bytes at %lld" msgstr "" -#: fileread.cc:372 +#: fileread.cc:538 #, c-format msgid "" "%s: attempt to map %lld bytes at offset %lld exceeds size of file; the file " "may be corrupt" msgstr "" -#: fileread.cc:402 -#, c-format -msgid "%s: mmap offset %lld size %lld failed: %s" -msgstr "" - -#: fileread.cc:548 +#: fileread.cc:678 #, c-format msgid "%s: lseek failed: %s" msgstr "" -#: fileread.cc:554 +#: fileread.cc:684 #, c-format msgid "%s: readv failed: %s" msgstr "" -#: fileread.cc:557 +#: fileread.cc:687 #, c-format msgid "%s: file too short: read only %zd of %zd bytes at %lld" msgstr "" -#: fileread.cc:706 +#: fileread.cc:854 #, c-format msgid "%s: total bytes mapped for read: %llu\n" msgstr "" -#: fileread.cc:708 +#: fileread.cc:856 #, c-format msgid "%s: maximum bytes mapped for read at one time: %llu\n" msgstr "" -#: fileread.cc:791 +#: fileread.cc:949 #, c-format msgid "%s: stat failed: %s" msgstr "" -#: fileread.cc:849 +#: fileread.cc:1046 #, c-format msgid "cannot find %s%s" msgstr "" -#: fileread.cc:880 +#: fileread.cc:1071 #, c-format msgid "cannot find %s" msgstr "" -#: fileread.cc:904 +#: fileread.cc:1110 #, c-format msgid "cannot open %s: %s" msgstr "" +#: gdb-index.cc:369 +#, c-format +msgid "%s: --gdb-index currently supports only C and C++ languages" +msgstr "" + +#. The top level DIE should be one of the above. +#: gdb-index.cc:390 +#, c-format +msgid "%s: top level DIE is not DW_TAG_compile_unit or DW_TAG_type_unit" +msgstr "" + +#: gdb-index.cc:844 +#, c-format +msgid "" +"%s: DWARF info may be corrupt; low_pc and high_pc are in different sections" +msgstr "" + +#: gdb-index.cc:970 +#, c-format +msgid "%s: DWARF CUs: %u\n" +msgstr "" + +#: gdb-index.cc:972 +#, c-format +msgid "%s: DWARF CUs without pubnames/pubtypes: %u\n" +msgstr "" + +#: gdb-index.cc:974 +#, c-format +msgid "%s: DWARF TUs: %u\n" +msgstr "" + +#: gdb-index.cc:976 +#, c-format +msgid "%s: DWARF TUs without pubnames/pubtypes: %u\n" +msgstr "" + +#: gdb-index.h:149 +msgid "** gdb_index" +msgstr "" + #: gold-threads.cc:103 #, c-format msgid "pthead_mutextattr_init failed: %s" @@ -535,12 +846,12 @@ msgstr "" msgid "pthread_mutex_destroy failed: %s" msgstr "" -#: gold-threads.cc:131 gold-threads.cc:382 +#: gold-threads.cc:131 gold-threads.cc:396 #, c-format msgid "pthread_mutex_lock failed: %s" msgstr "" -#: gold-threads.cc:139 gold-threads.cc:394 +#: gold-threads.cc:139 gold-threads.cc:410 #, c-format msgid "pthread_mutex_unlock failed: %s" msgstr "" @@ -570,160 +881,277 @@ msgstr "" msgid "pthread_cond_broadcast failed: %s" msgstr "" -#: gold-threads.cc:388 +#: gold-threads.cc:403 #, c-format msgid "pthread_once failed: %s" msgstr "" -#: gold.cc:91 +#: gold.cc:101 #, c-format msgid "%s: internal error in %s, at %s:%d\n" msgstr "" -#: gold.cc:173 +#: gold.cc:191 msgid "no input files" msgstr "" -#: gold.cc:226 +#: gold.cc:221 +msgid "linking with --incremental-full" +msgstr "" + +#: gold.cc:223 +msgid "restart link with --incremental-full" +msgstr "" + +#: gold.cc:285 msgid "cannot mix -r with --gc-sections or --icf" msgstr "" -#: gold.cc:407 +#: gold.cc:612 #, c-format msgid "cannot mix -static with dynamic object %s" msgstr "" -#: gold.cc:411 +#: gold.cc:616 #, c-format msgid "cannot mix -r with dynamic object %s" msgstr "" -#: gold.cc:415 +#: gold.cc:620 #, c-format msgid "cannot use non-ELF output format with dynamic object %s" msgstr "" -#: gold.cc:427 +#: gold.cc:632 #, c-format msgid "cannot mix split-stack '%s' and non-split-stack '%s' when using -r" msgstr "" #. FIXME: This needs to specify the location somehow. -#: i386.cc:232 i386.cc:1669 sparc.cc:234 sparc.cc:2395 x86_64.cc:237 -#: x86_64.cc:1732 +#: i386.cc:601 i386.cc:2655 sparc.cc:312 sparc.cc:3185 x86_64.cc:746 +#: x86_64.cc:3250 msgid "missing expected TLS relocation" msgstr "" -#: i386.cc:944 x86_64.cc:1068 +#: i386.cc:1699 sparc.cc:2229 tilegx.cc:3209 x86_64.cc:2279 #, c-format -msgid "section symbol %u has bad shndx %u" +msgid "%s: unsupported TLS reloc %u for IFUNC symbol" msgstr "" -#: i386.cc:1036 i386.cc:1060 sparc.cc:1777 x86_64.cc:1176 x86_64.cc:1204 +#: i386.cc:2809 i386.cc:3558 powerpc.cc:7521 sparc.cc:3583 tilegx.cc:4706 +#: x86_64.cc:3465 x86_64.cc:4205 #, c-format -msgid "local symbol %u has bad shndx %u" +msgid "unexpected reloc %u in object file" msgstr "" -#: i386.cc:1991 +#: i386.cc:3002 msgid "both SUN and GNU model TLS relocations" msgstr "" -#: i386.cc:2730 x86_64.cc:2719 +#: i386.cc:3572 +#, c-format +msgid "unsupported reloc %u in object file" +msgstr "" + +#: i386.cc:3802 x86_64.cc:4459 #, c-format msgid "failed to match split-stack sequence at section %u offset %0zx" msgstr "" -#: icf.cc:616 +#: icf.cc:768 #, c-format msgid "%s: ICF Converged after %u iteration(s)" msgstr "" -#: icf.cc:619 +#: icf.cc:771 #, c-format msgid "%s: ICF stopped after %u iteration(s)" msgstr "" -#: icf.cc:633 +#: icf.cc:785 #, c-format msgid "Could not find symbol %s to unfold\n" msgstr "" -#: incremental.cc:242 +#: incremental.cc:80 +msgid "** incremental_inputs" +msgstr "" + +#: incremental.cc:145 #, c-format msgid "the link might take longer: cannot perform incremental link: %s" msgstr "" -#: incremental.cc:302 +#: incremental.cc:411 msgid "no incremental data from previous build" msgstr "" -#: incremental.cc:309 incremental.cc:332 -msgid "invalid incremental build data" -msgstr "" - -#: incremental.cc:321 +#: incremental.cc:417 msgid "different version of incremental build data" msgstr "" -#: incremental.cc:338 +#: incremental.cc:429 msgid "command line changed" msgstr "" -#: incremental.cc:362 +#: incremental.cc:456 +#, c-format +msgid "%s: script file changed" +msgstr "" + +#: incremental.cc:859 #, c-format msgid "unsupported ELF machine number %d" msgstr "" -#: incremental.cc:387 +#: incremental.cc:867 object.cc:3063 +#, c-format +msgid "%s: incompatible target" +msgstr "" + +#: incremental.cc:889 msgid "output is not an ELF file." msgstr "" -#: incremental.cc:410 +#: incremental.cc:912 msgid "unsupported file: 32-bit, big-endian" msgstr "" -#: incremental.cc:419 +#: incremental.cc:921 msgid "unsupported file: 32-bit, little-endian" msgstr "" -#: incremental.cc:431 +#: incremental.cc:933 msgid "unsupported file: 64-bit, big-endian" msgstr "" -#: incremental.cc:440 +#: incremental.cc:942 msgid "unsupported file: 64-bit, little-endian" msgstr "" -#: layout.cc:1887 +#: incremental.cc:2078 +msgid "COMDAT group has no signature" +msgstr "" + +#: incremental.cc:2084 +#, c-format +msgid "COMDAT group %s included twice in incremental link" +msgstr "" + +#: int_encoding.cc:50 int_encoding.cc:83 +msgid "Unusually large LEB128 decoded, debug information may be corrupted" +msgstr "" + +#: layout.cc:225 +#, c-format +msgid "%s: total free lists: %u\n" +msgstr "" + +#: layout.cc:227 +#, c-format +msgid "%s: total free list nodes: %u\n" +msgstr "" + +#: layout.cc:229 +#, c-format +msgid "%s: calls to Free_list::remove: %u\n" +msgstr "" + +#: layout.cc:231 layout.cc:235 +#, c-format +msgid "%s: nodes visited: %u\n" +msgstr "" + +#: layout.cc:233 +#, c-format +msgid "%s: calls to Free_list::allocate: %u\n" +msgstr "" + +#: layout.cc:946 +#, c-format +msgid "" +"Unable to create output section '%s' because it is not allowed by the " +"SECTIONS clause of the linker script" +msgstr "" + +#: layout.cc:2015 +msgid "" +"multiple '.interp' sections in input files may cause confusing PT_INTERP " +"segment" +msgstr "" + +#: layout.cc:2079 +#, c-format +msgid "%s: missing .note.GNU-stack section implies executable stack" +msgstr "" + +#: layout.cc:2091 +#, c-format +msgid "%s: requires executable stack" +msgstr "" + +#: layout.cc:2590 +#, c-format +msgid "unable to open --section-ordering-file file %s: %s" +msgstr "" + +#: layout.cc:3024 #, c-format msgid "--build-id=uuid failed: could not open /dev/urandom: %s" msgstr "" -#: layout.cc:1894 +#: layout.cc:3031 #, c-format msgid "/dev/urandom: read failed: %s" msgstr "" -#: layout.cc:1896 +#: layout.cc:3033 #, c-format msgid "/dev/urandom: expected %zu bytes, got %zd bytes" msgstr "" -#: layout.cc:1918 +#: layout.cc:3055 #, c-format msgid "--build-id argument '%s' not a valid hex number" msgstr "" -#: layout.cc:1924 +#: layout.cc:3061 #, c-format msgid "unrecognized --build-id argument '%s'" msgstr "" -#: layout.cc:2337 +#: layout.cc:3626 #, c-format msgid "load segment overlap [0x%llx -> 0x%llx] and [0x%llx -> 0x%llx]" msgstr "" +#: layout.cc:3785 output.cc:4557 +#, c-format +msgid "out of patch space for section %s; relink with --incremental-full" +msgstr "" + +#: layout.cc:3794 output.cc:4565 +#, c-format +msgid "%s: section changed size; relink with --incremental-full" +msgstr "" + +#: layout.cc:4051 +msgid "out of patch space for symbol table; relink with --incremental-full" +msgstr "" + +#: layout.cc:4122 +msgid "" +"out of patch space for section header table; relink with --incremental-full" +msgstr "" + +#: layout.cc:4840 +msgid "read-only segment has dynamic relocations" +msgstr "" + +#: layout.cc:4843 +msgid "shared library text segment is not shareable" +msgstr "" + #: mapfile.cc:70 #, c-format msgid "cannot open map file %s: %s" @@ -763,7 +1191,7 @@ msgid "" "\n" msgstr "" -#: mapfile.cc:361 +#: mapfile.cc:367 #, c-format msgid "" "\n" @@ -771,162 +1199,168 @@ msgid "" "\n" msgstr "" -#: merge.cc:455 +#: merge.cc:493 #, c-format msgid "%s: %s merged constants size: %lu; input: %zu; output: %zu\n" msgstr "" -#: merge.cc:478 +#: merge.cc:520 msgid "mergeable string section length not multiple of character size" msgstr "" -#: merge.cc:494 +#: merge.cc:529 #, c-format msgid "%s: last entry in mergeable string section '%s' not null terminated" msgstr "" -#: merge.cc:613 +#: merge.cc:604 #, c-format -msgid "%s: %s input: %zu\n" +msgid "" +"%s: section %s contains incorrectly aligned strings; the alignment of those " +"strings won't be preserved" msgstr "" -#: merge.h:300 -msgid "** merge constants" +#: merge.cc:726 +#, c-format +msgid "%s: %s input bytes: %zu\n" msgstr "" -#: merge.h:422 -msgid "** merge strings" +#: merge.cc:728 +#, c-format +msgid "%s: %s input strings: %zu\n" msgstr "" -#: object.cc:75 -msgid "missing SHT_SYMTAB_SHNDX section" +#: merge.h:366 +msgid "** merge constants" msgstr "" -#: object.cc:119 -#, c-format -msgid "symbol %u out of range for SHT_SYMTAB_SHNDX section" +#: merge.h:495 +msgid "** merge strings" msgstr "" -#: object.cc:126 +#: nacl.cc:43 object.cc:174 object.cc:3111 output.cc:5185 #, c-format -msgid "extended index for symbol %u out of range: %u" +msgid "%s: %s" msgstr "" -#: object.cc:148 object.cc:2331 output.cc:4052 -#, c-format -msgid "%s: %s" +#: object.cc:101 +msgid "missing SHT_SYMTAB_SHNDX section" msgstr "" -#: object.cc:190 +#: object.cc:145 #, c-format -msgid "section name section has wrong type: %u" +msgid "symbol %u out of range for SHT_SYMTAB_SHNDX section" msgstr "" -#: object.cc:546 +#: object.cc:152 #, c-format -msgid "invalid symbol table name index: %u" +msgid "extended index for symbol %u out of range: %u" msgstr "" -#: object.cc:552 +#: object.cc:207 #, c-format -msgid "symbol table name section has wrong type: %u" +msgid "section name section has wrong type: %u" msgstr "" -#: object.cc:641 +#: object.cc:914 #, c-format msgid "section group %u info %u out of range" msgstr "" -#: object.cc:660 +#: object.cc:933 #, c-format msgid "symbol %u name offset %u out of range" msgstr "" -#: object.cc:678 +#: object.cc:951 #, c-format msgid "symbol %u invalid section index %u" msgstr "" -#: object.cc:723 +#: object.cc:1003 #, c-format msgid "section %u in section group %u out of range" msgstr "" -#: object.cc:731 +#: object.cc:1011 #, c-format msgid "invalid section group %u refers to earlier section %u" msgstr "" -#: object.cc:1037 reloc.cc:271 reloc.cc:838 +#: object.cc:1380 reloc.cc:290 reloc.cc:939 #, c-format msgid "relocation section %u has bad info %u" msgstr "" -#: object.cc:1231 +#: object.cc:1610 #, c-format msgid "%s: removing unused section from '%s' in file '%s'" msgstr "" -#: object.cc:1257 +#: object.cc:1636 #, c-format msgid "%s: ICF folding section '%s' in file '%s'into '%s' in file '%s'" msgstr "" -#: object.cc:1454 +#: object.cc:1927 msgid "size of symbols is not multiple of symbol size" msgstr "" -#: object.cc:1563 +#: object.cc:2156 #, c-format msgid "local symbol %u section name out of range: %u >= %u" msgstr "" -#: object.cc:1652 +#: object.cc:2246 #, c-format msgid "unknown section index %u for local symbol %u" msgstr "" -#: object.cc:1661 +#: object.cc:2256 #, c-format msgid "local symbol %u section index %u out of range" msgstr "" -#: object.cc:2169 +#: object.cc:2826 reloc.cc:870 #, c-format -msgid "%s is not supported but is required for %s in %s" +msgid "could not decompress section %s" msgstr "" -#: object.cc:2273 +#: object.cc:2942 #, c-format -msgid "%s: unsupported ELF machine number %d" +msgid "%s is not supported but is required for %s in %s" +msgstr "" + +#: object.cc:3019 +msgid "function " msgstr "" -#: object.cc:2283 +#: object.cc:3053 #, c-format -msgid "%s: incompatible target" +msgid "%s: unsupported ELF machine number %d" msgstr "" -#: object.cc:2347 plugin.cc:1019 +#: object.cc:3127 plugin.cc:1822 #, c-format msgid "%s: not configured to support 32-bit big-endian object" msgstr "" -#: object.cc:2363 plugin.cc:1028 +#: object.cc:3143 plugin.cc:1831 #, c-format msgid "%s: not configured to support 32-bit little-endian object" msgstr "" -#: object.cc:2382 plugin.cc:1040 +#: object.cc:3162 plugin.cc:1843 #, c-format msgid "%s: not configured to support 64-bit big-endian object" msgstr "" -#: object.cc:2398 plugin.cc:1049 +#: object.cc:3178 plugin.cc:1852 #, c-format msgid "%s: not configured to support 64-bit little-endian object" msgstr "" -#: options.cc:156 +#: options.cc:157 #, c-format msgid "" "Usage: %s [options] file...\n" @@ -935,1295 +1369,2029 @@ msgstr "" #. config.guess and libtool.m4 look in ld --help output for the #. string "supported targets". -#: options.cc:164 +#: options.cc:165 #, c-format msgid "%s: supported targets:" msgstr "" -#: options.cc:176 +#: options.cc:174 +#, c-format +msgid "%s: supported emulations:" +msgstr "" + +#: options.cc:186 #, c-format msgid "Report bugs to %s\n" msgstr "" -#: options.cc:193 options.cc:203 options.cc:213 +#: options.cc:203 options.cc:213 options.cc:223 #, c-format msgid "%s: invalid option value (expected an integer): %s" msgstr "" -#: options.cc:223 +#: options.cc:233 options.cc:244 #, c-format msgid "%s: invalid option value (expected a floating point number): %s" msgstr "" -#: options.cc:232 +#: options.cc:253 #, c-format msgid "%s: must take a non-empty argument" msgstr "" -#: options.cc:273 +#: options.cc:294 #, c-format msgid "%s: must take one of the following arguments: %s" msgstr "" -#: options.cc:300 +#: options.cc:325 #, c-format msgid " Supported targets:\n" msgstr "" -#: options.cc:409 +#: options.cc:333 +#, c-format +msgid " Supported emulations:\n" +msgstr "" + +#: options.cc:476 +msgid "invalid argument to --section-start; must be SECTION=ADDRESS" +msgstr "" + +#: options.cc:489 +msgid "--section-start address missing" +msgstr "" + +#: options.cc:498 +#, c-format +msgid "--section-start argument %s is not a valid hex number" +msgstr "" + +#: options.cc:535 #, c-format msgid "unable to parse script file %s" msgstr "" -#: options.cc:417 +#: options.cc:543 #, c-format msgid "unable to parse version script file %s" msgstr "" -#: options.cc:425 +#: options.cc:551 #, c-format msgid "unable to parse dynamic-list script file %s" msgstr "" -#: options.cc:522 +#: options.cc:663 #, c-format msgid "" "format '%s' not supported; treating as elf (supported formats: elf, binary)" msgstr "" -#: options.cc:538 +#: options.cc:705 #, c-format msgid "%s: use the --help option for usage information\n" msgstr "" -#: options.cc:547 +#: options.cc:714 #, c-format msgid "%s: %s: %s\n" msgstr "" -#: options.cc:651 +#: options.cc:818 msgid "unexpected argument" msgstr "" -#: options.cc:664 options.cc:725 +#: options.cc:831 options.cc:892 msgid "missing argument" msgstr "" -#: options.cc:736 +#: options.cc:903 msgid "unknown -z option" msgstr "" -#: options.cc:935 +#: options.cc:1115 #, c-format msgid "ignoring --threads: %s was compiled without thread support" msgstr "" -#: options.cc:942 +#: options.cc:1122 #, c-format msgid "ignoring --thread-count: %s was compiled without thread support" msgstr "" -#: options.cc:981 +#: options.cc:1176 #, c-format msgid "unable to open -retain-symbols-file file %s: %s" msgstr "" -#: options.cc:1003 +#: options.cc:1213 msgid "-shared and -static are incompatible" msgstr "" -#: options.cc:1005 +#: options.cc:1215 msgid "-shared and -pie are incompatible" msgstr "" -#: options.cc:1008 +#: options.cc:1217 +msgid "-pie and -static are incompatible" +msgstr "" + +#: options.cc:1220 msgid "-shared and -r are incompatible" msgstr "" -#: options.cc:1010 +#: options.cc:1222 msgid "-pie and -r are incompatible" msgstr "" -#: options.cc:1014 +#: options.cc:1227 +msgid "-F/--filter may not used without -shared" +msgstr "" + +#: options.cc:1229 +msgid "-f/--auxiliary may not be used without -shared" +msgstr "" + +#: options.cc:1234 msgid "-retain-symbols-file does not yet work with -r" msgstr "" -#: options.cc:1020 +#: options.cc:1240 msgid "binary output format not compatible with -shared or -pie or -r" msgstr "" -#: options.cc:1026 +#: options.cc:1246 #, c-format msgid "--hash-bucket-empty-fraction value %g out of range [0.0, 1.0)" msgstr "" -#: options.cc:1031 +#: options.cc:1251 msgid "" "Options --incremental-changed, --incremental-unchanged, --incremental-" "unknown require the use of --incremental" msgstr "" -#: options.cc:1097 +#: options.cc:1261 +msgid "incremental linking is not compatible with -r" +msgstr "" + +#: options.cc:1263 +msgid "incremental linking is not compatible with --emit-relocs" +msgstr "" + +#: options.cc:1266 +msgid "incremental linking is not compatible with --plugin" +msgstr "" + +#: options.cc:1269 +msgid "ignoring --gc-sections for an incremental link" +msgstr "" + +#: options.cc:1274 +msgid "ignoring --icf for an incremental link" +msgstr "" + +#: options.cc:1279 +msgid "ignoring --compress-debug-sections for an incremental link" +msgstr "" + +#: options.cc:1359 msgid "May not nest groups" msgstr "" -#: options.cc:1109 +#: options.cc:1361 +msgid "may not nest groups in libraries" +msgstr "" + +#: options.cc:1373 msgid "Group end without group start" msgstr "" +#: options.cc:1383 +msgid "may not nest libraries" +msgstr "" + +#: options.cc:1385 +msgid "may not nest libraries in groups" +msgstr "" + +#: options.cc:1397 +msgid "lib end without lib start" +msgstr "" + #. I guess it's neither a long option nor a short option. -#: options.cc:1174 +#: options.cc:1462 msgid "unknown option" msgstr "" -#: options.cc:1201 +#: options.cc:1489 #, c-format msgid "%s: missing group end\n" msgstr "" -#: options.h:571 +#: options.h:624 msgid "Report usage information" msgstr "" -#: options.h:573 +#: options.h:626 msgid "Report version information" msgstr "" -#: options.h:575 +#: options.h:628 msgid "Report version and target information" msgstr "" -#: options.h:584 options.h:635 +#: options.h:637 options.h:712 msgid "Not supported" msgstr "" -#: options.h:585 options.h:636 +#: options.h:638 options.h:713 msgid "Do not copy DT_NEEDED tags from shared libraries" msgstr "" -#: options.h:588 +#: options.h:641 options.h:1289 +msgid "Allow multiple definitions of symbols" +msgstr "" + +#: options.h:642 +msgid "Do not allow multiple definitions" +msgstr "" + +#: options.h:645 msgid "Allow unresolved references in shared libraries" msgstr "" -#: options.h:589 +#: options.h:646 msgid "Do not allow unresolved references in shared libraries" msgstr "" -#: options.h:592 +#: options.h:649 msgid "Only set DT_NEEDED for shared libraries if used" msgstr "" -#: options.h:593 +#: options.h:650 msgid "Always DT_NEEDED for shared libraries" msgstr "" -#: options.h:600 +#: options.h:653 options.h:831 options.h:1197 options.h:1207 +msgid "Ignored" +msgstr "" + +#: options.h:653 +msgid "[ignored]" +msgstr "" + +#: options.h:661 msgid "Set input format" msgstr "" -#: options.h:603 +#: options.h:664 msgid "-l searches for shared libraries" msgstr "" -#: options.h:605 +#: options.h:666 msgid "-l does not search for shared libraries" msgstr "" -#: options.h:609 +#: options.h:669 +msgid "alias for -Bdynamic" +msgstr "" + +#: options.h:671 +msgid "alias for -Bstatic" +msgstr "" + +#: options.h:674 +msgid "Use group name lookup rules for shared library" +msgstr "" + +#: options.h:677 msgid "Bind defined symbols locally" msgstr "" -#: options.h:612 +#: options.h:680 msgid "Bind defined function symbols locally" msgstr "" -#: options.h:615 +#: options.h:683 msgid "Generate build ID note" msgstr "" -#: options.h:616 options.h:655 +#: options.h:684 options.h:740 msgid "[=STYLE]" msgstr "" -#: options.h:619 +#: options.h:688 +msgid "Chunk size for '--build-id=tree'" +msgstr "" + +#: options.h:688 options.h:693 options.h:1086 options.h:1100 options.h:1268 +#: options.h:1287 +msgid "SIZE" +msgstr "" + +#: options.h:692 +msgid "" +"Minimum output file size for '--build-id=tree' to work differently than '--" +"build-id=sha1'" +msgstr "" + +#: options.h:696 msgid "Check segment addresses for overlaps (default)" msgstr "" -#: options.h:620 +#: options.h:697 msgid "Do not check segment addresses for overlaps" msgstr "" -#: options.h:624 options.h:629 +#: options.h:701 options.h:706 msgid "Compress .debug_* sections in the output file" msgstr "" -#: options.h:630 +#: options.h:707 msgid "[none]" msgstr "" -#: options.h:639 +#: options.h:716 +msgid "Output cross reference table" +msgstr "" + +#: options.h:717 +msgid "Do not output cross reference table" +msgstr "" + +#: options.h:720 +msgid "Use DT_INIT_ARRAY for all constructors (default)" +msgstr "" + +#: options.h:721 +msgid "Handle constructors as directed by compiler" +msgstr "" + +#: options.h:724 msgid "Define common symbols" msgstr "" -#: options.h:640 +#: options.h:725 msgid "Do not define common symbols" msgstr "" -#: options.h:642 options.h:644 +#: options.h:727 options.h:729 msgid "Alias for -d" msgstr "" -#: options.h:647 +#: options.h:732 msgid "Turn on debugging" msgstr "" -#: options.h:648 +#: options.h:733 msgid "[all,files,script,task][,...]" msgstr "" -#: options.h:651 +#: options.h:736 msgid "Define a symbol" msgstr "" -#: options.h:651 +#: options.h:736 msgid "SYMBOL=EXPRESSION" msgstr "" -#: options.h:654 +#: options.h:739 msgid "Demangle C++ symbols in log messages" msgstr "" -#: options.h:658 +#: options.h:743 msgid "Do not demangle C++ symbols in log messages" msgstr "" -#: options.h:662 -msgid "Try to detect violations of the One Definition Rule" +#: options.h:747 +msgid "Look for violations of the C++ One Definition Rule" msgstr "" -#: options.h:666 +#: options.h:748 +msgid "Do not look for violations of the C++ One Definition Rule" +msgstr "" + +#: options.h:751 +msgid "Delete all local symbols" +msgstr "" + +#: options.h:753 msgid "Delete all temporary local symbols" msgstr "" -#: options.h:669 +#: options.h:756 msgid "Add data symbols to dynamic symbols" msgstr "" -#: options.h:672 +#: options.h:759 msgid "Add C++ operator new/delete to dynamic symbols" msgstr "" -#: options.h:675 +#: options.h:762 msgid "Add C++ typeinfo to dynamic symbols" msgstr "" -#: options.h:678 +#: options.h:765 msgid "Read a list of dynamic symbols" msgstr "" -#: options.h:678 options.h:732 options.h:766 options.h:893 options.h:921 +#: options.h:765 options.h:873 options.h:896 options.h:964 options.h:1033 +#: options.h:1142 options.h:1190 msgid "FILE" msgstr "" -#: options.h:681 +#: options.h:768 msgid "Set program start address" msgstr "" -#: options.h:681 options.h:908 options.h:910 options.h:912 +#: options.h:768 options.h:1157 options.h:1159 options.h:1161 options.h:1164 +#: options.h:1166 msgid "ADDRESS" msgstr "" -#: options.h:684 +#: options.h:771 msgid "Exclude libraries from automatic export" msgstr "" -#: options.h:688 +#: options.h:775 msgid "Export all dynamic symbols" msgstr "" -#: options.h:689 +#: options.h:776 msgid "Do not export all dynamic symbols (default)" msgstr "" -#: options.h:692 +#: options.h:779 +msgid "Export SYMBOL to dynamic symbol table" +msgstr "" + +#: options.h:779 options.h:807 options.h:893 options.h:1122 options.h:1177 +#: options.h:1234 options.h:1237 +msgid "SYMBOL" +msgstr "" + +#: options.h:782 +msgid "Link big-endian objects." +msgstr "" + +#: options.h:785 +msgid "Link little-endian objects." +msgstr "" + +#: options.h:788 msgid "Create exception frame header" msgstr "" -#: options.h:695 +#: options.h:791 +msgid "(ARM only) Do not warn about objects with incompatible enum sizes" +msgstr "" + +#: options.h:795 +msgid "Auxiliary filter for shared object symbol table" +msgstr "" + +#: options.h:796 options.h:800 +msgid "SHLIB" +msgstr "" + +#: options.h:799 +msgid "Filter for shared object symbol table" +msgstr "" + +#: options.h:803 msgid "Treat warnings as errors" msgstr "" -#: options.h:696 +#: options.h:804 msgid "Do not treat warnings as errors" msgstr "" -#: options.h:699 +#: options.h:807 msgid "Call SYMBOL at unload-time" msgstr "" -#: options.h:699 options.h:729 options.h:873 options.h:915 options.h:936 -#: options.h:939 -msgid "SYMBOL" +#: options.h:810 +msgid "(ARM only) Fix binaries for Cortex-A8 erratum." +msgstr "" + +#: options.h:811 +msgid "(ARM only) Do not fix binaries for Cortex-A8 erratum." msgstr "" -#: options.h:702 +#: options.h:814 +msgid "(ARM only) Fix binaries for ARM1176 erratum." +msgstr "" + +#: options.h:815 +msgid "(ARM only) Do not fix binaries for ARM1176 erratum." +msgstr "" + +#: options.h:818 +msgid "(ARM only) Merge exidx entries in debuginfo." +msgstr "" + +#: options.h:819 +msgid "(ARM only) Do not merge exidx entries in debuginfo." +msgstr "" + +#: options.h:822 +msgid "(ARM only) Rewrite BX rn as MOV pc, rn for ARMv4" +msgstr "" + +#: options.h:826 +msgid "(ARM only) Rewrite BX rn branch to ARMv4 interworking veneer" +msgstr "" + +#: options.h:834 +msgid "Generate .gdb_index section" +msgstr "" + +#: options.h:835 +msgid "Do not generate .gdb_index section" +msgstr "" + +#: options.h:838 +msgid "Enable STB_GNU_UNIQUE symbol binding (default)" +msgstr "" + +#: options.h:839 +msgid "Disable STB_GNU_UNIQUE symbol binding" +msgstr "" + +#: options.h:842 msgid "Set shared library name" msgstr "" -#: options.h:702 options.h:792 +#: options.h:842 options.h:1016 options.h:1050 msgid "FILENAME" msgstr "" -#: options.h:705 +#: options.h:845 msgid "Min fraction of empty buckets in dynamic hash" msgstr "" -#: options.h:706 +#: options.h:846 msgid "FRACTION" msgstr "" -#: options.h:709 +#: options.h:849 msgid "Dynamic hash style" msgstr "" -#: options.h:709 +#: options.h:849 msgid "[sysv,gnu,both]" msgstr "" -#: options.h:713 +#: options.h:853 msgid "Set dynamic linker path" msgstr "" -#: options.h:713 +#: options.h:853 msgid "PROGRAM" msgstr "" -#: options.h:716 -msgid "Work in progress; do not use" +#: options.h:856 +msgid "" +"Do an incremental link if possible; otherwise, do a full link and prepare " +"output for incremental linking" msgstr "" -#: options.h:717 -msgid "Do a full build" +#: options.h:861 +msgid "Do a full link (default)" msgstr "" -#: options.h:720 +#: options.h:864 +msgid "Do a full link and prepare output for incremental linking" +msgstr "" + +#: options.h:868 +msgid "Do an incremental link; exit if not possible" +msgstr "" + +#: options.h:871 +msgid "Set base file for incremental linking (default is output file)" +msgstr "" + +#: options.h:876 msgid "Assume files changed" msgstr "" -#: options.h:723 +#: options.h:879 msgid "Assume files didn't change" msgstr "" -#: options.h:726 +#: options.h:882 msgid "Use timestamps to check files (default)" msgstr "" -#: options.h:729 +#: options.h:885 +msgid "Assume startup files unchanged (files preceding this option)" +msgstr "" + +#: options.h:889 +msgid "Amount of extra space to allocate for patches" +msgstr "" + +#: options.h:890 +msgid "PERCENT" +msgstr "" + +#: options.h:893 msgid "Call SYMBOL at load-time" msgstr "" -#: options.h:732 +#: options.h:896 msgid "Read only symbol values from FILE" msgstr "" -#: options.h:735 +#: options.h:900 +msgid "Map whole files to memory (default on 64-bit hosts)" +msgstr "" + +#: options.h:901 +msgid "Map relevant file parts to memory (default on 32-bit hosts)" +msgstr "" + +#: options.h:904 +msgid "Keep files mapped across passes (default)" +msgstr "" + +#: options.h:905 +msgid "Release mapped files after each pass" +msgstr "" + +#: options.h:908 +msgid "Generate unwind information for PLT (default)" +msgstr "" + +#: options.h:909 +msgid "Do not generate unwind information for PLT" +msgstr "" + +#: options.h:912 msgid "Search for library LIBNAME" msgstr "" -#: options.h:735 +#: options.h:912 msgid "LIBNAME" msgstr "" -#: options.h:738 +#: options.h:915 msgid "Add directory to search path" msgstr "" -#: options.h:738 options.h:813 options.h:816 options.h:820 options.h:887 +#: options.h:915 options.h:1039 options.h:1042 options.h:1046 options.h:1136 msgid "DIR" msgstr "" -#: options.h:741 -msgid "Ignored for compatibility" +#: options.h:918 +msgid "Enable text section reordering for GCC section names (default)" +msgstr "" + +#: options.h:920 +msgid "Disable text section reordering for GCC section names" +msgstr "" + +#: options.h:923 +msgid "Only search directories specified on the command line." +msgstr "" + +#: options.h:927 +msgid "Put read-only non-executable sections in their own segment" msgstr "" -#: options.h:741 +#: options.h:931 +msgid "Set offset between executable and read-only segments" +msgstr "" + +#: options.h:932 +msgid "OFFSET" +msgstr "" + +#: options.h:935 +msgid "Set GNU linker emulation; obsolete" +msgstr "" + +#: options.h:935 msgid "EMULATION" msgstr "" -#: options.h:744 +#: options.h:938 +msgid "Map the output file for writing (default)." +msgstr "" + +#: options.h:939 +msgid "Do not map the output file for writing." +msgstr "" + +#: options.h:942 msgid "Write map file on standard output" msgstr "" -#: options.h:745 +#: options.h:943 msgid "Write map file" msgstr "" -#: options.h:746 +#: options.h:944 msgid "MAPFILENAME" msgstr "" -#: options.h:749 +#: options.h:947 msgid "Do not page align data" msgstr "" -#: options.h:751 +#: options.h:949 msgid "Do not page align data, do not make text readonly" msgstr "" -#: options.h:752 +#: options.h:950 msgid "Page align data, make text readonly" msgstr "" -#: options.h:755 +#: options.h:953 msgid "Enable use of DT_RUNPATH and DT_FLAGS" msgstr "" -#: options.h:756 +#: options.h:954 msgid "Disable use of DT_RUNPATH and DT_FLAGS" msgstr "" -#: options.h:759 +#: options.h:957 msgid "Create an output file even if errors occur" msgstr "" -#: options.h:762 options.h:958 +#: options.h:960 options.h:1270 msgid "Report undefined symbols (even with --shared)" msgstr "" -#: options.h:766 +#: options.h:964 msgid "Set output file name" msgstr "" -#: options.h:769 +#: options.h:967 msgid "Optimize output file size" msgstr "" -#: options.h:769 +#: options.h:967 msgid "LEVEL" msgstr "" -#: options.h:772 +#: options.h:970 msgid "Set output format" msgstr "" -#: options.h:772 +#: options.h:970 msgid "[binary]" msgstr "" -#: options.h:775 options.h:777 +#: options.h:973 options.h:982 +msgid "(ARM only) Ignore for backward compatibility" +msgstr "" + +#: options.h:976 options.h:978 msgid "Create a position independent executable" msgstr "" -#: options.h:782 +#: options.h:985 +msgid "(PowerPC64 only) Align PLT call stubs to fit cache lines" +msgstr "" + +#: options.h:986 +msgid "[=P2ALIGN]" +msgstr "" + +#: options.h:989 +msgid "(PowerPC64 only) PLT call stubs should load r11" +msgstr "" + +#: options.h:990 +msgid "(PowerPC64 only) PLT call stubs should not load r11" +msgstr "" + +#: options.h:993 +msgid "(PowerPC64 only) PLT call stubs with load-load barrier" +msgstr "" + +#: options.h:994 +msgid "(PowerPC64 only) PLT call stubs without barrier" +msgstr "" + +#: options.h:998 msgid "Load a plugin library" msgstr "" -#: options.h:782 +#: options.h:998 msgid "PLUGIN" msgstr "" -#: options.h:784 +#: options.h:1000 msgid "Pass an option to the plugin" msgstr "" -#: options.h:784 +#: options.h:1000 msgid "OPTION" msgstr "" -#: options.h:788 +#: options.h:1004 +msgid "Use posix_fallocate to reserve space in the output file (default)." +msgstr "" + +#: options.h:1006 +msgid "Use fallocate or ftruncate to reserve space." +msgstr "" + +#: options.h:1009 msgid "Preread archive symbols when multi-threaded" msgstr "" -#: options.h:791 +#: options.h:1012 +msgid "Print default output format" +msgstr "" + +#: options.h:1015 msgid "Print symbols defined and used for each input" msgstr "" -#: options.h:795 +#: options.h:1019 msgid "Ignored for SVR4 compatibility" msgstr "" -#: options.h:798 +#: options.h:1022 msgid "Generate relocations in output" msgstr "" -#: options.h:801 +#: options.h:1025 msgid "Generate relocatable output" msgstr "" -#: options.h:804 -msgid "Relax branches on certain targets" +#: options.h:1027 +msgid "Synonym for -r" msgstr "" -#: options.h:807 -msgid "keep only symbols listed in this file" +#: options.h:1030 +msgid "Relax branches on certain targets" msgstr "" -#: options.h:807 -msgid "[file]" +#: options.h:1033 +msgid "keep only symbols listed in this file" msgstr "" -#: options.h:813 options.h:816 +#: options.h:1039 options.h:1042 msgid "Add DIR to runtime search path" msgstr "" -#: options.h:819 +#: options.h:1045 msgid "Add DIR to link time shared library search path" msgstr "" -#: options.h:823 +#: options.h:1049 +msgid "Layout sections in the order specified." +msgstr "" + +#: options.h:1053 +msgid "Set address of section" +msgstr "" + +#: options.h:1053 +msgid "SECTION=ADDRESS" +msgstr "" + +#: options.h:1056 +msgid "Sort common symbols by alignment" +msgstr "" + +#: options.h:1057 +msgid "[={ascending,descending}]" +msgstr "" + +#: options.h:1060 +msgid "" +"Sort sections by name. '--no-text-reorder' will override '--sort-" +"section=name' for .text" +msgstr "" + +#: options.h:1062 +msgid "[none,name]" +msgstr "" + +#: options.h:1066 +msgid "Dynamic tag slots to reserve (default 5)" +msgstr "" + +#: options.h:1067 options.h:1115 options.h:1148 options.h:1150 options.h:1152 +#: options.h:1154 +msgid "COUNT" +msgstr "" + +#: options.h:1070 msgid "Strip all symbols" msgstr "" -#: options.h:825 +#: options.h:1072 msgid "Strip debugging information" msgstr "" -#: options.h:827 +#: options.h:1074 msgid "Emit only debug line number information" msgstr "" -#: options.h:829 -msgid "Strip debug symbols that are unused by gdb (at least versions <= 6.7)" +#: options.h:1076 +msgid "Strip debug symbols that are unused by gdb (at least versions <= 7.4)" msgstr "" -#: options.h:832 +#: options.h:1079 msgid "Strip LTO intermediate code sections" msgstr "" -#: options.h:835 +#: options.h:1082 msgid "" -"(ARM only) The maximum distance from instructions in a group of sections to " -"their stubs. Negative values mean stubs are always after the group. 1 means " -"using default size.\n" +"(ARM, PowerPC only) The maximum distance from instructions in a group of " +"sections to their stubs. Negative values mean stubs are always after " +"(PowerPC before) the group. 1 means use default size.\n" msgstr "" -#: options.h:838 options.h:852 options.h:956 options.h:975 -msgid "SIZE" -msgstr "" - -#: options.h:841 +#: options.h:1089 msgid "" "Use less memory and more disk I/O (included only for compatibility with GNU " "ld)" msgstr "" -#: options.h:845 options.h:848 +#: options.h:1093 options.h:1096 msgid "Generate shared library" msgstr "" -#: options.h:851 +#: options.h:1099 msgid "Stack size when -fsplit-stack function calls non-split" msgstr "" -#: options.h:857 +#: options.h:1105 msgid "Do not link against shared libraries" msgstr "" -#: options.h:860 -msgid "Identical Code Folding. '--icf=safe' folds only ctors and dtors." +#: options.h:1108 +msgid "" +"Identical Code Folding. '--icf=safe' Folds ctors, dtors and functions whose " +"pointers are definitely not taken." msgstr "" -#: options.h:866 +#: options.h:1115 msgid "Number of iterations of ICF (default 2)" msgstr "" -#: options.h:866 options.h:899 options.h:901 options.h:903 options.h:905 -msgid "COUNT" -msgstr "" - -#: options.h:869 +#: options.h:1118 msgid "List folded identical sections on stderr" msgstr "" -#: options.h:870 +#: options.h:1119 msgid "Do not list folded identical sections" msgstr "" -#: options.h:873 +#: options.h:1122 msgid "Do not fold this symbol during ICF" msgstr "" -#: options.h:876 +#: options.h:1125 msgid "Remove unused sections" msgstr "" -#: options.h:877 +#: options.h:1126 msgid "Don't remove unused sections (default)" msgstr "" -#: options.h:880 +#: options.h:1129 msgid "List removed unused sections on stderr" msgstr "" -#: options.h:881 +#: options.h:1130 msgid "Do not list removed unused sections" msgstr "" -#: options.h:884 +#: options.h:1133 msgid "Print resource usage statistics" msgstr "" -#: options.h:887 +#: options.h:1136 msgid "Set target system root directory" msgstr "" -#: options.h:890 +#: options.h:1139 msgid "Print the name of each input file" msgstr "" -#: options.h:893 +#: options.h:1142 msgid "Read linker script" msgstr "" -#: options.h:896 +#: options.h:1145 msgid "Run the linker multi-threaded" msgstr "" -#: options.h:897 +#: options.h:1146 msgid "Do not run the linker multi-threaded" msgstr "" -#: options.h:899 +#: options.h:1148 msgid "Number of threads to use" msgstr "" -#: options.h:901 +#: options.h:1150 msgid "Number of threads to use in initial pass" msgstr "" -#: options.h:903 +#: options.h:1152 msgid "Number of threads to use in middle pass" msgstr "" -#: options.h:905 +#: options.h:1154 msgid "Number of threads to use in final pass" msgstr "" -#: options.h:908 +#: options.h:1157 msgid "Set the address of the bss segment" msgstr "" -#: options.h:910 +#: options.h:1159 msgid "Set the address of the data segment" msgstr "" -#: options.h:912 +#: options.h:1161 options.h:1163 msgid "Set the address of the text segment" msgstr "" -#: options.h:915 +#: options.h:1166 +msgid "Set the address of the rodata segment" +msgstr "" + +#: options.h:1169 +msgid "(PowerPC64 only) Optimize TOC code sequences" +msgstr "" + +#: options.h:1170 +msgid "(PowerPC64 only) Don't optimize TOC code sequences" +msgstr "" + +#: options.h:1173 +msgid "(PowerPC64 only) Sort TOC and GOT sections" +msgstr "" + +#: options.h:1174 +msgid "(PowerPC64 only) Don't sort TOC and GOT sections" +msgstr "" + +#: options.h:1177 msgid "Create undefined reference to SYMBOL" msgstr "" -#: options.h:918 +#: options.h:1180 +msgid "How to handle unresolved symbols" +msgstr "" + +#: options.h:1187 msgid "Synonym for --debug=files" msgstr "" -#: options.h:921 +#: options.h:1190 msgid "Read version script" msgstr "" -#: options.h:924 +#: options.h:1193 msgid "Warn about duplicate common symbols" msgstr "" -#: options.h:925 +#: options.h:1194 msgid "Do not warn about duplicate common symbols (default)" msgstr "" -#: options.h:928 +#: options.h:1200 +msgid "Warn if the stack is executable" +msgstr "" + +#: options.h:1201 +msgid "Do not warn if the stack is executable (default)" +msgstr "" + +#: options.h:1204 +msgid "Don't warn about mismatched input files" +msgstr "" + +#: options.h:1210 msgid "Warn when skipping an incompatible library" msgstr "" -#: options.h:929 +#: options.h:1211 msgid "Don't warn when skipping an incompatible library" msgstr "" -#: options.h:932 +#: options.h:1214 +msgid "Warn if text segment is not shareable" +msgstr "" + +#: options.h:1215 +msgid "Do not warn if text segment is not shareable (default)" +msgstr "" + +#: options.h:1218 +msgid "Report unresolved symbols as warnings" +msgstr "" + +#: options.h:1222 +msgid "Report unresolved symbols as errors" +msgstr "" + +#: options.h:1226 +msgid "(ARM only) Do not warn about objects with incompatible wchar_t sizes" +msgstr "" + +#: options.h:1230 msgid "Include all archive contents" msgstr "" -#: options.h:933 +#: options.h:1231 msgid "Include only needed archive contents" msgstr "" -#: options.h:936 +#: options.h:1234 msgid "Use wrapper functions for SYMBOL" msgstr "" -#: options.h:939 +#: options.h:1237 msgid "Trace references to symbol" msgstr "" -#: options.h:942 +#: options.h:1240 +msgid "Allow unused version in script (default)" +msgstr "" + +#: options.h:1241 +msgid "Do not allow unused version in script" +msgstr "" + +#: options.h:1244 msgid "Default search path for Solaris compatibility" msgstr "" -#: options.h:943 +#: options.h:1245 msgid "PATH" msgstr "" -#: options.h:946 +#: options.h:1248 msgid "Start a library search group" msgstr "" -#: options.h:948 +#: options.h:1250 msgid "End a library search group" msgstr "" -#: options.h:953 +#: options.h:1254 +msgid "Start a library" +msgstr "" + +#: options.h:1256 +msgid "End a library " +msgstr "" + +#: options.h:1259 +msgid "Ignored for GCC linker option compatibility" +msgstr "" + +#: options.h:1265 msgid "Sort dynamic relocs" msgstr "" -#: options.h:954 +#: options.h:1266 msgid "Do not sort dynamic relocs" msgstr "" -#: options.h:956 +#: options.h:1268 msgid "Set common page size to SIZE" msgstr "" -#: options.h:961 +#: options.h:1273 msgid "Mark output as requiring executable stack" msgstr "" -#: options.h:963 +#: options.h:1275 msgid "Mark DSO to be initialized first at runtime" msgstr "" -#: options.h:966 +#: options.h:1278 msgid "Mark object to interpose all DSOs but executable" msgstr "" -#: options.h:969 +#: options.h:1281 msgid "Mark object for lazy runtime binding (default)" msgstr "" -#: options.h:972 +#: options.h:1284 msgid "Mark object requiring immediate process" msgstr "" -#: options.h:975 +#: options.h:1287 msgid "Set maximum page size to SIZE" msgstr "" -#: options.h:978 +#: options.h:1295 msgid "Do not create copy relocs" msgstr "" -#: options.h:980 +#: options.h:1297 msgid "Mark object not to use default search paths" msgstr "" -#: options.h:983 +#: options.h:1300 msgid "Mark DSO non-deletable at runtime" msgstr "" -#: options.h:986 +#: options.h:1303 msgid "Mark DSO not available to dlopen" msgstr "" -#: options.h:989 +#: options.h:1306 msgid "Mark DSO not available to dldump" msgstr "" -#: options.h:992 +#: options.h:1309 msgid "Mark output as not requiring executable stack" msgstr "" -#: options.h:994 +#: options.h:1311 msgid "Mark object for immediate function binding" msgstr "" -#: options.h:997 +#: options.h:1314 msgid "Mark DSO to indicate that needs immediate $ORIGIN processing at runtime" msgstr "" -#: options.h:1000 +#: options.h:1317 msgid "Where possible mark variables read-only after relocation" msgstr "" -#: options.h:1001 +#: options.h:1318 msgid "Don't mark variables read-only after relocation" msgstr "" -#: output.cc:1132 +#: options.h:1320 +msgid "Do not permit relocations in read-only segments" +msgstr "" + +#: options.h:1321 options.h:1323 +msgid "Permit relocations in read-only segments (default)" +msgstr "" + +#: output.cc:1344 msgid "section group retained but group element discarded" msgstr "" -#: output.cc:1860 +#: output.cc:1711 output.cc:1743 +msgid "out of patch space (GOT); relink with --incremental-full" +msgstr "" + +#: output.cc:2372 #, c-format msgid "invalid alignment %lu for section \"%s\"" msgstr "" -#: output.cc:3573 +#: output.cc:4598 #, c-format msgid "dot moves backward in linker script from 0x%llx to 0x%llx" msgstr "" -#: output.cc:3576 +#: output.cc:4601 #, c-format msgid "address of section '%s' moves backward from 0x%llx to 0x%llx" msgstr "" -#: output.cc:3755 +#: output.cc:4965 +#, c-format +msgid "%s: incremental base and output file name are the same" +msgstr "" + +#: output.cc:4972 #, c-format -msgid "nobits section %s may not precede progbits section %s in same segment" +msgid "%s: stat: %s" msgstr "" -#: output.cc:3907 output.cc:3975 +#: output.cc:4977 +#, c-format +msgid "%s: incremental base file is empty" +msgstr "" + +#: output.cc:4989 output.cc:5087 #, c-format msgid "%s: open: %s" msgstr "" -#: output.cc:3996 +#: output.cc:5006 +#, c-format +msgid "%s: read failed: %s" +msgstr "" + +#: output.cc:5011 +#, c-format +msgid "%s: file too short: read only %lld of %lld bytes" +msgstr "" + +#: output.cc:5111 #, c-format msgid "%s: mremap: %s" msgstr "" -#: output.cc:4005 +#: output.cc:5130 #, c-format msgid "%s: mmap: %s" msgstr "" -#: output.cc:4085 +#: output.cc:5222 #, c-format msgid "%s: mmap: failed to allocate %lu bytes for output file: %s" msgstr "" -#: output.cc:4096 +#: output.cc:5240 #, c-format msgid "%s: munmap: %s" msgstr "" -#: output.cc:4115 +#: output.cc:5260 #, c-format msgid "%s: write: unexpected 0 return-value" msgstr "" -#: output.cc:4117 +#: output.cc:5262 #, c-format msgid "%s: write: %s" msgstr "" -#: output.cc:4132 +#: output.cc:5277 #, c-format msgid "%s: close: %s" msgstr "" -#: output.h:520 +#: output.h:501 msgid "** section headers" msgstr "" -#: output.h:565 +#: output.h:551 msgid "** segment headers" msgstr "" -#: output.h:613 +#: output.h:598 msgid "** file header" msgstr "" -#: output.h:833 +#: output.h:824 msgid "** fill" msgstr "" -#: output.h:987 +#: output.h:990 msgid "** string table" msgstr "" -#: output.h:1300 +#: output.h:1513 msgid "** dynamic relocs" msgstr "" -#: output.h:1301 output.h:1637 +#: output.h:1514 output.h:2214 msgid "** relocs" msgstr "" -#: output.h:1662 +#: output.h:2239 msgid "** group" msgstr "" -#: output.h:1774 +#: output.h:2415 msgid "** GOT" msgstr "" -#: output.h:1916 +#: output.h:2597 msgid "** dynamic" msgstr "" -#: output.h:2039 +#: output.h:2734 msgid "** symtab xindex" msgstr "" -#: parameters.cc:172 +#: parameters.cc:221 +msgid "input file does not match -EB/EL option" +msgstr "" + +#: parameters.cc:231 +msgid "-Trodata-segment is meaningless without --rosegment" +msgstr "" + +#: parameters.cc:339 target-select.cc:199 #, c-format msgid "unrecognized output format %s" msgstr "" -#: plugin.cc:106 +#: parameters.cc:352 #, c-format -msgid "%s: could not load plugin library" +msgid "unrecognized emulation %s" msgstr "" -#: plugin.cc:116 +#: parameters.cc:375 +msgid "no supported target for -EB/-EL option" +msgstr "" + +#: plugin.cc:178 +#, c-format +msgid "%s: could not load plugin library: %s" +msgstr "" + +#: plugin.cc:187 #, c-format msgid "%s: could not find onload entry point" msgstr "" -#: plugin.cc:426 -msgid "" -"Input files added by plug-ins in --incremental mode not supported yet.\n" +#: plugin.cc:852 +msgid "input files added by plug-ins in --incremental mode not supported yet" +msgstr "" + +#: powerpc.cc:856 +msgid "missing expected __tls_get_addr call" +msgstr "" + +#: powerpc.cc:1663 powerpc.cc:1865 +#, c-format +msgid "%s: ABI version %d is not compatible with ABI version %d output" +msgstr "" + +#: powerpc.cc:1697 powerpc.cc:1907 +#, c-format +msgid "%s: .opd invalid in abiv%d" +msgstr "" + +#: powerpc.cc:1765 +#, c-format +msgid "%s: unexpected reloc type %u in .opd section" +msgstr "" + +#: powerpc.cc:1776 +#, c-format +msgid "%s: .opd is not a regular array of opd entries" +msgstr "" + +#: powerpc.cc:1843 +#, c-format +msgid "%s: local symbol %d has invalid st_other for ABI version 1" +msgstr "" + +#: powerpc.cc:2420 +#, c-format +msgid "%s:%s exceeds group size" msgstr "" -#: powerpc.cc:1502 sparc.cc:2307 x86_64.cc:1632 +#: powerpc.cc:2643 +#, c-format +msgid "%s:%s: branch in non-executable section, no long branch stub for you" +msgstr "" + +#: powerpc.cc:3966 +msgid "** glink" +msgstr "" + +#: powerpc.cc:4136 powerpc.cc:4500 +#, c-format +msgid "%s: linkage table error against `%s'" +msgstr "" + +#: powerpc.cc:4607 +msgid "** save/restore" +msgstr "" + +#: powerpc.cc:5216 sparc.cc:2212 +msgid "requires unsupported dynamic reloc; recompile with -fPIC" +msgstr "" + +#: powerpc.cc:5289 +#, c-format +msgid "%s: unsupported reloc %u for IFUNC symbol" +msgstr "" + +#: powerpc.cc:6329 sparc.cc:3076 tilegx.cc:4193 x86_64.cc:3114 #, c-format msgid "%s: unsupported REL reloc section" msgstr "" -#: readsyms.cc:191 +#: powerpc.cc:6626 +msgid "__tls_get_addr call lacks marker reloc" +msgstr "" + +#: powerpc.cc:6772 +msgid "call lacks nop, can't restore toc; recompile with -fPIC" +msgstr "" + +#: powerpc.cc:7206 powerpc.cc:7230 +#, c-format +msgid "toc optimization is not supported for %#08x instruction" +msgstr "" + +#: powerpc.cc:7568 +msgid "relocation overflow" +msgstr "" + +#: readsyms.cc:285 #, c-format msgid "%s: file is empty" msgstr "" #. Here we have to handle any other input file types we need. -#: readsyms.cc:575 +#: readsyms.cc:920 #, c-format msgid "%s: not an object or archive" msgstr "" -#: reduced_debug_output.cc:236 +#: reduced_debug_output.cc:187 msgid "" "Debug abbreviations extend beyond .debug_abbrev section; failed to reduce " "debug abbreviations" msgstr "" -#: reduced_debug_output.cc:322 +#: reduced_debug_output.cc:273 msgid "Extremely large compile unit in debug info; failed to reduce debug info" msgstr "" -#: reduced_debug_output.cc:330 +#: reduced_debug_output.cc:281 msgid "" "Debug info extends beyond .debug_info section;failed to reduce debug info" msgstr "" -#: reduced_debug_output.cc:350 reduced_debug_output.cc:392 +#: reduced_debug_output.cc:301 reduced_debug_output.cc:343 msgid "Invalid DIE in debug info; failed to reduce debug info" msgstr "" -#: reduced_debug_output.cc:373 +#: reduced_debug_output.cc:324 msgid "" "Debug info extends beyond .debug_info section; failed to reduce debug info" msgstr "" -#: reloc.cc:297 reloc.cc:858 +#: reloc.cc:317 reloc.cc:959 #, c-format msgid "relocation section %u uses unexpected symbol table %u" msgstr "" -#: reloc.cc:312 reloc.cc:875 +#: reloc.cc:335 reloc.cc:976 #, c-format msgid "unexpected entsize for reloc section %u: %lu != %u" msgstr "" -#: reloc.cc:321 reloc.cc:884 +#: reloc.cc:344 reloc.cc:985 #, c-format msgid "reloc section %u size %lu uneven" msgstr "" -#: reloc.cc:1203 +#: reloc.cc:1367 #, c-format msgid "could not convert call to '%s' to '%s'" msgstr "" -#: reloc.cc:1343 +#: reloc.cc:1527 #, c-format msgid "reloc section size %zu is not a multiple of reloc size %d\n" msgstr "" #. We should only see externally visible symbols in the symbol #. table. -#: resolve.cc:191 +#: resolve.cc:194 msgid "invalid STB_LOCAL symbol in external symbols" msgstr "" #. Any target which wants to handle STB_LOOS, etc., needs to #. define a resolve method. -#: resolve.cc:197 -msgid "unsupported symbol binding" +#: resolve.cc:200 +#, c-format +msgid "unsupported symbol binding %d" msgstr "" #. A dynamic object cannot reference a hidden or internal symbol #. defined in another object. -#: resolve.cc:266 +#: resolve.cc:284 #, c-format msgid "%s symbol '%s' in %s is referenced by DSO %s" msgstr "" -#: resolve.cc:326 +#: resolve.cc:406 #, c-format msgid "common of '%s' overriding smaller common" msgstr "" -#: resolve.cc:331 +#: resolve.cc:411 #, c-format msgid "common of '%s' overidden by larger common" msgstr "" -#: resolve.cc:336 +#: resolve.cc:416 #, c-format msgid "multiple common of '%s'" msgstr "" -#: resolve.cc:442 +#: resolve.cc:458 +#, c-format +msgid "symbol '%s' used as both __thread and non-__thread" +msgstr "" + +#: resolve.cc:501 #, c-format msgid "multiple definition of '%s'" msgstr "" -#: resolve.cc:481 +#: resolve.cc:540 #, c-format msgid "definition of '%s' overriding common" msgstr "" -#: resolve.cc:516 +#: resolve.cc:575 #, c-format msgid "definition of '%s' overriding dynamic common definition" msgstr "" -#: resolve.cc:636 +#: resolve.cc:725 #, c-format msgid "common '%s' overridden by previous definition" msgstr "" -#: resolve.cc:766 resolve.cc:778 +#: resolve.cc:860 +msgid "COPY reloc" +msgstr "" + +#: resolve.cc:864 resolve.cc:887 msgid "command line" msgstr "" -#: script-sections.cc:690 +#: resolve.cc:867 +msgid "linker script" +msgstr "" + +#: resolve.cc:871 +msgid "linker defined" +msgstr "" + +#: script-sections.cc:105 +#, c-format +msgid "section %s overflows end of region %s" +msgstr "" + +#: script-sections.cc:646 +msgid "Attempt to set a memory region for a non-output section" +msgstr "" + +#: script-sections.cc:952 script-sections.cc:3583 msgid "dot may not move backward" msgstr "" -#: script-sections.cc:757 +#: script-sections.cc:1019 msgid "** expression" msgstr "" -#: script-sections.cc:941 +#: script-sections.cc:1204 msgid "fill value is not absolute" msgstr "" -#: script-sections.cc:1913 +#: script-sections.cc:2348 #, c-format msgid "alignment of section %s is not absolute" msgstr "" -#: script-sections.cc:1957 +#: script-sections.cc:2449 #, c-format msgid "subalign of section %s is not absolute" msgstr "" -#: script-sections.cc:1972 +#: script-sections.cc:2464 #, c-format msgid "fill of section %s is not absolute" msgstr "" -#: script-sections.cc:2048 +#: script-sections.cc:2577 msgid "SPECIAL constraints are not implemented" msgstr "" -#: script-sections.cc:2090 +#: script-sections.cc:2619 msgid "mismatched definition for constrained sections" msgstr "" -#: script-sections.cc:2634 +#: script-sections.cc:3095 +#, c-format +msgid "region '%.*s' already defined" +msgstr "" + +#: script-sections.cc:3321 msgid "DATA_SEGMENT_ALIGN may only appear once in a linker script" msgstr "" -#: script-sections.cc:2649 +#: script-sections.cc:3336 msgid "DATA_SEGMENT_RELRO_END may only appear once in a linker script" msgstr "" -#: script-sections.cc:2654 +#: script-sections.cc:3341 msgid "DATA_SEGMENT_RELRO_END must follow DATA_SEGMENT_ALIGN" msgstr "" -#: script-sections.cc:2826 +#: script-sections.cc:3519 msgid "no matching section constraint" msgstr "" -#: script-sections.cc:3151 +#: script-sections.cc:3914 +msgid "" +"creating a segment to contain the file and program headers outside of any " +"MEMORY region" +msgstr "" + +#: script-sections.cc:3963 msgid "TLS sections are not adjacent" msgstr "" -#: script-sections.cc:3280 -msgid "allocated section not in any segment" +#: script-sections.cc:4110 +#, c-format +msgid "allocated section %s not in any segment" msgstr "" -#: script-sections.cc:3309 +#: script-sections.cc:4156 #, c-format msgid "no segment %s" msgstr "" -#: script-sections.cc:3323 +#: script-sections.cc:4169 msgid "section in two PT_LOAD segments" msgstr "" -#: script-sections.cc:3330 +#: script-sections.cc:4176 msgid "allocated section not in any PT_LOAD segment" msgstr "" -#: script-sections.cc:3358 +#: script-sections.cc:4205 msgid "may only specify load address for PT_LOAD segment" msgstr "" -#: script-sections.cc:3382 +#: script-sections.cc:4231 #, c-format msgid "PHDRS load address overrides section %s load address" msgstr "" #. We could support this if we wanted to. -#: script-sections.cc:3393 +#: script-sections.cc:4242 msgid "using only one of FILEHDR and PHDRS is not currently supported" msgstr "" -#: script-sections.cc:3408 +#: script-sections.cc:4257 msgid "" "sections loaded on first page without room for file and program headers are " "not supported" msgstr "" -#: script-sections.cc:3414 +#: script-sections.cc:4263 msgid "" "using FILEHDR and PHDRS on more than one PT_LOAD segment is not currently " "supported" msgstr "" -#: script.cc:1072 +#: script.cc:1132 msgid "invalid use of PROVIDE for dot symbol" msgstr "" -#: script.cc:2132 +#: script.cc:1508 +#, c-format +msgid "%s: SECTIONS seen after other input files; try -T/--script" +msgstr "" + +#. We have a match for both the global and local entries for a +#. version tag. That's got to be wrong. +#: script.cc:2212 +#, c-format +msgid "" +"'%s' appears as both a global and a local symbol for version '%s' in script" +msgstr "" + +#: script.cc:2239 +#, c-format +msgid "wildcard match appears in both version '%s' and '%s' in script" +msgstr "" + +#: script.cc:2244 +#, c-format +msgid "" +"wildcard match appears as both global and local in version '%s' in script" +msgstr "" + +#: script.cc:2329 +#, c-format +msgid "" +"using '%s' as version for '%s' which is also named in version '%s' in script" +msgstr "" + +#: script.cc:2427 +#, c-format +msgid "version script assignment of %s to symbol %s failed: symbol not defined" +msgstr "" + +#: script.cc:2623 #, c-format msgid "%s:%d:%d: %s" msgstr "" +#: script.cc:2689 +msgid "library name must be prefixed with -l" +msgstr "" + #. There are some options that we could handle here--e.g., #. -lLIBRARY. Should we bother? -#: script.cc:2297 +#: script.cc:2816 #, c-format msgid "" "%s:%d:%d: ignoring command OPTION; OPTION is only valid for scripts " "specified via -T/--script" msgstr "" -#: script.cc:2362 +#: script.cc:2881 #, c-format msgid "" "%s:%d:%d: ignoring SEARCH_DIR; SEARCH_DIR is only valid for scripts " "specified via -T/--script" msgstr "" -#: script.cc:2606 script.cc:2620 +#: script.cc:2909 +#, c-format +msgid "%s:%d:%d: invalid use of VERSION in input file" +msgstr "" + +#: script.cc:3025 +#, c-format +msgid "unrecognized version script language '%s'" +msgstr "" + +#: script.cc:3144 script.cc:3158 #, c-format msgid "%s:%d:%d: DATA_SEGMENT_ALIGN not in SECTIONS clause" msgstr "" -#: script.cc:2739 +#: script.cc:3277 msgid "unknown PHDR type (try integer)" msgstr "" -#: stringpool.cc:528 +#: script.cc:3296 +#, c-format +msgid "%s:%d:%d: MEMORY region '%.*s' referred to outside of SECTIONS clause" +msgstr "" + +#: script.cc:3307 +#, c-format +msgid "%s:%d:%d: MEMORY region '%.*s' not declared" +msgstr "" + +#: script.cc:3352 +msgid "unknown MEMORY attribute" +msgstr "" + +#: script.cc:3382 +#, c-format +msgid "undefined memory region '%s' referenced in ORIGIN expression" +msgstr "" + +#: script.cc:3401 +#, c-format +msgid "undefined memory region '%s' referenced in LENGTH expression" +msgstr "" + +#: sparc.cc:4326 +#, c-format +msgid "%s: little endian elf flag set on BE object" +msgstr "" + +#: sparc.cc:4329 +#, c-format +msgid "%s: little endian elf flag clear on LE object" +msgstr "" + +#: stringpool.cc:510 #, c-format msgid "%s: %s entries: %zu; buckets: %zu\n" msgstr "" -#: stringpool.cc:532 +#: stringpool.cc:514 #, c-format msgid "%s: %s entries: %zu\n" msgstr "" -#: stringpool.cc:535 +#: stringpool.cc:517 #, c-format msgid "%s: %s Stringdata structures: %zu\n" msgstr "" -#: symtab.cc:857 +#: symtab.cc:374 +#, c-format +msgid "Cannot export local symbol '%s'" +msgstr "" + +#: symtab.cc:904 #, c-format msgid "%s: reference to %s" msgstr "" -#: symtab.cc:859 +#: symtab.cc:906 #, c-format msgid "%s: definition of %s" msgstr "" -#: symtab.cc:1052 +#: symtab.cc:1104 #, c-format msgid "bad global symbol name offset %u at %zu" msgstr "" -#: symtab.cc:1278 +#: symtab.cc:1358 msgid "--just-symbols does not make sense with a shared object" msgstr "" -#: symtab.cc:1284 +#: symtab.cc:1369 msgid "too few symbol versions" msgstr "" -#: symtab.cc:1333 +#: symtab.cc:1418 #, c-format msgid "bad symbol name offset %u at %zu" msgstr "" -#: symtab.cc:1396 +#: symtab.cc:1481 #, c-format msgid "versym for symbol %zu out of range: %u" msgstr "" -#: symtab.cc:1404 +#: symtab.cc:1489 #, c-format msgid "versym for symbol %zu has no name: %u" msgstr "" -#: symtab.cc:2549 symtab.cc:2681 +#: symtab.cc:2742 symtab.cc:2881 #, c-format msgid "%s: unsupported symbol section 0x%x" msgstr "" -#: symtab.cc:2933 +#: symtab.cc:3155 #, c-format msgid "%s: symbol table entries: %zu; buckets: %zu\n" msgstr "" -#: symtab.cc:2936 +#: symtab.cc:3158 #, c-format msgid "%s: symbol table entries: %zu\n" msgstr "" -#: symtab.cc:3007 +#: symtab.cc:3310 #, c-format msgid "" "while linking %s: symbol '%s' defined in multiple places (possible ODR " "violation):" msgstr "" -#: target-reloc.h:259 -msgid "relocation refers to discarded comdat section" +#: symtab.cc:3319 symtab.cc:3322 +#, c-format +msgid " %s from %s\n" +msgstr "" + +#: target-reloc.h:163 +msgid "internal" msgstr "" -#: target-reloc.h:298 +#: target-reloc.h:166 +msgid "hidden" +msgstr "" + +#: target-reloc.h:169 +msgid "protected" +msgstr "" + +#: target-reloc.h:174 #, c-format -msgid "reloc has bad offset %zu" +msgid "%s symbol '%s' is not defined locally" msgstr "" -#: target.cc:90 +#: target-reloc.h:414 #, c-format -msgid "%s: unsupported ELF file type %d" +msgid "reloc has bad offset %zu" msgstr "" -#: target.cc:157 +#: target.cc:170 #, c-format msgid "linker does not include stack split support required by %s" msgstr "" +#: tilegx.cc:2074 x86_64.cc:1244 +msgid "out of patch space (PLT); relink with --incremental-full" +msgstr "" + +#: tilegx.cc:2724 x86_64.cc:1871 +msgid "TLS_DESC not yet supported for incremental linking" +msgstr "" + +#: tilegx.cc:2779 +msgid "TLS_DESC not yet supported for TILEGX" +msgstr "" + +#: tilegx.cc:3188 x86_64.cc:2257 +#, c-format +msgid "requires unsupported dynamic reloc %u; recompile with -fPIC" +msgstr "" + #: tls.h:59 msgid "TLS relocation out of range" msgstr "" @@ -2233,12 +3401,12 @@ msgid "TLS relocation against invalid instruction" msgstr "" #. This output is intended to follow the GNU standards. -#: version.cc:65 +#: version.cc:66 #, c-format -msgid "Copyright 2008 Free Software Foundation, Inc.\n" +msgid "Copyright 2014 Free Software Foundation, Inc.\n" msgstr "" -#: version.cc:66 +#: version.cc:67 #, c-format msgid "" "This program is free software; you may redistribute it under the terms of\n" @@ -2252,12 +3420,25 @@ msgstr "" msgid "%s failed: %s" msgstr "" -#: x86_64.cc:2184 +#: x86_64.cc:2222 +msgid "" +"requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile " +"with -fPIC" +msgstr "" + +#: x86_64.cc:2242 +#, c-format +msgid "" +"requires dynamic %s reloc against '%s' which may overflow at runtime; " +"recompile with -fPIC" +msgstr "" + +#: x86_64.cc:3776 #, c-format msgid "unsupported reloc type %u" msgstr "" -#: x86_64.cc:2524 +#: x86_64.cc:4211 #, c-format msgid "unsupported reloc %u against local symbol" msgstr "" diff --git a/binutils-2.25/gold/powerpc.cc b/binutils-2.25/gold/powerpc.cc index 880b367..828bc16 100644 --- a/binutils-2.25/gold/powerpc.cc +++ b/binutils-2.25/gold/powerpc.cc @@ -1,6 +1,6 @@ // powerpc.cc -- powerpc target support for gold. -// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by David S. Miller <davem@davemloft.net> // and David Edelsohn <edelsohn@gnu.org> @@ -77,12 +77,19 @@ public: const typename elfcpp::Ehdr<size, big_endian>& ehdr) : Sized_relobj_file<size, big_endian>(name, input_file, offset, ehdr), special_(0), has_small_toc_reloc_(false), opd_valid_(false), - opd_ent_(), access_from_map_(), has14_(), stub_table_() - { } + opd_ent_(), access_from_map_(), has14_(), stub_table_(), + e_flags_(ehdr.get_e_flags()), st_other_() + { + this->set_abiversion(0); + } ~Powerpc_relobj() { } + // Read the symbols then set up st_other vector. + void + do_read_symbols(Read_symbols_data*); + // The .got2 section shndx. unsigned int got2_shndx() const @@ -268,6 +275,22 @@ public: return NULL; } + int + abiversion() const + { return this->e_flags_ & elfcpp::EF_PPC64_ABI; } + + // Set ABI version for input and output + void + set_abiversion(int ver); + + unsigned int + ppc64_local_entry_offset(const Symbol* sym) const + { return elfcpp::ppc64_decode_local_entry(sym->nonvis() >> 3); } + + unsigned int + ppc64_local_entry_offset(unsigned int symndx) const + { return elfcpp::ppc64_decode_local_entry(this->st_other_[symndx] >> 5); } + private: struct Opd_ent { @@ -321,6 +344,12 @@ private: // The stub table to use for a given input section. std::vector<Stub_table<size, big_endian>*> stub_table_; + + // Header e_flags + elfcpp::Elf_Word e_flags_; + + // ELF st_other field for local symbols. + std::vector<unsigned char> st_other_; }; template<int size, bool big_endian> @@ -332,8 +361,10 @@ public: Powerpc_dynobj(const std::string& name, Input_file* input_file, off_t offset, const typename elfcpp::Ehdr<size, big_endian>& ehdr) : Sized_dynobj<size, big_endian>(name, input_file, offset, ehdr), - opd_shndx_(0), opd_ent_() - { } + opd_shndx_(0), opd_ent_(), e_flags_(ehdr.get_e_flags()) + { + this->set_abiversion(0); + } ~Powerpc_dynobj() { } @@ -387,6 +418,14 @@ public: this->opd_ent_[ndx].off = value; } + int + abiversion() const + { return this->e_flags_ & elfcpp::EF_PPC64_ABI; } + + // Set ABI version for input and output. + void + set_abiversion(int ver); + private: // Used to specify extent of executable sections. struct Sec_info @@ -424,6 +463,9 @@ private: // corresponding to the address. Note that in dynamic objects, // offset is *not* relative to the section. std::vector<Opd_ent> opd_ent_; + + // Header e_flags + elfcpp::Elf_Word e_flags_; }; template<int size, bool big_endian> @@ -645,6 +687,13 @@ class Target_powerpc : public Sized_target<size, big_endian> return this->glink_; } + Output_data_glink<size, big_endian>* + glink_section() + { + gold_assert(this->glink_ != NULL); + return this->glink_; + } + bool has_glink() const { return this->glink_ != NULL; } @@ -679,11 +728,25 @@ class Target_powerpc : public Sized_target<size, big_endian> // Return the offset of the first non-reserved PLT entry. unsigned int - first_plt_entry_offset() const; + first_plt_entry_offset() const + { + if (size == 32) + return 0; + if (this->abiversion() >= 2) + return 16; + return 24; + } // Return the size of each PLT entry. unsigned int - plt_entry_size() const; + plt_entry_size() const + { + if (size == 32) + return 4; + if (this->abiversion() >= 2) + return 8; + return 24; + } // Add any special sections for this symbol to the gc work list. // For powerpc64, this adds the code section of a function @@ -743,6 +806,24 @@ class Target_powerpc : public Sized_target<size, big_endian> plt_thread_safe() const { return this->plt_thread_safe_; } + int + abiversion () const + { return this->processor_specific_flags() & elfcpp::EF_PPC64_ABI; } + + void + set_abiversion (int ver) + { + elfcpp::Elf_Word flags = this->processor_specific_flags(); + flags &= ~elfcpp::EF_PPC64_ABI; + flags |= ver & elfcpp::EF_PPC64_ABI; + this->set_processor_specific_flags(flags); + } + + // Offset to to save stack slot + int + stk_toc () const + { return this->abiversion() < 2 ? 40 : 24; } + private: class Track_tls @@ -844,7 +925,7 @@ class Target_powerpc : public Sized_target<size, big_endian> { } static inline int - get_reference_flags(unsigned int r_type); + get_reference_flags(unsigned int r_type, const Target_powerpc* target); inline void local(Symbol_table* symtab, Layout* layout, Target_powerpc* target, @@ -866,7 +947,7 @@ class Target_powerpc : public Sized_target<size, big_endian> inline bool local_reloc_may_be_function_pointer(Symbol_table* , Layout* , Target_powerpc* , - Sized_relobj_file<size, big_endian>* , + Sized_relobj_file<size, big_endian>* relobj, unsigned int , Output_section* , const elfcpp::Rela<size, big_endian>& , @@ -877,8 +958,13 @@ class Target_powerpc : public Sized_target<size, big_endian> // may be folded and we'll still keep function addresses distinct. // That means no reloc is of concern here. if (size == 64) - return false; - // For 32-bit, conservatively assume anything but calls to + { + Powerpc_relobj<size, big_endian>* ppcobj = static_cast + <Powerpc_relobj<size, big_endian>*>(relobj); + if (ppcobj->abiversion() == 1) + return false; + } + // For 32-bit and ELFv2, conservatively assume anything but calls to // function code might be taking the address of the function. return !is_branch_reloc(r_type); } @@ -886,7 +972,7 @@ class Target_powerpc : public Sized_target<size, big_endian> inline bool global_reloc_may_be_function_pointer(Symbol_table* , Layout* , Target_powerpc* , - Sized_relobj_file<size, big_endian>* , + Sized_relobj_file<size, big_endian>* relobj, unsigned int , Output_section* , const elfcpp::Rela<size, big_endian>& , @@ -895,12 +981,18 @@ class Target_powerpc : public Sized_target<size, big_endian> { // As above. if (size == 64) - return false; + { + Powerpc_relobj<size, big_endian>* ppcobj = static_cast + <Powerpc_relobj<size, big_endian>*>(relobj); + if (ppcobj->abiversion() == 1) + return false; + } return !is_branch_reloc(r_type); } static bool - reloc_needs_plt_for_ifunc(Sized_relobj_file<size, big_endian>* object, + reloc_needs_plt_for_ifunc(Target_powerpc<size, big_endian>* target, + Sized_relobj_file<size, big_endian>* object, unsigned int r_type, bool report_err); private: @@ -1355,102 +1447,6 @@ at_tls_transform(uint32_t insn, unsigned int reg) return insn; } -// Modified version of symtab.h class Symbol member -// Given a direct absolute or pc-relative static relocation against -// the global symbol, this function returns whether a dynamic relocation -// is needed. - -template<int size> -bool -needs_dynamic_reloc(const Symbol* gsym, int flags) -{ - // No dynamic relocations in a static link! - if (parameters->doing_static_link()) - return false; - - // A reference to an undefined symbol from an executable should be - // statically resolved to 0, and does not need a dynamic relocation. - // This matches gnu ld behavior. - if (gsym->is_undefined() && !parameters->options().shared()) - return false; - - // A reference to an absolute symbol does not need a dynamic relocation. - if (gsym->is_absolute()) - return false; - - // An absolute reference within a position-independent output file - // will need a dynamic relocation. - if ((flags & Symbol::ABSOLUTE_REF) - && parameters->options().output_is_position_independent()) - return true; - - // A function call that can branch to a local PLT entry does not need - // a dynamic relocation. - if ((flags & Symbol::FUNCTION_CALL) && gsym->has_plt_offset()) - return false; - - // A reference to any PLT entry in a non-position-independent executable - // does not need a dynamic relocation. - // Except due to having function descriptors on powerpc64 we don't define - // functions to their plt code in an executable, so this doesn't apply. - if (size == 32 - && !parameters->options().output_is_position_independent() - && gsym->has_plt_offset()) - return false; - - // A reference to a symbol defined in a dynamic object or to a - // symbol that is preemptible will need a dynamic relocation. - if (gsym->is_from_dynobj() - || gsym->is_undefined() - || gsym->is_preemptible()) - return true; - - // For all other cases, return FALSE. - return false; -} - -// Modified version of symtab.h class Symbol member -// Whether we should use the PLT offset associated with a symbol for -// a relocation. FLAGS is a set of Reference_flags. - -template<int size> -bool -use_plt_offset(const Symbol* gsym, int flags) -{ - // If the symbol doesn't have a PLT offset, then naturally we - // don't want to use it. - if (!gsym->has_plt_offset()) - return false; - - // For a STT_GNU_IFUNC symbol we always have to use the PLT entry. - if (gsym->type() == elfcpp::STT_GNU_IFUNC) - return true; - - // If we are going to generate a dynamic relocation, then we will - // wind up using that, so no need to use the PLT entry. - if (needs_dynamic_reloc<size>(gsym, flags)) - return false; - - // If the symbol is from a dynamic object, we need to use the PLT - // entry. - if (gsym->is_from_dynobj()) - return true; - - // If we are generating a shared object, and this symbol is - // undefined or preemptible, we need to use the PLT entry. - if (parameters->options().shared() - && (gsym->is_undefined() || gsym->is_preemptible())) - return true; - - // If this is a call to a weak undefined symbol, we need to use - // the PLT entry; the symbol may be defined by a library loaded - // at runtime. - if ((flags & Symbol::FUNCTION_CALL) && gsym->is_weak_undefined()) - return true; - - // Otherwise we can use the regular definition. - return false; -} template<int size, bool big_endian> class Powerpc_relocate_functions @@ -1460,7 +1456,10 @@ public: { CHECK_NONE, CHECK_SIGNED, - CHECK_BITFIELD + CHECK_UNSIGNED, + CHECK_BITFIELD, + CHECK_LOW_INSN, + CHECK_HIGH_INSN }; enum Status @@ -1486,12 +1485,20 @@ private: template<int valsize> static inline bool - has_overflow_bitfield(Address value) + has_overflow_unsigned(Address value) { Address limit = static_cast<Address>(1) << ((valsize - 1) >> 1); limit <<= ((valsize - 1) >> 1); limit <<= ((valsize - 1) - 2 * ((valsize - 1) >> 1)); - return value > (limit << 1) - 1 && value + limit > (limit << 1) - 1; + return value > (limit << 1) - 1; + } + + template<int valsize> + static inline bool + has_overflow_bitfield(Address value) + { + return (has_overflow_unsigned<valsize>(value) + && has_overflow_signed<valsize>(value)); } template<int valsize> @@ -1503,6 +1510,11 @@ private: if (has_overflow_signed<valsize>(value)) return STATUS_OVERFLOW; } + else if (overflow == CHECK_UNSIGNED) + { + if (has_overflow_unsigned<valsize>(value)) + return STATUS_OVERFLOW; + } else if (overflow == CHECK_BITFIELD) { if (has_overflow_bitfield<valsize>(value)) @@ -1659,6 +1671,29 @@ public: } }; +// Set ABI version for input and output. + +template<int size, bool big_endian> +void +Powerpc_relobj<size, big_endian>::set_abiversion(int ver) +{ + this->e_flags_ |= ver; + if (this->abiversion() != 0) + { + Target_powerpc<size, big_endian>* target = + static_cast<Target_powerpc<size, big_endian>*>( + parameters->sized_target<size, big_endian>()); + if (target->abiversion() == 0) + target->set_abiversion(this->abiversion()); + else if (target->abiversion() != this->abiversion()) + gold_error(_("%s: ABI version %d is not compatible " + "with ABI version %d output"), + this->name().c_str(), + this->abiversion(), target->abiversion()); + + } +} + // Stash away the index of .got2 or .opd in a relocatable object, if // such a section exists. @@ -1680,6 +1715,14 @@ Powerpc_relobj<size, big_endian>::do_find_special_sections( { unsigned int ndx = (s - pshdrs) / elfcpp::Elf_sizes<size>::shdr_size; this->special_ = ndx; + if (size == 64) + { + if (this->abiversion() == 0) + this->set_abiversion(1); + else if (this->abiversion() > 1) + gold_error(_("%s: .opd invalid in abiv%d"), + this->name().c_str(), this->abiversion()); + } } return Sized_relobj_file<size, big_endian>::do_find_special_sections(sd); } @@ -1790,14 +1833,77 @@ Powerpc_relobj<size, big_endian>::do_read_relocs(Read_relocs_data* rd) } } -// Call Sized_dynobj::do_read_symbols to read the symbols then +// Read the symbols then set up st_other vector. + +template<int size, bool big_endian> +void +Powerpc_relobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd) +{ + this->base_read_symbols(sd); + if (size == 64) + { + const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size; + const unsigned char* const pshdrs = sd->section_headers->data(); + const unsigned int loccount = this->do_local_symbol_count(); + if (loccount != 0) + { + this->st_other_.resize(loccount); + const int sym_size = elfcpp::Elf_sizes<size>::sym_size; + off_t locsize = loccount * sym_size; + const unsigned int symtab_shndx = this->symtab_shndx(); + const unsigned char *psymtab = pshdrs + symtab_shndx * shdr_size; + typename elfcpp::Shdr<size, big_endian> shdr(psymtab); + const unsigned char* psyms = this->get_view(shdr.get_sh_offset(), + locsize, true, false); + psyms += sym_size; + for (unsigned int i = 1; i < loccount; ++i, psyms += sym_size) + { + elfcpp::Sym<size, big_endian> sym(psyms); + unsigned char st_other = sym.get_st_other(); + this->st_other_[i] = st_other; + if ((st_other & elfcpp::STO_PPC64_LOCAL_MASK) != 0) + { + if (this->abiversion() == 0) + this->set_abiversion(2); + else if (this->abiversion() < 2) + gold_error(_("%s: local symbol %d has invalid st_other" + " for ABI version 1"), + this->name().c_str(), i); + } + } + } + } +} + +template<int size, bool big_endian> +void +Powerpc_dynobj<size, big_endian>::set_abiversion(int ver) +{ + this->e_flags_ |= ver; + if (this->abiversion() != 0) + { + Target_powerpc<size, big_endian>* target = + static_cast<Target_powerpc<size, big_endian>*>( + parameters->sized_target<size, big_endian>()); + if (target->abiversion() == 0) + target->set_abiversion(this->abiversion()); + else if (target->abiversion() != this->abiversion()) + gold_error(_("%s: ABI version %d is not compatible " + "with ABI version %d output"), + this->name().c_str(), + this->abiversion(), target->abiversion()); + + } +} + +// Call Sized_dynobj::base_read_symbols to read the symbols then // read .opd from a dynamic object, filling in opd_ent_ vector, template<int size, bool big_endian> void Powerpc_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd) { - Sized_dynobj<size, big_endian>::do_read_symbols(sd); + this->base_read_symbols(sd); if (size == 64) { const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size; @@ -1821,6 +1927,12 @@ Powerpc_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd) if (shdr.get_sh_type() == elfcpp::SHT_PROGBITS && (shdr.get_sh_flags() & elfcpp::SHF_ALLOC) != 0) { + if (this->abiversion() == 0) + this->set_abiversion(1); + else if (this->abiversion() > 1) + gold_error(_("%s: .opd invalid in abiv%d"), + this->name().c_str(), this->abiversion()); + this->opd_shndx_ = (s - pshdrs) / shdr_size; this->opd_address_ = shdr.get_sh_addr(); opd_size = convert_to_section_size_type(shdr.get_sh_size()); @@ -1937,6 +2049,26 @@ Target_powerpc<size, big_endian>::do_define_standard_symbols( 0, false, false); } } + else + { + // Define .TOC. as for 32-bit _GLOBAL_OFFSET_TABLE_ + Symbol *gotsym = symtab->lookup(".TOC.", NULL); + if (gotsym != NULL && gotsym->is_undefined()) + { + Target_powerpc<size, big_endian>* target = + static_cast<Target_powerpc<size, big_endian>*>( + parameters->sized_target<size, big_endian>()); + Output_data_got_powerpc<size, big_endian>* got + = target->got_section(symtab, layout); + symtab->define_in_output_data(".TOC.", NULL, + Symbol_table::PREDEFINED, + got, 0x8000, 0, + elfcpp::STT_OBJECT, + elfcpp::STB_LOCAL, + elfcpp::STV_HIDDEN, 0, + false, false); + } + } } // Set up PowerPC target specific relobj. @@ -2425,28 +2557,40 @@ Target_powerpc<size, big_endian>::Branch_info::make_stub( if (sym != NULL && sym->is_forwarder()) sym = symtab->resolve_forwards(sym); const Sized_symbol<size>* gsym = static_cast<const Sized_symbol<size>*>(sym); + Target_powerpc<size, big_endian>* target = + static_cast<Target_powerpc<size, big_endian>*>( + parameters->sized_target<size, big_endian>()); if (gsym != NULL - ? use_plt_offset<size>(gsym, Scan::get_reference_flags(this->r_type_)) + ? gsym->use_plt_offset(Scan::get_reference_flags(this->r_type_, target)) : this->object_->local_has_plt_offset(this->r_sym_)) { - if (stub_table == NULL) - stub_table = this->object_->stub_table(this->shndx_); - if (stub_table == NULL) + if (size == 64 + && gsym != NULL + && target->abiversion() >= 2 + && !parameters->options().output_is_position_independent() + && !is_branch_reloc(this->r_type_)) + target->glink_section()->add_global_entry(gsym); + else { - // This is a ref from a data section to an ifunc symbol. - stub_table = ifunc_stub_table; + if (stub_table == NULL) + stub_table = this->object_->stub_table(this->shndx_); + if (stub_table == NULL) + { + // This is a ref from a data section to an ifunc symbol. + stub_table = ifunc_stub_table; + } + gold_assert(stub_table != NULL); + if (gsym != NULL) + stub_table->add_plt_call_entry(this->object_, gsym, + this->r_type_, this->addend_); + else + stub_table->add_plt_call_entry(this->object_, this->r_sym_, + this->r_type_, this->addend_); } - gold_assert(stub_table != NULL); - if (gsym != NULL) - stub_table->add_plt_call_entry(this->object_, gsym, - this->r_type_, this->addend_); - else - stub_table->add_plt_call_entry(this->object_, this->r_sym_, - this->r_type_, this->addend_); } else { - unsigned int max_branch_offset; + unsigned long max_branch_offset; if (this->r_type_ == elfcpp::R_POWERPC_REL14 || this->r_type_ == elfcpp::R_POWERPC_REL14_BRTAKEN || this->r_type_ == elfcpp::R_POWERPC_REL14_BRNTAKEN) @@ -2489,6 +2633,8 @@ Target_powerpc<size, big_endian>::Branch_info::make_stub( to = symtab->compute_final_value<size>(gsym, &status); if (status != Symbol_table::CFVS_OK) return; + if (size == 64) + to += this->object_->ppc64_local_entry_offset(gsym); } else { @@ -2503,16 +2649,15 @@ Target_powerpc<size, big_endian>::Branch_info::make_stub( || !symval.has_output_value()) return; to = symval.value(this->object_, 0); + if (size == 64) + to += this->object_->ppc64_local_entry_offset(this->r_sym_); } to += this->addend_; if (stub_table == NULL) stub_table = this->object_->stub_table(this->shndx_); - if (size == 64 && is_branch_reloc(this->r_type_)) + if (size == 64 && target->abiversion() < 2) { unsigned int dest_shndx; - Target_powerpc<size, big_endian>* target = - static_cast<Target_powerpc<size, big_endian>*>( - parameters->sized_target<size, big_endian>()); to = target->symval_for_branch(symtab, to, gsym, this->object_, &dest_shndx); } @@ -2545,8 +2690,12 @@ Target_powerpc<size, big_endian>::do_relax(int pass, unsigned int prev_brlt_size = 0; if (pass == 1) { - bool thread_safe = parameters->options().plt_thread_safe(); - if (size == 64 && !parameters->options().user_set_plt_thread_safe()) + bool thread_safe + = this->abiversion() < 2 && parameters->options().plt_thread_safe(); + if (size == 64 + && this->abiversion() < 2 + && !thread_safe + && !parameters->options().user_set_plt_thread_safe()) { static const char* const thread_starter[] = { @@ -2559,11 +2708,17 @@ Target_powerpc<size, big_endian>::do_relax(int pass, /* libanl */ "getaddrinfo_a", /* libgomp */ + "GOMP_parallel", "GOMP_parallel_start", + "GOMP_parallel_loop_static", "GOMP_parallel_loop_static_start", + "GOMP_parallel_loop_dynamic", "GOMP_parallel_loop_dynamic_start", + "GOMP_parallel_loop_guided", "GOMP_parallel_loop_guided_start", + "GOMP_parallel_loop_runtime", "GOMP_parallel_loop_runtime_start", + "GOMP_parallel_sections", "GOMP_parallel_sections_start", }; @@ -2712,7 +2867,21 @@ Target_powerpc<size, big_endian>::do_plt_fde_location(const Output_data* plt, if (plt == this->glink_) { // See Output_data_glink::do_write() for glink contents. - if (size == 64) + if (len == 0) + { + gold_assert(parameters->doing_static_link()); + // Static linking may need stubs, to support ifunc and long + // branches. We need to create an output section for + // .eh_frame early in the link process, to have a place to + // attach stub .eh_frame info. We also need to have + // registered a CIE that matches the stub CIE. Both of + // these requirements are satisfied by creating an FDE and + // CIE for .glink, even though static linking will leave + // .glink zero length. + // ??? Hopefully generating an FDE with a zero address range + // won't confuse anything that consumes .eh_frame info. + } + else if (size == 64) { // There is one word before __glink_PLTresolve address += 8; @@ -2724,7 +2893,7 @@ Target_powerpc<size, big_endian>::do_plt_fde_location(const Output_data* plt, // The first covers the branch table, the second // __glink_PLTresolve at the end of glink. off_t resolve_size = this->glink_->pltresolve_size; - if (oview[9] == 0) + if (oview[9] == elfcpp::DW_CFA_nop) len -= resolve_size; else { @@ -2758,12 +2927,10 @@ class Output_data_plt_powerpc : public Output_section_data_build Output_data_plt_powerpc(Target_powerpc<size, big_endian>* targ, Reloc_section* plt_rel, - unsigned int reserved_size, const char* name) : Output_section_data_build(size == 32 ? 4 : 8), rel_(plt_rel), targ_(targ), - initial_plt_entry_size_(reserved_size), name_(name) { } @@ -2790,20 +2957,10 @@ class Output_data_plt_powerpc : public Output_section_data_build { if (this->current_data_size() == 0) return 0; - return ((this->current_data_size() - this->initial_plt_entry_size_) - / plt_entry_size); + return ((this->current_data_size() - this->first_plt_entry_offset()) + / this->plt_entry_size()); } - // Return the offset of the first non-reserved PLT entry. - unsigned int - first_plt_entry_offset() - { return this->initial_plt_entry_size_; } - - // Return the size of a PLT entry. - static unsigned int - get_plt_entry_size() - { return plt_entry_size; } - protected: void do_adjust_output_section(Output_section* os) @@ -2817,8 +2974,22 @@ class Output_data_plt_powerpc : public Output_section_data_build { mapfile->print_output_data(this, this->name_); } private: - // The size of an entry in the PLT. - static const int plt_entry_size = size == 32 ? 4 : 24; + // Return the offset of the first non-reserved PLT entry. + unsigned int + first_plt_entry_offset() const + { + // IPLT has no reserved entry. + if (this->name_[3] == 'I') + return 0; + return this->targ_->first_plt_entry_offset(); + } + + // Return the size of each PLT entry. + unsigned int + plt_entry_size() const + { + return this->targ_->plt_entry_size(); + } // Write out the PLT data. void @@ -2828,8 +2999,6 @@ class Output_data_plt_powerpc : public Output_section_data_build Reloc_section* rel_; // Allows access to .glink for do_write. Target_powerpc<size, big_endian>* targ_; - // The size of the first reserved entry. - int initial_plt_entry_size_; // What to report in map file. const char *name_; }; @@ -2849,7 +3018,7 @@ Output_data_plt_powerpc<size, big_endian>::add_entry(Symbol* gsym) gsym->set_needs_dynsym_entry(); unsigned int dynrel = elfcpp::R_POWERPC_JMP_SLOT; this->rel_->add_global(gsym, dynrel, this, off, 0); - off += plt_entry_size; + off += this->plt_entry_size(); this->set_current_data_size(off); } } @@ -2865,10 +3034,10 @@ Output_data_plt_powerpc<size, big_endian>::add_ifunc_entry(Symbol* gsym) section_size_type off = this->current_data_size(); gsym->set_plt_offset(off); unsigned int dynrel = elfcpp::R_POWERPC_IRELATIVE; - if (size == 64) + if (size == 64 && this->targ_->abiversion() < 2) dynrel = elfcpp::R_PPC64_JMP_IREL; this->rel_->add_symbolless_global_addend(gsym, dynrel, this, off, 0); - off += plt_entry_size; + off += this->plt_entry_size(); this->set_current_data_size(off); } } @@ -2886,11 +3055,11 @@ Output_data_plt_powerpc<size, big_endian>::add_local_ifunc_entry( section_size_type off = this->current_data_size(); relobj->set_local_plt_offset(local_sym_index, off); unsigned int dynrel = elfcpp::R_POWERPC_IRELATIVE; - if (size == 64) + if (size == 64 && this->targ_->abiversion() < 2) dynrel = elfcpp::R_PPC64_JMP_IREL; this->rel_->add_symbolless_local_addend(relobj, local_sym_index, dynrel, this, off, 0); - off += plt_entry_size; + off += this->plt_entry_size(); this->set_current_data_size(off); } } @@ -2900,50 +3069,52 @@ static const uint32_t add_2_2_11 = 0x7c425a14; static const uint32_t add_3_3_2 = 0x7c631214; static const uint32_t add_3_3_13 = 0x7c636a14; static const uint32_t add_11_0_11 = 0x7d605a14; -static const uint32_t add_12_2_11 = 0x7d825a14; -static const uint32_t add_12_12_11 = 0x7d8c5a14; -static const uint32_t addi_11_11 = 0x396b0000; -static const uint32_t addi_12_12 = 0x398c0000; +static const uint32_t add_11_2_11 = 0x7d625a14; +static const uint32_t add_11_11_2 = 0x7d6b1214; +static const uint32_t addi_0_12 = 0x380c0000; static const uint32_t addi_2_2 = 0x38420000; -static const uint32_t addi_3_2 = 0x38620000; static const uint32_t addi_3_3 = 0x38630000; +static const uint32_t addi_11_11 = 0x396b0000; +static const uint32_t addi_12_12 = 0x398c0000; static const uint32_t addis_0_2 = 0x3c020000; static const uint32_t addis_0_13 = 0x3c0d0000; +static const uint32_t addis_3_2 = 0x3c620000; +static const uint32_t addis_3_13 = 0x3c6d0000; +static const uint32_t addis_11_2 = 0x3d620000; static const uint32_t addis_11_11 = 0x3d6b0000; static const uint32_t addis_11_30 = 0x3d7e0000; -static const uint32_t addis_12_12 = 0x3d8c0000; static const uint32_t addis_12_2 = 0x3d820000; -static const uint32_t addis_3_2 = 0x3c620000; -static const uint32_t addis_3_13 = 0x3c6d0000; +static const uint32_t addis_12_12 = 0x3d8c0000; static const uint32_t b = 0x48000000; static const uint32_t bcl_20_31 = 0x429f0005; static const uint32_t bctr = 0x4e800420; static const uint32_t blr = 0x4e800020; -static const uint32_t blrl = 0x4e800021; static const uint32_t bnectr_p4 = 0x4ce20420; static const uint32_t cmpldi_2_0 = 0x28220000; static const uint32_t cror_15_15_15 = 0x4def7b82; static const uint32_t cror_31_31_31 = 0x4ffffb82; static const uint32_t ld_0_1 = 0xe8010000; static const uint32_t ld_0_12 = 0xe80c0000; -static const uint32_t ld_11_12 = 0xe96c0000; -static const uint32_t ld_11_2 = 0xe9620000; static const uint32_t ld_2_1 = 0xe8410000; -static const uint32_t ld_2_11 = 0xe84b0000; -static const uint32_t ld_2_12 = 0xe84c0000; static const uint32_t ld_2_2 = 0xe8420000; +static const uint32_t ld_2_11 = 0xe84b0000; +static const uint32_t ld_11_2 = 0xe9620000; +static const uint32_t ld_11_11 = 0xe96b0000; +static const uint32_t ld_12_2 = 0xe9820000; +static const uint32_t ld_12_11 = 0xe98b0000; +static const uint32_t ld_12_12 = 0xe98c0000; static const uint32_t lfd_0_1 = 0xc8010000; static const uint32_t li_0_0 = 0x38000000; static const uint32_t li_12_0 = 0x39800000; static const uint32_t lis_0_0 = 0x3c000000; static const uint32_t lis_11 = 0x3d600000; static const uint32_t lis_12 = 0x3d800000; +static const uint32_t lvx_0_12_0 = 0x7c0c00ce; static const uint32_t lwz_0_12 = 0x800c0000; static const uint32_t lwz_11_11 = 0x816b0000; static const uint32_t lwz_11_30 = 0x817e0000; static const uint32_t lwz_12_12 = 0x818c0000; static const uint32_t lwzu_0_12 = 0x840c0000; -static const uint32_t lvx_0_12_0 = 0x7c0c00ce; static const uint32_t mflr_0 = 0x7c0802a6; static const uint32_t mflr_11 = 0x7d6802a6; static const uint32_t mflr_12 = 0x7d8802a6; @@ -2954,13 +3125,16 @@ static const uint32_t mtlr_0 = 0x7c0803a6; static const uint32_t mtlr_12 = 0x7d8803a6; static const uint32_t nop = 0x60000000; static const uint32_t ori_0_0_0 = 0x60000000; +static const uint32_t srdi_0_0_2 = 0x7800f082; static const uint32_t std_0_1 = 0xf8010000; static const uint32_t std_0_12 = 0xf80c0000; static const uint32_t std_2_1 = 0xf8410000; static const uint32_t stfd_0_1 = 0xd8010000; static const uint32_t stvx_0_12_0 = 0x7c0c01ce; static const uint32_t sub_11_11_12 = 0x7d6c5850; -static const uint32_t xor_11_11_11 = 0x7d6b5a78; +static const uint32_t sub_12_12_11 = 0x7d8b6050; +static const uint32_t xor_2_12_12 = 0x7d826278; +static const uint32_t xor_11_12_12 = 0x7d8b6278; // Write out the PLT. @@ -3019,7 +3193,6 @@ Target_powerpc<size, big_endian>::make_plt_section(Symbol_table* symtab, ORDER_DYNAMIC_PLT_RELOCS, false); this->plt_ = new Output_data_plt_powerpc<size, big_endian>(this, plt_rel, - size == 32 ? 0 : 24, "** PLT"); layout->add_output_section_data(".plt", (size == 32 @@ -3049,7 +3222,7 @@ Target_powerpc<size, big_endian>::make_iplt_section(Symbol_table* symtab, this->rela_dyn_->output_section()->add_output_section_data(iplt_rel); this->iplt_ = new Output_data_plt_powerpc<size, big_endian>(this, iplt_rel, - 0, "** IPLT"); + "** IPLT"); this->plt_->output_section()->add_output_section_data(this->iplt_); } } @@ -3225,8 +3398,8 @@ const unsigned char Eh_cie<size>::eh_frame_cie[] = elfcpp::DW_CFA_def_cfa, 1, 0 // def_cfa: r1 offset 0. }; -// Describe __glink_PLTresolve use of LR, 64-bit version. -static const unsigned char glink_eh_frame_fde_64[] = +// Describe __glink_PLTresolve use of LR, 64-bit version ABIv1. +static const unsigned char glink_eh_frame_fde_64v1[] = { 0, 0, 0, 0, // Replaced with offset to .glink. 0, 0, 0, 0, // Replaced with size of .glink. @@ -3237,6 +3410,18 @@ static const unsigned char glink_eh_frame_fde_64[] = elfcpp::DW_CFA_restore_extended, 65 }; +// Describe __glink_PLTresolve use of LR, 64-bit version ABIv2. +static const unsigned char glink_eh_frame_fde_64v2[] = +{ + 0, 0, 0, 0, // Replaced with offset to .glink. + 0, 0, 0, 0, // Replaced with size of .glink. + 0, // Augmentation size. + elfcpp::DW_CFA_advance_loc + 1, + elfcpp::DW_CFA_register, 65, 0, + elfcpp::DW_CFA_advance_loc + 4, + elfcpp::DW_CFA_restore_extended, 65 +}; + // Describe __glink_PLTresolve use of LR, 32-bit version. static const unsigned char glink_eh_frame_fde_32[] = { @@ -3493,13 +3678,16 @@ class Stub_table : public Output_relaxed_input_section <const Powerpc_relobj<size, big_endian>*>(p->first.object_); got_addr += ppcobj->toc_base_offset(); Address off = plt_addr - got_addr; - bool static_chain = parameters->options().plt_static_chain(); - bool thread_safe = this->targ_->plt_thread_safe(); - unsigned int bytes = (4 * 5 - + 4 * static_chain - + 8 * thread_safe - + 4 * (ha(off) != 0) - + 4 * (ha(off + 8 + 8 * static_chain) != ha(off))); + unsigned int bytes = 4 * 4 + 4 * (ha(off) != 0); + if (this->targ_->abiversion() < 2) + { + bool static_chain = parameters->options().plt_static_chain(); + bool thread_safe = this->targ_->plt_thread_safe(); + bytes += (4 + + 4 * static_chain + + 8 * thread_safe + + 4 * (ha(off + 8 + 8 * static_chain) != ha(off))); + } unsigned int align = 1 << parameters->options().plt_align(); if (align > 1) bytes = (bytes + align - 1) & -align; @@ -3681,7 +3869,7 @@ Stub_table<size, big_endian>::add_plt_call_entry( Address addend) { Plt_stub_ent ent(object, gsym, r_type, addend); - Address off = this->plt_size_; + unsigned int off = this->plt_size_; std::pair<typename Plt_stub_entries::iterator, bool> p = this->plt_call_stubs_.insert(std::make_pair(ent, off)); if (p.second) @@ -3697,7 +3885,7 @@ Stub_table<size, big_endian>::add_plt_call_entry( Address addend) { Plt_stub_ent ent(object, locsym_index, r_type, addend); - Address off = this->plt_size_; + unsigned int off = this->plt_size_; std::pair<typename Plt_stub_entries::iterator, bool> p = this->plt_call_stubs_.insert(std::make_pair(ent, off)); if (p.second) @@ -3792,41 +3980,30 @@ template<int size, bool big_endian> class Output_data_glink : public Output_section_data { public: + typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; + static const Address invalid_address = static_cast<Address>(0) - 1; static const int pltresolve_size = 16*4; Output_data_glink(Target_powerpc<size, big_endian>* targ) - : Output_section_data(16), targ_(targ) + : Output_section_data(16), targ_(targ), global_entry_stubs_(), + end_branch_table_(), ge_size_(0) { } void - add_eh_frame(Layout* layout) - { - if (!parameters->options().ld_generated_unwind_info()) - return; + add_eh_frame(Layout* layout); - if (size == 64) - layout->add_eh_frame_for_plt(this, - Eh_cie<64>::eh_frame_cie, - sizeof (Eh_cie<64>::eh_frame_cie), - glink_eh_frame_fde_64, - sizeof (glink_eh_frame_fde_64)); - else - { - // 32-bit .glink can use the default since the CIE return - // address reg, LR, is valid. - layout->add_eh_frame_for_plt(this, - Eh_cie<32>::eh_frame_cie, - sizeof (Eh_cie<32>::eh_frame_cie), - default_fde, - sizeof (default_fde)); - // Except where LR is used in a PIC __glink_PLTresolve. - if (parameters->options().output_is_position_independent()) - layout->add_eh_frame_for_plt(this, - Eh_cie<32>::eh_frame_cie, - sizeof (Eh_cie<32>::eh_frame_cie), - glink_eh_frame_fde_32, - sizeof (glink_eh_frame_fde_32)); - } + void + add_global_entry(const Symbol*); + + Address + find_global_entry(const Symbol*) const; + + Address + global_entry_address() const + { + gold_assert(this->is_data_size_valid()); + unsigned int global_entry_off = (this->end_branch_table_ + 15) & -16; + return this->address() + global_entry_off; } protected: @@ -3845,10 +4022,76 @@ class Output_data_glink : public Output_section_data // Allows access to .got and .plt for do_write. Target_powerpc<size, big_endian>* targ_; + + // Map sym to stub offset. + typedef Unordered_map<const Symbol*, unsigned int> Global_entry_stub_entries; + Global_entry_stub_entries global_entry_stubs_; + + unsigned int end_branch_table_, ge_size_; }; template<int size, bool big_endian> void +Output_data_glink<size, big_endian>::add_eh_frame(Layout* layout) +{ + if (!parameters->options().ld_generated_unwind_info()) + return; + + if (size == 64) + { + if (this->targ_->abiversion() < 2) + layout->add_eh_frame_for_plt(this, + Eh_cie<64>::eh_frame_cie, + sizeof (Eh_cie<64>::eh_frame_cie), + glink_eh_frame_fde_64v1, + sizeof (glink_eh_frame_fde_64v1)); + else + layout->add_eh_frame_for_plt(this, + Eh_cie<64>::eh_frame_cie, + sizeof (Eh_cie<64>::eh_frame_cie), + glink_eh_frame_fde_64v2, + sizeof (glink_eh_frame_fde_64v2)); + } + else + { + // 32-bit .glink can use the default since the CIE return + // address reg, LR, is valid. + layout->add_eh_frame_for_plt(this, + Eh_cie<32>::eh_frame_cie, + sizeof (Eh_cie<32>::eh_frame_cie), + default_fde, + sizeof (default_fde)); + // Except where LR is used in a PIC __glink_PLTresolve. + if (parameters->options().output_is_position_independent()) + layout->add_eh_frame_for_plt(this, + Eh_cie<32>::eh_frame_cie, + sizeof (Eh_cie<32>::eh_frame_cie), + glink_eh_frame_fde_32, + sizeof (glink_eh_frame_fde_32)); + } +} + +template<int size, bool big_endian> +void +Output_data_glink<size, big_endian>::add_global_entry(const Symbol* gsym) +{ + std::pair<typename Global_entry_stub_entries::iterator, bool> p + = this->global_entry_stubs_.insert(std::make_pair(gsym, this->ge_size_)); + if (p.second) + this->ge_size_ += 16; +} + +template<int size, bool big_endian> +typename Output_data_glink<size, big_endian>::Address +Output_data_glink<size, big_endian>::find_global_entry(const Symbol* gsym) const +{ + typename Global_entry_stub_entries::const_iterator p + = this->global_entry_stubs_.find(gsym); + return p == this->global_entry_stubs_.end() ? invalid_address : p->second; +} + +template<int size, bool big_endian> +void Output_data_glink<size, big_endian>::set_final_data_size() { unsigned int count = this->targ_->plt_entry_count(); @@ -3869,11 +4112,18 @@ Output_data_glink<size, big_endian>::set_final_data_size() total += this->pltresolve_size; // space for branch table - total += 8 * count; - if (count > 0x8000) - total += 4 * (count - 0x8000); + total += 4 * count; + if (this->targ_->abiversion() < 2) + { + total += 4 * count; + if (count > 0x8000) + total += 4 * (count - 0x8000); + } } } + this->end_branch_table_ = total; + total = (total + 15) & -16; + total += this->ge_size_; this->set_data_size(total); } @@ -3934,8 +4184,11 @@ Stub_table<size, big_endian>::do_write(Output_file* of) cs->first.object_->name().c_str(), cs->first.sym_->demangled_name().c_str()); - bool static_chain = parameters->options().plt_static_chain(); - bool thread_safe = this->targ_->plt_thread_safe(); + bool plt_load_toc = this->targ_->abiversion() < 2; + bool static_chain + = plt_load_toc && parameters->options().plt_static_chain(); + bool thread_safe + = plt_load_toc && this->targ_->plt_thread_safe(); bool use_fake_dep = false; Address cmp_branch_off = 0; if (thread_safe) @@ -3962,47 +4215,88 @@ Stub_table<size, big_endian>::do_write(Output_file* of) p = oview + cs->second; if (ha(off) != 0) { - write_insn<big_endian>(p, std_2_1 + 40), p += 4; - write_insn<big_endian>(p, addis_12_2 + ha(off)), p += 4; - write_insn<big_endian>(p, ld_11_12 + l(off)), p += 4; - if (ha(off + 8 + 8 * static_chain) != ha(off)) + write_insn<big_endian>(p, std_2_1 + this->targ_->stk_toc()); + p += 4; + if (plt_load_toc) + { + write_insn<big_endian>(p, addis_11_2 + ha(off)); + p += 4; + write_insn<big_endian>(p, ld_12_11 + l(off)); + p += 4; + } + else { - write_insn<big_endian>(p, addi_12_12 + l(off)), p += 4; + write_insn<big_endian>(p, addis_12_2 + ha(off)); + p += 4; + write_insn<big_endian>(p, ld_12_12 + l(off)); + p += 4; + } + if (plt_load_toc + && ha(off + 8 + 8 * static_chain) != ha(off)) + { + write_insn<big_endian>(p, addi_11_11 + l(off)); + p += 4; off = 0; } - write_insn<big_endian>(p, mtctr_11), p += 4; - if (use_fake_dep) + write_insn<big_endian>(p, mtctr_12); + p += 4; + if (plt_load_toc) { - write_insn<big_endian>(p, xor_11_11_11), p += 4; - write_insn<big_endian>(p, add_12_12_11), p += 4; + if (use_fake_dep) + { + write_insn<big_endian>(p, xor_2_12_12); + p += 4; + write_insn<big_endian>(p, add_11_11_2); + p += 4; + } + write_insn<big_endian>(p, ld_2_11 + l(off + 8)); + p += 4; + if (static_chain) + { + write_insn<big_endian>(p, ld_11_11 + l(off + 16)); + p += 4; + } } - write_insn<big_endian>(p, ld_2_12 + l(off + 8)), p += 4; - if (static_chain) - write_insn<big_endian>(p, ld_11_12 + l(off + 16)), p += 4; } else { - write_insn<big_endian>(p, std_2_1 + 40), p += 4; - write_insn<big_endian>(p, ld_11_2 + l(off)), p += 4; - if (ha(off + 8 + 8 * static_chain) != ha(off)) + write_insn<big_endian>(p, std_2_1 + this->targ_->stk_toc()); + p += 4; + write_insn<big_endian>(p, ld_12_2 + l(off)); + p += 4; + if (plt_load_toc + && ha(off + 8 + 8 * static_chain) != ha(off)) { - write_insn<big_endian>(p, addi_2_2 + l(off)), p += 4; + write_insn<big_endian>(p, addi_2_2 + l(off)); + p += 4; off = 0; } - write_insn<big_endian>(p, mtctr_11), p += 4; - if (use_fake_dep) + write_insn<big_endian>(p, mtctr_12); + p += 4; + if (plt_load_toc) { - write_insn<big_endian>(p, xor_11_11_11), p += 4; - write_insn<big_endian>(p, add_2_2_11), p += 4; + if (use_fake_dep) + { + write_insn<big_endian>(p, xor_11_12_12); + p += 4; + write_insn<big_endian>(p, add_2_2_11); + p += 4; + } + if (static_chain) + { + write_insn<big_endian>(p, ld_11_2 + l(off + 16)); + p += 4; + } + write_insn<big_endian>(p, ld_2_2 + l(off + 8)); + p += 4; } - if (static_chain) - write_insn<big_endian>(p, ld_11_2 + l(off + 16)), p += 4; - write_insn<big_endian>(p, ld_2_2 + l(off + 8)), p += 4; } if (thread_safe && !use_fake_dep) { - write_insn<big_endian>(p, cmpldi_2_0), p += 4; - write_insn<big_endian>(p, bnectr_p4), p += 4; + write_insn<big_endian>(p, cmpldi_2_0); + p += 4; + write_insn<big_endian>(p, bnectr_p4); + p += 4; write_insn<big_endian>(p, b | (cmp_branch_off & 0x3fffffc)); } else @@ -4031,14 +4325,14 @@ Stub_table<size, big_endian>::do_write(Output_file* of) Address brltoff = brlt_addr - got_addr; if (ha(brltoff) == 0) { - write_insn<big_endian>(p, ld_11_2 + l(brltoff)), p += 4; + write_insn<big_endian>(p, ld_12_2 + l(brltoff)), p += 4; } else { write_insn<big_endian>(p, addis_12_2 + ha(brltoff)), p += 4; - write_insn<big_endian>(p, ld_11_12 + l(brltoff)), p += 4; + write_insn<big_endian>(p, ld_12_12 + l(brltoff)), p += 4; } - write_insn<big_endian>(p, mtctr_11), p += 4; + write_insn<big_endian>(p, mtctr_12), p += 4; write_insn<big_endian>(p, bctr); } } @@ -4173,43 +4467,101 @@ Output_data_glink<size, big_endian>::do_write(Output_file* of) if (size == 64) { - // Write pltresolve stub. - p = oview; - Address after_bcl = this->address() + 16; - Address pltoff = plt_base - after_bcl; - - elfcpp::Swap<64, big_endian>::writeval(p, pltoff), p += 8; - - write_insn<big_endian>(p, mflr_12), p += 4; - write_insn<big_endian>(p, bcl_20_31), p += 4; - write_insn<big_endian>(p, mflr_11), p += 4; - write_insn<big_endian>(p, ld_2_11 + l(-16)), p += 4; - write_insn<big_endian>(p, mtlr_12), p += 4; - write_insn<big_endian>(p, add_12_2_11), p += 4; - write_insn<big_endian>(p, ld_11_12 + 0), p += 4; - write_insn<big_endian>(p, ld_2_12 + 8), p += 4; - write_insn<big_endian>(p, mtctr_11), p += 4; - write_insn<big_endian>(p, ld_11_12 + 16), p += 4; - write_insn<big_endian>(p, bctr), p += 4; - while (p < oview + this->pltresolve_size) - write_insn<big_endian>(p, nop), p += 4; - - // Write lazy link call stubs. - uint32_t indx = 0; - while (p < oview + oview_size) + if (this->end_branch_table_ != 0) { - if (indx < 0x8000) + // Write pltresolve stub. + p = oview; + Address after_bcl = this->address() + 16; + Address pltoff = plt_base - after_bcl; + + elfcpp::Swap<64, big_endian>::writeval(p, pltoff), p += 8; + + if (this->targ_->abiversion() < 2) { - write_insn<big_endian>(p, li_0_0 + indx), p += 4; + write_insn<big_endian>(p, mflr_12), p += 4; + write_insn<big_endian>(p, bcl_20_31), p += 4; + write_insn<big_endian>(p, mflr_11), p += 4; + write_insn<big_endian>(p, ld_2_11 + l(-16)), p += 4; + write_insn<big_endian>(p, mtlr_12), p += 4; + write_insn<big_endian>(p, add_11_2_11), p += 4; + write_insn<big_endian>(p, ld_12_11 + 0), p += 4; + write_insn<big_endian>(p, ld_2_11 + 8), p += 4; + write_insn<big_endian>(p, mtctr_12), p += 4; + write_insn<big_endian>(p, ld_11_11 + 16), p += 4; } else { - write_insn<big_endian>(p, lis_0_0 + hi(indx)), p += 4; - write_insn<big_endian>(p, ori_0_0_0 + l(indx)), p += 4; + write_insn<big_endian>(p, mflr_0), p += 4; + write_insn<big_endian>(p, bcl_20_31), p += 4; + write_insn<big_endian>(p, mflr_11), p += 4; + write_insn<big_endian>(p, ld_2_11 + l(-16)), p += 4; + write_insn<big_endian>(p, mtlr_0), p += 4; + write_insn<big_endian>(p, sub_12_12_11), p += 4; + write_insn<big_endian>(p, add_11_2_11), p += 4; + write_insn<big_endian>(p, addi_0_12 + l(-48)), p += 4; + write_insn<big_endian>(p, ld_12_11 + 0), p += 4; + write_insn<big_endian>(p, srdi_0_0_2), p += 4; + write_insn<big_endian>(p, mtctr_12), p += 4; + write_insn<big_endian>(p, ld_11_11 + 8), p += 4; + } + write_insn<big_endian>(p, bctr), p += 4; + while (p < oview + this->pltresolve_size) + write_insn<big_endian>(p, nop), p += 4; + + // Write lazy link call stubs. + uint32_t indx = 0; + while (p < oview + this->end_branch_table_) + { + if (this->targ_->abiversion() < 2) + { + if (indx < 0x8000) + { + write_insn<big_endian>(p, li_0_0 + indx), p += 4; + } + else + { + write_insn<big_endian>(p, lis_0_0 + hi(indx)), p += 4; + write_insn<big_endian>(p, ori_0_0_0 + l(indx)), p += 4; + } + } + uint32_t branch_off = 8 - (p - oview); + write_insn<big_endian>(p, b + (branch_off & 0x3fffffc)), p += 4; + indx++; + } + } + + Address plt_base = this->targ_->plt_section()->address(); + Address iplt_base = invalid_address; + unsigned int global_entry_off = (this->end_branch_table_ + 15) & -16; + Address global_entry_base = this->address() + global_entry_off; + typename Global_entry_stub_entries::const_iterator ge; + for (ge = this->global_entry_stubs_.begin(); + ge != this->global_entry_stubs_.end(); + ++ge) + { + p = oview + global_entry_off + ge->second; + Address plt_addr = ge->first->plt_offset(); + if (ge->first->type() == elfcpp::STT_GNU_IFUNC + && ge->first->can_use_relative_reloc(false)) + { + if (iplt_base == invalid_address) + iplt_base = this->targ_->iplt_section()->address(); + plt_addr += iplt_base; } - uint32_t branch_off = 8 - (p - oview); - write_insn<big_endian>(p, b + (branch_off & 0x3fffffc)), p += 4; - indx++; + else + plt_addr += plt_base; + Address my_addr = global_entry_base + ge->second; + Address off = plt_addr - my_addr; + + if (off + 0x80008000 > 0xffffffff || (off & 3) != 0) + gold_error(_("%s: linkage table error against `%s'"), + ge->first->object()->name().c_str(), + ge->first->demangled_name().c_str()); + + write_insn<big_endian>(p, addis_12_12 + ha(off)), p += 4; + write_insn<big_endian>(p, ld_12_12 + l(off)), p += 4; + write_insn<big_endian>(p, mtctr_12), p += 4; + write_insn<big_endian>(p, bctr); } } else @@ -4690,24 +5042,6 @@ Target_powerpc<size, big_endian>::plt_entry_count() const return this->plt_->entry_count(); } -// Return the offset of the first non-reserved PLT entry. - -template<int size, bool big_endian> -unsigned int -Target_powerpc<size, big_endian>::first_plt_entry_offset() const -{ - return this->plt_->first_plt_entry_offset(); -} - -// Return the size of each PLT entry. - -template<int size, bool big_endian> -unsigned int -Target_powerpc<size, big_endian>::plt_entry_size() const -{ - return Output_data_plt_powerpc<size, big_endian>::get_plt_entry_size(); -} - // Create a GOT entry for local dynamic __tls_get_addr calls. template<int size, bool big_endian> @@ -4735,8 +5069,12 @@ Target_powerpc<size, big_endian>::tlsld_got_offset( template<int size, bool big_endian> int -Target_powerpc<size, big_endian>::Scan::get_reference_flags(unsigned int r_type) +Target_powerpc<size, big_endian>::Scan::get_reference_flags( + unsigned int r_type, + const Target_powerpc* target) { + int ref = 0; + switch (r_type) { case elfcpp::R_POWERPC_NONE: @@ -4744,7 +5082,7 @@ Target_powerpc<size, big_endian>::Scan::get_reference_flags(unsigned int r_type) case elfcpp::R_POWERPC_GNU_VTENTRY: case elfcpp::R_PPC64_TOC: // No symbol reference. - return 0; + break; case elfcpp::R_PPC64_ADDR64: case elfcpp::R_PPC64_UADDR64: @@ -4755,13 +5093,15 @@ Target_powerpc<size, big_endian>::Scan::get_reference_flags(unsigned int r_type) case elfcpp::R_POWERPC_ADDR16_LO: case elfcpp::R_POWERPC_ADDR16_HI: case elfcpp::R_POWERPC_ADDR16_HA: - return Symbol::ABSOLUTE_REF; + ref = Symbol::ABSOLUTE_REF; + break; case elfcpp::R_POWERPC_ADDR24: case elfcpp::R_POWERPC_ADDR14: case elfcpp::R_POWERPC_ADDR14_BRTAKEN: case elfcpp::R_POWERPC_ADDR14_BRNTAKEN: - return Symbol::FUNCTION_CALL | Symbol::ABSOLUTE_REF; + ref = Symbol::FUNCTION_CALL | Symbol::ABSOLUTE_REF; + break; case elfcpp::R_PPC64_REL64: case elfcpp::R_POWERPC_REL32: @@ -4770,14 +5110,16 @@ Target_powerpc<size, big_endian>::Scan::get_reference_flags(unsigned int r_type) case elfcpp::R_POWERPC_REL16_LO: case elfcpp::R_POWERPC_REL16_HI: case elfcpp::R_POWERPC_REL16_HA: - return Symbol::RELATIVE_REF; + ref = Symbol::RELATIVE_REF; + break; case elfcpp::R_POWERPC_REL24: case elfcpp::R_PPC_PLTREL24: case elfcpp::R_POWERPC_REL14: case elfcpp::R_POWERPC_REL14_BRTAKEN: case elfcpp::R_POWERPC_REL14_BRNTAKEN: - return Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; + ref = Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; + break; case elfcpp::R_POWERPC_GOT16: case elfcpp::R_POWERPC_GOT16_LO: @@ -4792,11 +5134,13 @@ Target_powerpc<size, big_endian>::Scan::get_reference_flags(unsigned int r_type) case elfcpp::R_PPC64_TOC16_DS: case elfcpp::R_PPC64_TOC16_LO_DS: // Absolute in GOT. - return Symbol::ABSOLUTE_REF; + ref = Symbol::ABSOLUTE_REF; + break; case elfcpp::R_POWERPC_GOT_TPREL16: case elfcpp::R_POWERPC_TLS: - return Symbol::TLS_REF; + ref = Symbol::TLS_REF; + break; case elfcpp::R_POWERPC_COPY: case elfcpp::R_POWERPC_GLOB_DAT: @@ -4805,8 +5149,12 @@ Target_powerpc<size, big_endian>::Scan::get_reference_flags(unsigned int r_type) case elfcpp::R_POWERPC_DTPMOD: default: // Not expected. We will give an error later. - return 0; + break; } + + if (size == 64 && target->abiversion() < 2) + ref |= Symbol::FUNC_DESC_ABI; + return ref; } // Report an unsupported relocation against a local symbol. @@ -4877,6 +5225,8 @@ Target_powerpc<size, big_endian>::Scan::check_non_pic(Relobj* object, case elfcpp::R_PPC64_JMP_IREL: case elfcpp::R_PPC64_ADDR16_DS: case elfcpp::R_PPC64_ADDR16_LO_DS: + case elfcpp::R_PPC64_ADDR16_HIGH: + case elfcpp::R_PPC64_ADDR16_HIGHA: case elfcpp::R_PPC64_ADDR16_HIGHER: case elfcpp::R_PPC64_ADDR16_HIGHEST: case elfcpp::R_PPC64_ADDR16_HIGHERA: @@ -4885,6 +5235,8 @@ Target_powerpc<size, big_endian>::Scan::check_non_pic(Relobj* object, case elfcpp::R_POWERPC_ADDR30: case elfcpp::R_PPC64_TPREL16_DS: case elfcpp::R_PPC64_TPREL16_LO_DS: + case elfcpp::R_PPC64_TPREL16_HIGH: + case elfcpp::R_PPC64_TPREL16_HIGHA: case elfcpp::R_PPC64_TPREL16_HIGHER: case elfcpp::R_PPC64_TPREL16_HIGHEST: case elfcpp::R_PPC64_TPREL16_HIGHERA: @@ -4930,13 +5282,15 @@ Target_powerpc<size, big_endian>::Scan::check_non_pic(Relobj* object, template<int size, bool big_endian> bool Target_powerpc<size, big_endian>::Scan::reloc_needs_plt_for_ifunc( + Target_powerpc<size, big_endian>* target, Sized_relobj_file<size, big_endian>* object, unsigned int r_type, bool report_err) { // In non-pic code any reference will resolve to the plt call stub // for the ifunc symbol. - if (size == 32 && !parameters->options().output_is_position_independent()) + if ((size == 32 || target->abiversion() >= 2) + && !parameters->options().output_is_position_independent()) return true; switch (r_type) @@ -5043,7 +5397,7 @@ Target_powerpc<size, big_endian>::Scan::local( // A local STT_GNU_IFUNC symbol may require a PLT entry. bool is_ifunc = lsym.get_st_type() == elfcpp::STT_GNU_IFUNC; - if (is_ifunc && this->reloc_needs_plt_for_ifunc(object, r_type, true)) + if (is_ifunc && this->reloc_needs_plt_for_ifunc(target, object, r_type, true)) { unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info()); target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), @@ -5057,7 +5411,6 @@ Target_powerpc<size, big_endian>::Scan::local( case elfcpp::R_POWERPC_GNU_VTINHERIT: case elfcpp::R_POWERPC_GNU_VTENTRY: case elfcpp::R_PPC64_TOCSAVE: - case elfcpp::R_PPC_EMB_MRKREF: case elfcpp::R_POWERPC_TLS: break; @@ -5069,6 +5422,7 @@ Target_powerpc<size, big_endian>::Scan::local( { Address off = reloc.get_r_offset(); if (size == 64 + && target->abiversion() < 2 && data_shndx == ppc_object->opd_shndx() && ppc_object->get_opd_discard(off - 8)) break; @@ -5094,6 +5448,8 @@ Target_powerpc<size, big_endian>::Scan::local( case elfcpp::R_POWERPC_ADDR16_HI: case elfcpp::R_POWERPC_ADDR16_HA: case elfcpp::R_POWERPC_UADDR16: + case elfcpp::R_PPC64_ADDR16_HIGH: + case elfcpp::R_PPC64_ADDR16_HIGHA: case elfcpp::R_PPC64_ADDR16_HIGHER: case elfcpp::R_PPC64_ADDR16_HIGHERA: case elfcpp::R_PPC64_ADDR16_HIGHEST: @@ -5107,7 +5463,7 @@ Target_powerpc<size, big_endian>::Scan::local( // executable), we need to create a dynamic relocation for // this location. if (parameters->options().output_is_position_independent() - || (size == 64 && is_ifunc)) + || (size == 64 && is_ifunc && target->abiversion() < 2)) { Reloc_section* rela_dyn = target->rela_dyn_section(symtab, layout, is_ifunc); @@ -5152,33 +5508,38 @@ Target_powerpc<size, big_endian>::Scan::local( case elfcpp::R_POWERPC_REL16_HI: case elfcpp::R_POWERPC_REL16_HA: case elfcpp::R_POWERPC_SECTOFF: - case elfcpp::R_POWERPC_TPREL16: - case elfcpp::R_POWERPC_DTPREL16: case elfcpp::R_POWERPC_SECTOFF_LO: - case elfcpp::R_POWERPC_TPREL16_LO: - case elfcpp::R_POWERPC_DTPREL16_LO: case elfcpp::R_POWERPC_SECTOFF_HI: - case elfcpp::R_POWERPC_TPREL16_HI: - case elfcpp::R_POWERPC_DTPREL16_HI: case elfcpp::R_POWERPC_SECTOFF_HA: + case elfcpp::R_PPC64_SECTOFF_DS: + case elfcpp::R_PPC64_SECTOFF_LO_DS: + case elfcpp::R_POWERPC_TPREL16: + case elfcpp::R_POWERPC_TPREL16_LO: + case elfcpp::R_POWERPC_TPREL16_HI: case elfcpp::R_POWERPC_TPREL16_HA: - case elfcpp::R_POWERPC_DTPREL16_HA: - case elfcpp::R_PPC64_DTPREL16_HIGHER: + case elfcpp::R_PPC64_TPREL16_DS: + case elfcpp::R_PPC64_TPREL16_LO_DS: + case elfcpp::R_PPC64_TPREL16_HIGH: + case elfcpp::R_PPC64_TPREL16_HIGHA: case elfcpp::R_PPC64_TPREL16_HIGHER: - case elfcpp::R_PPC64_DTPREL16_HIGHERA: case elfcpp::R_PPC64_TPREL16_HIGHERA: - case elfcpp::R_PPC64_DTPREL16_HIGHEST: case elfcpp::R_PPC64_TPREL16_HIGHEST: - case elfcpp::R_PPC64_DTPREL16_HIGHESTA: case elfcpp::R_PPC64_TPREL16_HIGHESTA: - case elfcpp::R_PPC64_TPREL16_DS: - case elfcpp::R_PPC64_TPREL16_LO_DS: + case elfcpp::R_POWERPC_DTPREL16: + case elfcpp::R_POWERPC_DTPREL16_LO: + case elfcpp::R_POWERPC_DTPREL16_HI: + case elfcpp::R_POWERPC_DTPREL16_HA: case elfcpp::R_PPC64_DTPREL16_DS: case elfcpp::R_PPC64_DTPREL16_LO_DS: - case elfcpp::R_PPC64_SECTOFF_DS: - case elfcpp::R_PPC64_SECTOFF_LO_DS: + case elfcpp::R_PPC64_DTPREL16_HIGH: + case elfcpp::R_PPC64_DTPREL16_HIGHA: + case elfcpp::R_PPC64_DTPREL16_HIGHER: + case elfcpp::R_PPC64_DTPREL16_HIGHERA: + case elfcpp::R_PPC64_DTPREL16_HIGHEST: + case elfcpp::R_PPC64_DTPREL16_HIGHESTA: case elfcpp::R_PPC64_TLSGD: case elfcpp::R_PPC64_TLSLD: + case elfcpp::R_PPC64_ADDR64_LOCAL: break; case elfcpp::R_POWERPC_GOT16: @@ -5195,7 +5556,8 @@ Target_powerpc<size, big_endian>::Scan::local( if (!parameters->options().output_is_position_independent()) { - if (size == 32 && is_ifunc) + if ((size == 32 && is_ifunc) + || (size == 64 && target->abiversion() >= 2)) got->add_local_plt(object, r_sym, GOT_TYPE_STANDARD); else got->add_local(object, r_sym, GOT_TYPE_STANDARD); @@ -5393,12 +5755,14 @@ Target_powerpc<size, big_endian>::Scan::global( // A STT_GNU_IFUNC symbol may require a PLT entry. bool is_ifunc = gsym->type() == elfcpp::STT_GNU_IFUNC; - if (is_ifunc && this->reloc_needs_plt_for_ifunc(object, r_type, true)) + bool pushed_ifunc = false; + if (is_ifunc && this->reloc_needs_plt_for_ifunc(target, object, r_type, true)) { target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), r_type, elfcpp::elf_r_sym<size>(reloc.get_r_info()), reloc.get_r_addend()); target->make_plt_entry(symtab, layout, gsym); + pushed_ifunc = true; } switch (r_type) @@ -5407,7 +5771,6 @@ Target_powerpc<size, big_endian>::Scan::global( case elfcpp::R_POWERPC_GNU_VTINHERIT: case elfcpp::R_POWERPC_GNU_VTENTRY: case elfcpp::R_PPC_LOCAL24PC: - case elfcpp::R_PPC_EMB_MRKREF: case elfcpp::R_POWERPC_TLS: break; @@ -5439,6 +5802,7 @@ Target_powerpc<size, big_endian>::Scan::global( case elfcpp::R_PPC64_ADDR64: if (size == 64 + && target->abiversion() < 2 && data_shndx == ppc_object->opd_shndx() && (gsym->is_defined_in_discarded_section() || gsym->object() != object)) @@ -5456,6 +5820,8 @@ Target_powerpc<size, big_endian>::Scan::global( case elfcpp::R_POWERPC_ADDR16_HI: case elfcpp::R_POWERPC_ADDR16_HA: case elfcpp::R_POWERPC_UADDR16: + case elfcpp::R_PPC64_ADDR16_HIGH: + case elfcpp::R_PPC64_ADDR16_HIGHA: case elfcpp::R_PPC64_ADDR16_HIGHER: case elfcpp::R_PPC64_ADDR16_HIGHERA: case elfcpp::R_PPC64_ADDR16_HIGHEST: @@ -5469,7 +5835,19 @@ Target_powerpc<size, big_endian>::Scan::global( // Make a PLT entry if necessary. if (gsym->needs_plt_entry()) { - if (!is_ifunc) + // Since this is not a PC-relative relocation, we may be + // taking the address of a function. In that case we need to + // set the entry in the dynamic symbol table to the address of + // the PLT call stub. + bool need_ifunc_plt = false; + if ((size == 32 || target->abiversion() >= 2) + && gsym->is_from_dynobj() + && !parameters->options().output_is_position_independent()) + { + gsym->set_needs_dynsym_value(); + need_ifunc_plt = true; + } + if (!is_ifunc || (!pushed_ifunc && need_ifunc_plt)) { target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), r_type, @@ -5477,31 +5855,28 @@ Target_powerpc<size, big_endian>::Scan::global( reloc.get_r_addend()); target->make_plt_entry(symtab, layout, gsym); } - // Since this is not a PC-relative relocation, we may be - // taking the address of a function. In that case we need to - // set the entry in the dynamic symbol table to the address of - // the PLT call stub. - if (size == 32 - && gsym->is_from_dynobj() - && !parameters->options().output_is_position_independent()) - gsym->set_needs_dynsym_value(); } // Make a dynamic relocation if necessary. - if (needs_dynamic_reloc<size>(gsym, Scan::get_reference_flags(r_type)) - || (size == 64 && is_ifunc)) + if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type, target)) + || (size == 64 && is_ifunc && target->abiversion() < 2)) { - if (gsym->may_need_copy_reloc()) + if (!parameters->options().output_is_position_independent() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); } - else if ((size == 32 - && r_type == elfcpp::R_POWERPC_ADDR32 + else if ((((size == 32 + && r_type == elfcpp::R_POWERPC_ADDR32) + || (size == 64 + && r_type == elfcpp::R_PPC64_ADDR64 + && target->abiversion() >= 2)) && gsym->can_use_relative_reloc(false) && !(gsym->visibility() == elfcpp::STV_PROTECTED && parameters->options().shared())) || (size == 64 && r_type == elfcpp::R_PPC64_ADDR64 + && target->abiversion() < 2 && (gsym->can_use_relative_reloc(false) || data_shndx == ppc_object->opd_shndx()))) { @@ -5547,9 +5922,10 @@ Target_powerpc<size, big_endian>::Scan::global( case elfcpp::R_PPC64_REL64: case elfcpp::R_POWERPC_REL32: // Make a dynamic relocation if necessary. - if (needs_dynamic_reloc<size>(gsym, Scan::get_reference_flags(r_type))) + if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type, target))) { - if (gsym->may_need_copy_reloc()) + if (!parameters->options().output_is_position_independent() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, @@ -5581,33 +5957,38 @@ Target_powerpc<size, big_endian>::Scan::global( case elfcpp::R_POWERPC_REL16_HI: case elfcpp::R_POWERPC_REL16_HA: case elfcpp::R_POWERPC_SECTOFF: - case elfcpp::R_POWERPC_TPREL16: - case elfcpp::R_POWERPC_DTPREL16: case elfcpp::R_POWERPC_SECTOFF_LO: - case elfcpp::R_POWERPC_TPREL16_LO: - case elfcpp::R_POWERPC_DTPREL16_LO: case elfcpp::R_POWERPC_SECTOFF_HI: - case elfcpp::R_POWERPC_TPREL16_HI: - case elfcpp::R_POWERPC_DTPREL16_HI: case elfcpp::R_POWERPC_SECTOFF_HA: + case elfcpp::R_PPC64_SECTOFF_DS: + case elfcpp::R_PPC64_SECTOFF_LO_DS: + case elfcpp::R_POWERPC_TPREL16: + case elfcpp::R_POWERPC_TPREL16_LO: + case elfcpp::R_POWERPC_TPREL16_HI: case elfcpp::R_POWERPC_TPREL16_HA: - case elfcpp::R_POWERPC_DTPREL16_HA: - case elfcpp::R_PPC64_DTPREL16_HIGHER: + case elfcpp::R_PPC64_TPREL16_DS: + case elfcpp::R_PPC64_TPREL16_LO_DS: + case elfcpp::R_PPC64_TPREL16_HIGH: + case elfcpp::R_PPC64_TPREL16_HIGHA: case elfcpp::R_PPC64_TPREL16_HIGHER: - case elfcpp::R_PPC64_DTPREL16_HIGHERA: case elfcpp::R_PPC64_TPREL16_HIGHERA: - case elfcpp::R_PPC64_DTPREL16_HIGHEST: case elfcpp::R_PPC64_TPREL16_HIGHEST: - case elfcpp::R_PPC64_DTPREL16_HIGHESTA: case elfcpp::R_PPC64_TPREL16_HIGHESTA: - case elfcpp::R_PPC64_TPREL16_DS: - case elfcpp::R_PPC64_TPREL16_LO_DS: + case elfcpp::R_POWERPC_DTPREL16: + case elfcpp::R_POWERPC_DTPREL16_LO: + case elfcpp::R_POWERPC_DTPREL16_HI: + case elfcpp::R_POWERPC_DTPREL16_HA: case elfcpp::R_PPC64_DTPREL16_DS: case elfcpp::R_PPC64_DTPREL16_LO_DS: - case elfcpp::R_PPC64_SECTOFF_DS: - case elfcpp::R_PPC64_SECTOFF_LO_DS: + case elfcpp::R_PPC64_DTPREL16_HIGH: + case elfcpp::R_PPC64_DTPREL16_HIGHA: + case elfcpp::R_PPC64_DTPREL16_HIGHER: + case elfcpp::R_PPC64_DTPREL16_HIGHERA: + case elfcpp::R_PPC64_DTPREL16_HIGHEST: + case elfcpp::R_PPC64_DTPREL16_HIGHESTA: case elfcpp::R_PPC64_TLSGD: case elfcpp::R_PPC64_TLSLD: + case elfcpp::R_PPC64_ADDR64_LOCAL: break; case elfcpp::R_POWERPC_GOT16: @@ -5623,7 +6004,8 @@ Target_powerpc<size, big_endian>::Scan::global( got = target->got_section(symtab, layout); if (gsym->final_value_is_known()) { - if (size == 32 && is_ifunc) + if ((size == 32 && is_ifunc) + || (size == 64 && target->abiversion() >= 2)) got->add_global_plt(gsym, GOT_TYPE_STANDARD); else got->add_global(gsym, GOT_TYPE_STANDARD); @@ -5639,7 +6021,8 @@ Target_powerpc<size, big_endian>::Scan::global( = target->rela_dyn_section(symtab, layout, is_ifunc); if (gsym->can_use_relative_reloc(false) - && !(size == 32 + && !((size == 32 + || target->abiversion() >= 2) && gsym->visibility() == elfcpp::STV_PROTECTED && parameters->options().shared())) { @@ -6239,9 +6622,9 @@ Target_powerpc<size, big_endian>::symval_for_branch( Powerpc_relobj<size, big_endian>* object, unsigned int *dest_shndx) { + if (size == 32 || this->abiversion() >= 2) + gold_unreachable(); *dest_shndx = 0; - if (size == 32) - return value; // If the symbol is defined in an opd section, ie. is a function // descriptor, use the function descriptor code entry address @@ -6320,29 +6703,42 @@ Target_powerpc<size, big_endian>::Relocate::relocate( bool has_plt_value = false; unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); if ((gsym != NULL - ? use_plt_offset<size>(gsym, Scan::get_reference_flags(r_type)) + ? gsym->use_plt_offset(Scan::get_reference_flags(r_type, target)) : object->local_has_plt_offset(r_sym)) && (!psymval->is_ifunc_symbol() - || Scan::reloc_needs_plt_for_ifunc(object, r_type, false))) + || Scan::reloc_needs_plt_for_ifunc(target, object, r_type, false))) { - Stub_table<size, big_endian>* stub_table - = object->stub_table(relinfo->data_shndx); - if (stub_table == NULL) + if (size == 64 + && gsym != NULL + && target->abiversion() >= 2 + && !parameters->options().output_is_position_independent() + && !is_branch_reloc(r_type)) { - // This is a ref from a data section to an ifunc symbol. - if (target->stub_tables().size() != 0) - stub_table = target->stub_tables()[0]; + unsigned int off = target->glink_section()->find_global_entry(gsym); + gold_assert(off != (unsigned int)-1); + value = target->glink_section()->global_entry_address() + off; } - gold_assert(stub_table != NULL); - Address off; - if (gsym != NULL) - off = stub_table->find_plt_call_entry(object, gsym, r_type, - rela.get_r_addend()); else - off = stub_table->find_plt_call_entry(object, r_sym, r_type, - rela.get_r_addend()); - gold_assert(off != invalid_address); - value = stub_table->stub_address() + off; + { + Stub_table<size, big_endian>* stub_table + = object->stub_table(relinfo->data_shndx); + if (stub_table == NULL) + { + // This is a ref from a data section to an ifunc symbol. + if (target->stub_tables().size() != 0) + stub_table = target->stub_tables()[0]; + } + gold_assert(stub_table != NULL); + Address off; + if (gsym != NULL) + off = stub_table->find_plt_call_entry(object, gsym, r_type, + rela.get_r_addend()); + else + off = stub_table->find_plt_call_entry(object, r_sym, r_type, + rela.get_r_addend()); + gold_assert(off != invalid_address); + value = stub_table->stub_address() + off; + } has_plt_value = true; } @@ -6389,7 +6785,8 @@ Target_powerpc<size, big_endian>::Relocate::relocate( && (insn2 == nop || insn2 == cror_15_15_15 || insn2 == cror_31_31_31)) { - elfcpp::Swap<32, big_endian>::writeval(wv + 1, ld_2_1 + 40); + elfcpp::Swap<32, big_endian>:: + writeval(wv + 1, ld_2_1 + target->stk_toc()); can_plt_call = true; } } @@ -6416,11 +6813,15 @@ Target_powerpc<size, big_endian>::Relocate::relocate( if (gsym->source() == Symbol::FROM_OBJECT && gsym->object() == object) { - Address addend = rela.get_r_addend(); - unsigned int dest_shndx; - Address opdent = psymval->value(object, addend); - code = target->symval_for_branch(relinfo->symtab, opdent, - gsym, object, &dest_shndx); + unsigned int dest_shndx = 0; + if (target->abiversion() < 2) + { + Address addend = rela.get_r_addend(); + Address opdent = psymval->value(object, addend); + code = target->symval_for_branch(relinfo->symtab, + opdent, gsym, object, + &dest_shndx); + } bool is_ordinary; if (dest_shndx == 0) dest_shndx = gsym->shndx(&is_ordinary); @@ -6682,8 +7083,18 @@ Target_powerpc<size, big_endian>::Relocate::relocate( addend = rela.get_r_addend(); value = psymval->value(object, addend); if (size == 64 && is_branch_reloc(r_type)) - value = target->symval_for_branch(relinfo->symtab, value, - gsym, object, &dest_shndx); + { + if (target->abiversion() >= 2) + { + if (gsym != NULL) + value += object->ppc64_local_entry_offset(gsym); + else + value += object->ppc64_local_entry_offset(r_sym); + } + else + value = target->symval_for_branch(relinfo->symtab, value, + gsym, object, &dest_shndx); + } unsigned int max_branch_offset = 0; if (r_type == elfcpp::R_POWERPC_REL24 || r_type == elfcpp::R_PPC_PLTREL24 @@ -6748,8 +7159,10 @@ Target_powerpc<size, big_endian>::Relocate::relocate( case elfcpp::R_PPC64_TPREL16_DS: case elfcpp::R_PPC64_TPREL16_LO_DS: + case elfcpp::R_PPC64_TPREL16_HIGH: + case elfcpp::R_PPC64_TPREL16_HIGHA: if (size != 64) - // R_PPC_TLSGD and R_PPC_TLSLD + // R_PPC_TLSGD, R_PPC_TLSLD, R_PPC_EMB_RELST_LO, R_PPC_EMB_RELST_HI break; case elfcpp::R_POWERPC_TPREL16: case elfcpp::R_POWERPC_TPREL16_LO: @@ -6779,10 +7192,19 @@ Target_powerpc<size, big_endian>::Relocate::relocate( case elfcpp::R_POWERPC_DTPREL16_HI: case elfcpp::R_POWERPC_DTPREL16_HA: case elfcpp::R_POWERPC_DTPREL: + case elfcpp::R_PPC64_DTPREL16_HIGH: + case elfcpp::R_PPC64_DTPREL16_HIGHA: // tls symbol values are relative to tls_segment()->vaddr() value -= dtp_offset; break; + case elfcpp::R_PPC64_ADDR64_LOCAL: + if (gsym != NULL) + value += object->ppc64_local_entry_offset(gsym); + else + value += object->ppc64_local_entry_offset(r_sym); + break; + default: break; } @@ -6896,6 +7318,7 @@ Target_powerpc<size, big_endian>::Relocate::relocate( } typename Reloc::Overflow_check overflow = Reloc::CHECK_NONE; + elfcpp::Shdr<size, big_endian> shdr(relinfo->data_shdr); switch (r_type) { case elfcpp::R_POWERPC_ADDR32: @@ -6909,25 +7332,70 @@ Target_powerpc<size, big_endian>::Relocate::relocate( overflow = Reloc::CHECK_SIGNED; break; - case elfcpp::R_POWERPC_ADDR24: - case elfcpp::R_POWERPC_ADDR16: case elfcpp::R_POWERPC_UADDR16: - case elfcpp::R_PPC64_ADDR16_DS: - case elfcpp::R_POWERPC_ADDR14: - case elfcpp::R_POWERPC_ADDR14_BRTAKEN: - case elfcpp::R_POWERPC_ADDR14_BRNTAKEN: overflow = Reloc::CHECK_BITFIELD; break; - case elfcpp::R_POWERPC_REL24: - case elfcpp::R_PPC_PLTREL24: - case elfcpp::R_PPC_LOCAL24PC: + case elfcpp::R_POWERPC_ADDR16: + // We really should have three separate relocations, + // one for 16-bit data, one for insns with 16-bit signed fields, + // and one for insns with 16-bit unsigned fields. + overflow = Reloc::CHECK_BITFIELD; + if ((shdr.get_sh_flags() & elfcpp::SHF_EXECINSTR) != 0) + overflow = Reloc::CHECK_LOW_INSN; + break; + + case elfcpp::R_POWERPC_ADDR16_HI: + case elfcpp::R_POWERPC_ADDR16_HA: + case elfcpp::R_POWERPC_GOT16_HI: + case elfcpp::R_POWERPC_GOT16_HA: + case elfcpp::R_POWERPC_PLT16_HI: + case elfcpp::R_POWERPC_PLT16_HA: + case elfcpp::R_POWERPC_SECTOFF_HI: + case elfcpp::R_POWERPC_SECTOFF_HA: + case elfcpp::R_PPC64_TOC16_HI: + case elfcpp::R_PPC64_TOC16_HA: + case elfcpp::R_PPC64_PLTGOT16_HI: + case elfcpp::R_PPC64_PLTGOT16_HA: + case elfcpp::R_POWERPC_TPREL16_HI: + case elfcpp::R_POWERPC_TPREL16_HA: + case elfcpp::R_POWERPC_DTPREL16_HI: + case elfcpp::R_POWERPC_DTPREL16_HA: + case elfcpp::R_POWERPC_GOT_TLSGD16_HI: + case elfcpp::R_POWERPC_GOT_TLSGD16_HA: + case elfcpp::R_POWERPC_GOT_TLSLD16_HI: + case elfcpp::R_POWERPC_GOT_TLSLD16_HA: + case elfcpp::R_POWERPC_GOT_TPREL16_HI: + case elfcpp::R_POWERPC_GOT_TPREL16_HA: + case elfcpp::R_POWERPC_GOT_DTPREL16_HI: + case elfcpp::R_POWERPC_GOT_DTPREL16_HA: + case elfcpp::R_POWERPC_REL16_HI: + case elfcpp::R_POWERPC_REL16_HA: + if (size != 32) + overflow = Reloc::CHECK_HIGH_INSN; + break; + case elfcpp::R_POWERPC_REL16: case elfcpp::R_PPC64_TOC16: case elfcpp::R_POWERPC_GOT16: case elfcpp::R_POWERPC_SECTOFF: case elfcpp::R_POWERPC_TPREL16: case elfcpp::R_POWERPC_DTPREL16: + case elfcpp::R_POWERPC_GOT_TLSGD16: + case elfcpp::R_POWERPC_GOT_TLSLD16: + case elfcpp::R_POWERPC_GOT_TPREL16: + case elfcpp::R_POWERPC_GOT_DTPREL16: + overflow = Reloc::CHECK_LOW_INSN; + break; + + case elfcpp::R_POWERPC_ADDR24: + case elfcpp::R_POWERPC_ADDR14: + case elfcpp::R_POWERPC_ADDR14_BRTAKEN: + case elfcpp::R_POWERPC_ADDR14_BRNTAKEN: + case elfcpp::R_PPC64_ADDR16_DS: + case elfcpp::R_POWERPC_REL24: + case elfcpp::R_PPC_PLTREL24: + case elfcpp::R_PPC_LOCAL24PC: case elfcpp::R_PPC64_TPREL16_DS: case elfcpp::R_PPC64_DTPREL16_DS: case elfcpp::R_PPC64_TOC16_DS: @@ -6936,14 +7404,29 @@ Target_powerpc<size, big_endian>::Relocate::relocate( case elfcpp::R_POWERPC_REL14: case elfcpp::R_POWERPC_REL14_BRTAKEN: case elfcpp::R_POWERPC_REL14_BRNTAKEN: - case elfcpp::R_POWERPC_GOT_TLSGD16: - case elfcpp::R_POWERPC_GOT_TLSLD16: - case elfcpp::R_POWERPC_GOT_TPREL16: - case elfcpp::R_POWERPC_GOT_DTPREL16: overflow = Reloc::CHECK_SIGNED; break; } + if (overflow == Reloc::CHECK_LOW_INSN + || overflow == Reloc::CHECK_HIGH_INSN) + { + Insn* iview = reinterpret_cast<Insn*>(view - 2 * big_endian); + Insn insn = elfcpp::Swap<32, big_endian>::readval(iview); + + overflow = Reloc::CHECK_SIGNED; + if ((insn & (0x3f << 26)) == 10u << 26 /* cmpli */) + overflow = Reloc::CHECK_BITFIELD; + else if (overflow == Reloc::CHECK_LOW_INSN + ? ((insn & (0x3f << 26)) == 28u << 26 /* andi */ + || (insn & (0x3f << 26)) == 24u << 26 /* ori */ + || (insn & (0x3f << 26)) == 26u << 26 /* xori */) + : ((insn & (0x3f << 26)) == 29u << 26 /* andis */ + || (insn & (0x3f << 26)) == 25u << 26 /* oris */ + || (insn & (0x3f << 26)) == 27u << 26 /* xoris */)) + overflow = Reloc::CHECK_UNSIGNED; + } + typename Powerpc_relocate_functions<size, big_endian>::Status status = Powerpc_relocate_functions<size, big_endian>::STATUS_OK; switch (r_type) @@ -6952,12 +7435,12 @@ Target_powerpc<size, big_endian>::Relocate::relocate( case elfcpp::R_POWERPC_TLS: case elfcpp::R_POWERPC_GNU_VTINHERIT: case elfcpp::R_POWERPC_GNU_VTENTRY: - case elfcpp::R_PPC_EMB_MRKREF: break; case elfcpp::R_PPC64_ADDR64: case elfcpp::R_PPC64_REL64: case elfcpp::R_PPC64_TOC: + case elfcpp::R_PPC64_ADDR64_LOCAL: Reloc::addr64(view, value); break; @@ -7023,6 +7506,12 @@ Target_powerpc<size, big_endian>::Relocate::relocate( status = Reloc::addr16_u(view, value, overflow); break; + case elfcpp::R_PPC64_ADDR16_HIGH: + case elfcpp::R_PPC64_TPREL16_HIGH: + case elfcpp::R_PPC64_DTPREL16_HIGH: + if (size == 32) + // R_PPC_EMB_MRKREF, R_PPC_EMB_RELST_LO, R_PPC_EMB_RELST_HA + goto unsupp; case elfcpp::R_POWERPC_ADDR16_HI: case elfcpp::R_POWERPC_REL16_HI: case elfcpp::R_PPC64_TOC16_HI: @@ -7037,6 +7526,12 @@ Target_powerpc<size, big_endian>::Relocate::relocate( Reloc::addr16_hi(view, value); break; + case elfcpp::R_PPC64_ADDR16_HIGHA: + case elfcpp::R_PPC64_TPREL16_HIGHA: + case elfcpp::R_PPC64_DTPREL16_HIGHA: + if (size == 32) + // R_PPC_EMB_RELSEC16, R_PPC_EMB_RELST_HI, R_PPC_EMB_BIT_FLD + goto unsupp; case elfcpp::R_POWERPC_ADDR16_HA: case elfcpp::R_POWERPC_REL16_HA: case elfcpp::R_PPC64_TOC16_HA: @@ -7161,11 +7656,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate( case elfcpp::R_PPC64_PLT16_LO_DS: case elfcpp::R_PPC64_PLTGOT16_DS: case elfcpp::R_PPC64_PLTGOT16_LO_DS: - case elfcpp::R_PPC_EMB_RELSEC16: - case elfcpp::R_PPC_EMB_RELST_LO: - case elfcpp::R_PPC_EMB_RELST_HI: - case elfcpp::R_PPC_EMB_RELST_HA: - case elfcpp::R_PPC_EMB_BIT_FLD: case elfcpp::R_PPC_EMB_RELSDA: case elfcpp::R_PPC_TOC16: default: @@ -7604,6 +8094,12 @@ Target_powerpc<size, big_endian>::do_dynsym_value(const Symbol* gsym) const return (*p)->stub_address() + off; } } + else if (this->abiversion() >= 2) + { + unsigned int off = this->glink_section()->find_global_entry(gsym); + if (off != (unsigned int)-1) + return this->glink_section()->global_entry_address() + off; + } gold_unreachable(); } @@ -7648,6 +8144,12 @@ Target_powerpc<size, big_endian>::do_plt_address_for_global( return (*p)->stub_address() + off; } } + else if (this->abiversion() >= 2) + { + unsigned int off = this->glink_section()->find_global_entry(gsym); + if (off != (unsigned int)-1) + return this->glink_section()->global_entry_address() + off; + } gold_unreachable(); } @@ -7745,6 +8247,9 @@ Target_selector_powerpc<64, false> target_selector_ppc64le; template<int size, bool big_endian> const int Output_data_glink<size, big_endian>::pltresolve_size; template<int size, bool big_endian> +const typename Output_data_glink<size, big_endian>::Address + Output_data_glink<size, big_endian>::invalid_address; +template<int size, bool big_endian> const typename Stub_table<size, big_endian>::Address Stub_table<size, big_endian>::invalid_address; template<int size, bool big_endian> diff --git a/binutils-2.25/gold/pread.c b/binutils-2.25/gold/pread.c index 2f47565..eb27411 100644 --- a/binutils-2.25/gold/pread.c +++ b/binutils-2.25/gold/pread.c @@ -1,6 +1,6 @@ /* pread.c -- version of pread for gold. */ -/* Copyright 2006, 2007, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2006-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/readsyms.cc b/binutils-2.25/gold/readsyms.cc index 8e52ccb..8aaa91a 100644 --- a/binutils-2.25/gold/readsyms.cc +++ b/binutils-2.25/gold/readsyms.cc @@ -1,6 +1,6 @@ // readsyms.cc -- read input file symbols for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/readsyms.h b/binutils-2.25/gold/readsyms.h index 99b2b16..0276f4d 100644 --- a/binutils-2.25/gold/readsyms.h +++ b/binutils-2.25/gold/readsyms.h @@ -1,7 +1,6 @@ // readsyms.h -- read input file symbols for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/reduced_debug_output.cc b/binutils-2.25/gold/reduced_debug_output.cc index a6158fc..09bdf13 100644 --- a/binutils-2.25/gold/reduced_debug_output.cc +++ b/binutils-2.25/gold/reduced_debug_output.cc @@ -1,6 +1,6 @@ // reduced_debug_output.cc -- output reduced debugging information to save space -// Copyright 2008, 2010, 2012 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Caleb Howe <cshowe@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/reduced_debug_output.h b/binutils-2.25/gold/reduced_debug_output.h index d168228..a4f9ebb 100644 --- a/binutils-2.25/gold/reduced_debug_output.h +++ b/binutils-2.25/gold/reduced_debug_output.h @@ -1,6 +1,6 @@ // reduced_debug_output.h -- reduce debugging information -*- C++ -*- -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Caleb Howe <cshowe@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/reloc-types.h b/binutils-2.25/gold/reloc-types.h index f13e64a..e5f235f 100644 --- a/binutils-2.25/gold/reloc-types.h +++ b/binutils-2.25/gold/reloc-types.h @@ -1,6 +1,6 @@ // reloc-types.h -- ELF relocation templates for gold -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/reloc.cc b/binutils-2.25/gold/reloc.cc index ca7f32f..115ab37 100644 --- a/binutils-2.25/gold/reloc.cc +++ b/binutils-2.25/gold/reloc.cc @@ -1,6 +1,6 @@ // reloc.cc -- relocate input files for gold. -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/reloc.h b/binutils-2.25/gold/reloc.h index 4eca71a..da14ec1 100644 --- a/binutils-2.25/gold/reloc.h +++ b/binutils-2.25/gold/reloc.h @@ -1,7 +1,6 @@ // reloc.h -- relocate input files for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/resolve.cc b/binutils-2.25/gold/resolve.cc index 3b6e706..07dff4a 100644 --- a/binutils-2.25/gold/resolve.cc +++ b/binutils-2.25/gold/resolve.cc @@ -1,6 +1,6 @@ // resolve.cc -- symbol resolution for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -303,14 +303,32 @@ Symbol_table::resolve(Sized_symbol<size>* to, // If we're processing replacement files, allow new symbols to override // the placeholders from the plugin objects. + // Treat common symbols specially since it is possible that an ELF + // file increased the size of the alignment. if (to->source() == Symbol::FROM_OBJECT) { Pluginobj* obj = to->object()->pluginobj(); if (obj != NULL && parameters->options().plugins()->in_replacement_phase()) { - this->override(to, sym, st_shndx, is_ordinary, object, version); - return; + bool adjust_common = false; + typename Sized_symbol<size>::Size_type tosize = 0; + typename Sized_symbol<size>::Value_type tovalue = 0; + if (to->is_common() && !is_ordinary && st_shndx == elfcpp::SHN_COMMON) + { + adjust_common = true; + tosize = to->symsize(); + tovalue = to->value(); + } + this->override(to, sym, st_shndx, is_ordinary, object, version); + if (adjust_common) + { + if (tosize > to->symsize()) + to->set_symsize(tosize); + if (tovalue > to->value()) + to->set_value(tovalue); + } + return; } } @@ -915,6 +933,10 @@ Symbol::override_base_with_special(const Symbol* from) bool same_name = this->name_ == from->name_; gold_assert(same_name || this->has_alias()); + // If we are overriding an undef, remember the original binding. + if (this->is_undefined()) + this->set_undef_binding(this->binding_); + this->source_ = from->source_; switch (from->source_) { diff --git a/binutils-2.25/gold/script-c.h b/binutils-2.25/gold/script-c.h index 2807950..f9555fe 100644 --- a/binutils-2.25/gold/script-c.h +++ b/binutils-2.25/gold/script-c.h @@ -1,6 +1,6 @@ /* script-c.h -- C interface for linker scripts in gold. */ -/* Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2006-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/script-sections.cc b/binutils-2.25/gold/script-sections.cc index a57e53f..799f4ab 100644 --- a/binutils-2.25/gold/script-sections.cc +++ b/binutils-2.25/gold/script-sections.cc @@ -1,6 +1,6 @@ // script-sections.cc -- linker script SECTIONS for gold -// Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/script-sections.h b/binutils-2.25/gold/script-sections.h index 9ff44ea..daf9f64 100644 --- a/binutils-2.25/gold/script-sections.h +++ b/binutils-2.25/gold/script-sections.h @@ -1,6 +1,6 @@ // script-sections.h -- linker script SECTIONS for gold -*- C++ -*- -// Copyright 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/script.cc b/binutils-2.25/gold/script.cc index 6a10c40..eff9a81 100644 --- a/binutils-2.25/gold/script.cc +++ b/binutils-2.25/gold/script.cc @@ -1,6 +1,6 @@ // script.cc -- handle linker scripts for gold. -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -980,12 +980,19 @@ Symbol_assignment::sized_finalize(Symbol_table* symtab, const Layout* layout, Output_section* dot_section) { Output_section* section; + elfcpp::STT type = elfcpp::STT_NOTYPE; + elfcpp::STV vis = elfcpp::STV_DEFAULT; + unsigned char nonvis = 0; uint64_t final_val = this->val_->eval_maybe_dot(symtab, layout, true, is_dot_available, dot_value, dot_section, - §ion, NULL, false); + §ion, NULL, &type, + &vis, &nonvis, false); Sized_symbol<size>* ssym = symtab->get_sized_symbol<size>(this->sym_); ssym->set_value(final_val); + ssym->set_type(type); + ssym->set_visibility(vis); + ssym->set_nonvis(nonvis); if (section != NULL) ssym->set_output_section(section); } @@ -1005,7 +1012,7 @@ Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout, uint64_t val = this->val_->eval_maybe_dot(symtab, layout, false, is_dot_available, dot_value, dot_section, &val_section, NULL, - false); + NULL, NULL, NULL, false); if (val_section != NULL && val_section != dot_section) return; diff --git a/binutils-2.25/gold/script.h b/binutils-2.25/gold/script.h index f41f438..99bba08 100644 --- a/binutils-2.25/gold/script.h +++ b/binutils-2.25/gold/script.h @@ -1,6 +1,6 @@ // script.h -- handle linker scripts for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -34,6 +34,7 @@ #include <string> #include <vector> +#include "elfcpp.h" #include "script-sections.h" namespace gold @@ -111,6 +112,7 @@ class Expression bool is_dot_available, uint64_t dot_value, Output_section* dot_section, Output_section** result_section, uint64_t* result_alignment, + elfcpp::STT* type, elfcpp::STV* vis, unsigned char* nonvis, bool is_section_dot_assignment); // Print the expression to the FILE. This is for debugging. diff --git a/binutils-2.25/gold/sparc.cc b/binutils-2.25/gold/sparc.cc index cbe95b8..5a5f76a 100644 --- a/binutils-2.25/gold/sparc.cc +++ b/binutils-2.25/gold/sparc.cc @@ -1,6 +1,6 @@ // sparc.cc -- sparc target support for gold. -// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by David S. Miller <davem@davemloft.net>. // This file is part of gold. @@ -2634,7 +2634,8 @@ Target_sparc<size, big_endian>::Scan::global( // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (gsym->may_need_copy_reloc()) + if (parameters->options().output_is_executable() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, @@ -2723,7 +2724,8 @@ Target_sparc<size, big_endian>::Scan::global( break; } - if (gsym->may_need_copy_reloc()) + if (!parameters->options().output_is_position_independent() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); diff --git a/binutils-2.25/gold/stringpool.cc b/binutils-2.25/gold/stringpool.cc index 665fcc8..02f0da9 100644 --- a/binutils-2.25/gold/stringpool.cc +++ b/binutils-2.25/gold/stringpool.cc @@ -1,6 +1,6 @@ // stringpool.cc -- a string pool for gold -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -73,7 +73,10 @@ Stringpool_template<Stringpool_char>::reserve(unsigned int n) { this->key_to_offset_.reserve(n); -#if defined(HAVE_TR1_UNORDERED_MAP) +#if defined(HAVE_UNORDERED_MAP) + this->string_set_.rehash(this->string_set_.size() + n); + return; +#elif defined(HAVE_TR1_UNORDERED_MAP) // rehash() implementation is broken in gcc 4.0.3's stl //this->string_set_.rehash(this->string_set_.size() + n); //return; @@ -503,7 +506,7 @@ template<typename Stringpool_char> void Stringpool_template<Stringpool_char>::print_stats(const char* name) const { -#if defined(HAVE_TR1_UNORDERED_MAP) || defined(HAVE_EXT_HASH_MAP) +#if defined(HAVE_UNORDERED_MAP) || defined(HAVE_TR1_UNORDERED_MAP) || defined(HAVE_EXT_HASH_MAP) fprintf(stderr, _("%s: %s entries: %zu; buckets: %zu\n"), program_name, name, this->string_set_.size(), this->string_set_.bucket_count()); diff --git a/binutils-2.25/gold/stringpool.h b/binutils-2.25/gold/stringpool.h index b638329..8ef8386 100644 --- a/binutils-2.25/gold/stringpool.h +++ b/binutils-2.25/gold/stringpool.h @@ -1,6 +1,6 @@ // stringpool.h -- a string pool for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/symtab.cc b/binutils-2.25/gold/symtab.cc index 2e17529..70fb3f0 100644 --- a/binutils-2.25/gold/symtab.cc +++ b/binutils-2.25/gold/symtab.cc @@ -1,6 +1,6 @@ // symtab.cc -- the gold symbol table -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -334,7 +334,7 @@ Sized_symbol<size>::allocate_common(Output_data* od, Value_type value) // Return true if this symbol should be added to the dynamic symbol // table. -inline bool +bool Symbol::should_add_dynsym_entry(Symbol_table* symtab) const { // If the symbol is only present on plugin files, the plugin decided we @@ -527,6 +527,31 @@ Symbol::set_output_section(Output_section* os) } } +// Set the symbol's output segment. This is used for pre-defined +// symbols whose segments aren't known until after layout is done +// (e.g., __ehdr_start). + +void +Symbol::set_output_segment(Output_segment* os, Segment_offset_base base) +{ + gold_assert(this->is_predefined_); + this->source_ = IN_OUTPUT_SEGMENT; + this->u_.in_output_segment.output_segment = os; + this->u_.in_output_segment.offset_base = base; +} + +// Set the symbol to undefined. This is used for pre-defined +// symbols whose segments aren't known until after layout is done +// (e.g., __ehdr_start). + +void +Symbol::set_undefined() +{ + gold_assert(this->is_predefined_); + this->source_ = IS_UNDEFINED; + this->is_predefined_ = false; +} + // Class Symbol_table. Symbol_table::Symbol_table(unsigned int count, @@ -955,7 +980,8 @@ Symbol_table::add_from_object(Object* object, gold_assert(ret != NULL); was_undefined = ret->is_undefined(); - was_common = ret->is_common(); + // Commons from plugins are just placeholders. + was_common = ret->is_common() && ret->object()->pluginobj() == NULL; this->resolve(ret, sym, st_shndx, is_ordinary, orig_st_shndx, object, version); @@ -978,7 +1004,8 @@ Symbol_table::add_from_object(Object* object, ret = this->get_sized_symbol<size>(insdefault.first->second); was_undefined = ret->is_undefined(); - was_common = ret->is_common(); + // Commons from plugins are just placeholders. + was_common = ret->is_common() && ret->object()->pluginobj() == NULL; this->resolve(ret, sym, st_shndx, is_ordinary, orig_st_shndx, object, version); @@ -1041,8 +1068,10 @@ Symbol_table::add_from_object(Object* object, } // Keep track of common symbols, to speed up common symbol - // allocation. - if (!was_common && ret->is_common()) + // allocation. Don't record commons from plugin objects; + // we need to wait until we see the real symbol in the + // replacement file. + if (!was_common && ret->is_common() && ret->object()->pluginobj() == NULL) { if (ret->type() == elfcpp::STT_TLS) this->tls_commons_.push_back(ret); @@ -1108,6 +1137,10 @@ Symbol_table::add_from_relobj( const char* name = sym_names + st_name; + if (strcmp (name, "__gnu_lto_slim") == 0) + gold_info(_("%s: plugin needed to handle lto object"), + relobj->name().c_str()); + bool is_ordinary; unsigned int st_shndx = relobj->adjust_sym_shndx(i + symndx_offset, sym.get_st_shndx(), @@ -1258,7 +1291,8 @@ Symbol_table::add_from_relobj( && res->is_externally_visible() && !res->is_from_dynobj() && (parameters->options().shared() - || parameters->options().export_dynamic())) + || parameters->options().export_dynamic() + || parameters->options().in_dynamic_list(res->name()))) this->gc_mark_symbol(res); if (is_defined_in_discarded_section) @@ -2370,6 +2404,25 @@ Symbol_table::set_dynsym_indexes(unsigned int index, { std::vector<Symbol*> as_needed_sym; + // Allow a target to set dynsym indexes. + if (parameters->target().has_custom_set_dynsym_indexes()) + { + std::vector<Symbol*> dyn_symbols; + for (Symbol_table_type::iterator p = this->table_.begin(); + p != this->table_.end(); + ++p) + { + Symbol* sym = p->second; + if (!sym->should_add_dynsym_entry(this)) + sym->set_dynsym_index(-1U); + else + dyn_symbols.push_back(sym); + } + + return parameters->target().set_dynsym_indexes(&dyn_symbols, index, syms, + dynpool, versions, this); + } + for (Symbol_table_type::iterator p = this->table_.begin(); p != this->table_.end(); ++p) @@ -2992,6 +3045,8 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, unsigned char* pd = dynamic_view + (dynsym_index * sym_size); this->sized_write_symbol<size, big_endian>(sym, dynsym_value, shndx, binding, dynpool, pd); + // Allow a target to adjust dynamic symbol value. + parameters->target().adjust_dyn_symbol(sym, pd); } } @@ -3622,6 +3677,32 @@ Symbol_table::define_with_copy_reloc<64>( elfcpp::Elf_types<64>::Elf_Addr value); #endif +#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG) +template +void +Sized_symbol<32>::init_output_data(const char* name, const char* version, + Output_data* od, Value_type value, + Size_type symsize, elfcpp::STT type, + elfcpp::STB binding, + elfcpp::STV visibility, + unsigned char nonvis, + bool offset_is_from_end, + bool is_predefined); +#endif + +#if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG) +template +void +Sized_symbol<64>::init_output_data(const char* name, const char* version, + Output_data* od, Value_type value, + Size_type symsize, elfcpp::STT type, + elfcpp::STB binding, + elfcpp::STV visibility, + unsigned char nonvis, + bool offset_is_from_end, + bool is_predefined); +#endif + #ifdef HAVE_TARGET_32_LITTLE template void diff --git a/binutils-2.25/gold/symtab.h b/binutils-2.25/gold/symtab.h index 9299ea8..7984dd6 100644 --- a/binutils-2.25/gold/symtab.h +++ b/binutils-2.25/gold/symtab.h @@ -1,6 +1,6 @@ // symtab.h -- the gold symbol table -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -215,6 +215,11 @@ class Symbol type() const { return this->type_; } + // Set the symbol type. + void + set_type(elfcpp::STT type) + { this->type_ = type; } + // Return true for function symbol. bool is_func() const @@ -238,7 +243,7 @@ class Symbol override_visibility(elfcpp::STV); // Set whether the symbol was originally a weak undef or a regular undef - // when resolved by a dynamic def. + // when resolved by a dynamic def or by a special symbol. inline void set_undef_binding(elfcpp::STB bind) { @@ -249,7 +254,8 @@ class Symbol } } - // Return TRUE if a weak undef was resolved by a dynamic def. + // Return TRUE if a weak undef was resolved by a dynamic def or + // by a special symbol. inline bool is_undef_binding_weak() const { return this->undef_binding_weak_; } @@ -259,6 +265,11 @@ class Symbol nonvis() const { return this->nonvis_; } + // Set the non-visibility part of the st_other field. + void + set_nonvis(unsigned int nonvis) + { this->nonvis_ = nonvis; } + // Return whether this symbol is a forwarder. This will never be // true of a symbol found in the hash table, but may be true of // symbol pointers attached to object files. @@ -512,7 +523,20 @@ class Symbol // Return whether this is a weak undefined symbol. bool is_weak_undefined() const - { return this->is_undefined() && this->binding() == elfcpp::STB_WEAK; } + { + return (this->is_undefined() + && (this->binding() == elfcpp::STB_WEAK + || this->is_undef_binding_weak())); + } + + // Return whether this is a strong undefined symbol. + bool + is_strong_undefined() const + { + return (this->is_undefined() + && this->binding() != elfcpp::STB_WEAK + && !this->is_undef_binding_weak()); + } // Return whether this is an absolute symbol. bool @@ -576,8 +600,14 @@ class Symbol if (!parameters->options().shared()) return false; - // If the user used -Bsymbolic, then nothing is preemptible. - if (parameters->options().Bsymbolic()) + // If the symbol was named in a --dynamic-list script, it is preemptible. + if (parameters->options().in_dynamic_list(this->name())) + return true; + + // If the user used -Bsymbolic or provided a --dynamic-list script, + // then nothing (else) is preemptible. + if (parameters->options().Bsymbolic() + || parameters->options().have_dynamic_list()) return false; // If the user used -Bsymbolic-functions, then functions are not @@ -638,7 +668,10 @@ class Symbol // A TLS-related reference. TLS_REF = 4, // A reference that can always be treated as a function call. - FUNCTION_CALL = 8 + FUNCTION_CALL = 8, + // When set, says that dynamic relocations are needed even if a + // symbol has a plt entry. + FUNC_DESC_ABI = 16, }; // Given a direct absolute or pc-relative static relocation against @@ -675,7 +708,8 @@ class Symbol // A reference to any PLT entry in a non-position-independent executable // does not need a dynamic relocation. - if (!parameters->options().output_is_position_independent() + if (!(flags & FUNC_DESC_ABI) + && !parameters->options().output_is_position_independent() && this->has_plt_offset()) return false; @@ -767,6 +801,18 @@ class Symbol void set_output_section(Output_section*); + // Set the symbol's output segment. This is used for pre-defined + // symbols whose segments aren't known until after layout is done + // (e.g., __ehdr_start). + void + set_output_segment(Output_segment*, Segment_offset_base); + + // Set the symbol to undefined. This is used for pre-defined + // symbols whose segments aren't known until after layout is done + // (e.g., __ehdr_start). + void + set_undefined(); + // Return whether there should be a warning for references to this // symbol. bool @@ -806,8 +852,7 @@ class Symbol bool may_need_copy_reloc() const { - return (!parameters->options().output_is_position_independent() - && parameters->options().copyreloc() + return (parameters->options().copyreloc() && this->is_from_dynobj() && !this->is_func()); } @@ -1015,7 +1060,7 @@ class Symbol // True if UNDEF_BINDING_WEAK_ has been set (bit 32). bool undef_binding_set_ : 1; // True if this symbol was a weak undef resolved by a dynamic def - // (bit 33). + // or by a special symbol (bit 33). bool undef_binding_weak_ : 1; // True if this symbol is a predefined linker symbol (bit 34). bool is_predefined_ : 1; diff --git a/binutils-2.25/gold/system.h b/binutils-2.25/gold/system.h index 3e6fe1d..8d4d6be 100644 --- a/binutils-2.25/gold/system.h +++ b/binutils-2.25/gold/system.h @@ -1,6 +1,6 @@ // system.h -- general definitions for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -57,8 +57,21 @@ // Figure out how to get a hash set and a hash map. -#if defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP) \ - && defined(HAVE_TR1_UNORDERED_MAP_REHASH) +#if defined(HAVE_UNORDERED_SET) && defined(HAVE_UNORDERED_MAP) + +#include <unordered_set> +#include <unordered_map> + +// We need a template typedef here. + +#define Unordered_set std::unordered_set +#define Unordered_map std::unordered_map +#define Unordered_multimap std::unordered_multimap + +#define reserve_unordered_map(map, n) ((map)->rehash(n)) + +#elif defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP) \ + && defined(HAVE_TR1_UNORDERED_MAP_REHASH) #include <tr1/unordered_set> #include <tr1/unordered_map> diff --git a/binutils-2.25/gold/target-reloc.h b/binutils-2.25/gold/target-reloc.h index b544c78..e44519b 100644 --- a/binutils-2.25/gold/target-reloc.h +++ b/binutils-2.25/gold/target-reloc.h @@ -1,7 +1,6 @@ // target-reloc.h -- target specific relocation support -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -185,7 +184,7 @@ issue_undefined_symbol_error(const Symbol* sym) return false; // We don't report weak symbols. - if (sym->binding() == elfcpp::STB_WEAK) + if (sym->is_weak_undefined()) return false; // We don't report symbols defined in discarded sections. @@ -211,6 +210,10 @@ issue_undefined_symbol_error(const Symbol* sym) return false; } + // If the symbol is hidden, report it. + if (sym->visibility() == elfcpp::STV_HIDDEN) + return true; + // When creating a shared library, only report unresolved symbols if // -z defs was used. if (parameters->options().shared() && !parameters->options().defs()) @@ -411,16 +414,10 @@ relocate_section( } if (issue_undefined_symbol_error(sym)) - { - gold_undefined_symbol_at_location(sym, relinfo, i, offset); - if (sym->is_cxx_vtable()) - gold_info(_("%s: the vtable symbol may be undefined because " - "the class is missing its key function"), - program_name); - } + gold_undefined_symbol_at_location(sym, relinfo, i, offset); else if (sym != NULL && sym->visibility() != elfcpp::STV_DEFAULT - && (sym->is_undefined() || sym->is_from_dynobj())) + && (sym->is_strong_undefined() || sym->is_from_dynobj())) visibility_error(sym); if (sym != NULL && sym->has_warning()) diff --git a/binutils-2.25/gold/target-select.cc b/binutils-2.25/gold/target-select.cc index e17cb7d..e5f2597 100644 --- a/binutils-2.25/gold/target-select.cc +++ b/binutils-2.25/gold/target-select.cc @@ -1,7 +1,6 @@ // target-select.cc -- select a target for an object file -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/target-select.h b/binutils-2.25/gold/target-select.h index 2e16c2a..c18d84b 100644 --- a/binutils-2.25/gold/target-select.h +++ b/binutils-2.25/gold/target-select.h @@ -1,7 +1,6 @@ // target-select.h -- select a target for an object file -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/target.cc b/binutils-2.25/gold/target.cc index cad3c95..81c02cc 100644 --- a/binutils-2.25/gold/target.cc +++ b/binutils-2.25/gold/target.cc @@ -1,6 +1,6 @@ // target.cc -- target support for gold. -// Copyright 2009, 2010, 2011, 2013 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/target.h b/binutils-2.25/gold/target.h index 415b7ed..e380591 100644 --- a/binutils-2.25/gold/target.h +++ b/binutils-2.25/gold/target.h @@ -1,7 +1,6 @@ // target.h -- target support for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -37,6 +36,7 @@ #include "elfcpp.h" #include "options.h" #include "parameters.h" +#include "stringpool.h" #include "debug.h" namespace gold @@ -62,6 +62,7 @@ class Output_section; class Input_objects; class Task; struct Symbol_location; +class Versions; // The abstract class for target specific handling. @@ -454,6 +455,36 @@ class Target entry_symbol_name() const { return this->pti_->entry_symbol_name; } + // Whether the target has a custom set_dynsym_indexes method. + bool + has_custom_set_dynsym_indexes() const + { return this->do_has_custom_set_dynsym_indexes(); } + + // Custom set_dynsym_indexes method for a target. + unsigned int + set_dynsym_indexes(std::vector<Symbol*>* dyn_symbols, unsigned int index, + std::vector<Symbol*>* syms, Stringpool* dynpool, + Versions* versions, Symbol_table* symtab) const + { + return this->do_set_dynsym_indexes(dyn_symbols, index, syms, dynpool, + versions, symtab); + } + + // Get the custom dynamic tag value. + unsigned int + dynamic_tag_custom_value(elfcpp::DT tag) const + { return this->do_dynamic_tag_custom_value(tag); } + + // Adjust the value written to the dynamic symbol table. + void + adjust_dyn_symbol(const Symbol* sym, unsigned char* view) const + { this->do_adjust_dyn_symbol(sym, view); } + + // Return whether to include the section in the link. + bool + should_include_section(elfcpp::Elf_Word sh_type) const + { return this->do_should_include_section(sh_type); } + protected: // This struct holds the constant information for a child class. We // use a struct to avoid the overhead of virtual function calls for @@ -725,6 +756,33 @@ class Target do_gc_mark_symbol(Symbol_table*, Symbol*) const { } + // This may be overridden by the child class. + virtual bool + do_has_custom_set_dynsym_indexes() const + { return false; } + + // This may be overridden by the child class. + virtual unsigned int + do_set_dynsym_indexes(std::vector<Symbol*>*, unsigned int, + std::vector<Symbol*>*, Stringpool*, Versions*, + Symbol_table*) const + { gold_unreachable(); } + + // This may be overridden by the child class. + virtual unsigned int + do_dynamic_tag_custom_value(elfcpp::DT) const + { gold_unreachable(); } + + // This may be overridden by the child class. + virtual void + do_adjust_dyn_symbol(const Symbol*, unsigned char*) const + { } + + // This may be overridden by the child class. + virtual bool + do_should_include_section(elfcpp::Elf_Word) const + { return true; } + private: // The implementations of the four do_make_elf_object virtual functions are // almost identical except for their sizes and endianness. We use a template. diff --git a/binutils-2.25/gold/testsuite/Makefile.am b/binutils-2.25/gold/testsuite/Makefile.am index 0d40e3f..35cd013 100644 --- a/binutils-2.25/gold/testsuite/Makefile.am +++ b/binutils-2.25/gold/testsuite/Makefile.am @@ -19,18 +19,25 @@ AM_CPPFLAGS = \ -DLOCALEDIR="\"$(datadir)/locale\"" \ @INCINTL@ +# Some versions of GCC now automatically enable linker plugins, +# but we want to run our tests without GCC's plugins. +if HAVE_NO_USE_LINKER_PLUGIN +OPT_NO_PLUGINS = -fno-use-linker-plugin +endif + # COMPILE1, LINK1, CXXCOMPILE1, CXXLINK1 are renamed from COMPILE, LINK, # CXXCOMPILE and CXXLINK generated by automake 1.11.1. FIXME: they should # be updated if they are different from automake used by gold. COMPILE1 = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ CXXCOMPILE1 = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ +CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(OPT_NO_PLUGINS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ -# Strip out -Wp,-D_FORTIFY_SOURCE=, which is rrelevant for the gold +# Strip out -Wp,-D_FORTIFY_SOURCE=, which is irrelevant for the gold # testsuite and incompatible with -O0 used in gold tests, from # COMPILE, LINK, CXXCOMPILE and CXXLINK. COMPILE = `echo $(COMPILE1) | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9[0-9]]*//'` @@ -203,6 +210,16 @@ pr14265: pr14265.o pr14265.stdout: pr14265 $(TEST_NM) --format=bsd --numeric-sort $< > $@ +check_SCRIPTS += gc_dynamic_list_test.sh +check_DATA += gc_dynamic_list_test.stdout +MOSTLYCLEANFILES += gc_dynamic_list_test +gc_dynamic_list_test.o: gc_dynamic_list_test.c + $(COMPILE) -c -ffunction-sections -o $@ $< +gc_dynamic_list_test: gc_dynamic_list_test.o gcctestdir/ld $(srcdir)/gc_dynamic_list_test.t + $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,--dynamic-list,$(srcdir)/gc_dynamic_list_test.t gc_dynamic_list_test.o +gc_dynamic_list_test.stdout: gc_dynamic_list_test + $(TEST_NM) gc_dynamic_list_test > $@ + check_SCRIPTS += icf_test.sh check_DATA += icf_test.map MOSTLYCLEANFILES += icf_test icf_test.map @@ -500,6 +517,16 @@ two_file_pie_test: two_file_test_1_pie.o two_file_test_1b_pie.o \ two_file_test_2_pie.o two_file_test_main_pie.o gcctestdir/ld $(CXXLINK) -Bgcctestdir/ -pie two_file_test_1_pie.o two_file_test_1b_pie.o two_file_test_2_pie.o two_file_test_main_pie.o +check_PROGRAMS += pie_copyrelocs_test +pie_copyrelocs_test_SOURCES = pie_copyrelocs_test.cc +pie_copyrelocs_test_DEPENDENCIES = gcctestdir/ld pie_copyrelocs_shared_test.so +pie_copyrelocs_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -pie +pie_copyrelocs_test_LDADD = pie_copyrelocs_shared_test.so +pie_copyrelocs_shared_test.o: pie_copyrelocs_shared_test.cc + $(CXXCOMPILE) -O2 -fpic -c -o $@ $< +pie_copyrelocs_shared_test.so: pie_copyrelocs_shared_test.o gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ -shared pie_copyrelocs_shared_test.o + check_SCRIPTS += two_file_shared.sh check_DATA += two_file_shared.dbg MOSTLYCLEANFILES += two_file_shared.dbg @@ -700,6 +727,18 @@ alt/weak_undef_lib.so: weak_undef_file2.o test -d alt || mkdir -p alt $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file2.o +check_PROGRAMS += weak_undef_test_2 +weak_undef_test_2_SOURCES = weak_undef_test_2.cc +weak_undef_test_2_DEPENDENCIES = gcctestdir/ld libweak_undef_2.a +weak_undef_test_2_LDFLAGS = -Bgcctestdir/ -u weak_undef_2 +weak_undef_test_2_LDADD = -L . -lweak_undef_2 +libweak_undef_2.a: weak_undef_file3.o weak_undef_file4.o + $(TEST_AR) rc $@ $^ +weak_undef_file3.o: weak_undef_file3.cc + $(CXXCOMPILE) -c -o $@ $< +weak_undef_file4.o: weak_undef_file4.cc + $(CXXCOMPILE) -c -o $@ $< + if FN_PTRS_IN_SO_WITHOUT_PIC check_PROGRAMS += weak_undef_nonpic_test MOSTLYCLEANFILES += alt/weak_undef_lib_nonpic.so @@ -1465,6 +1504,22 @@ dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t dynamic_list.stdout: dynamic_list $(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout +check_PROGRAMS += dynamic_list_2 +dynamic_list_2_SOURCES = dynamic_list_2.cc +dynamic_list_2_DEPENDENCIES = gcctestdir/ld dynamic_list_lib1.so dynamic_list_lib2.so +dynamic_list_2_LDFLAGS = -Bgcctestdir/ -L. -Wl,-R,. -Wl,--no-as-needed +dynamic_list_2_LDADD = dynamic_list_lib1.so dynamic_list_lib2.so + +dynamic_list_lib1.so: gcctestdir/ld dynamic_list_lib1.o + $(CXXLINK) -Bgcctestdir/ -shared dynamic_list_lib1.o +dynamic_list_lib1.o: dynamic_list_lib1.cc + $(CXXCOMPILE) -c -fpic -o $@ $< + +dynamic_list_lib2.so: gcctestdir/ld dynamic_list_lib2.o $(srcdir)/dynamic_list_2.t + $(CXXLINK) -Bgcctestdir/ -shared -Wl,--dynamic-list,$(srcdir)/dynamic_list_2.t dynamic_list_lib2.o +dynamic_list_lib2.o: dynamic_list_lib2.cc + $(CXXCOMPILE) -c -fpic -o $@ $< + check_PROGRAMS += thin_archive_test_1 MOSTLYCLEANFILES += libthin1.a libthin3.a libthinall.a \ alt/thin_archive_test_2.o alt/thin_archive_test_4.o \ @@ -1602,6 +1657,17 @@ MOSTLYCLEANFILES += two_file_test_1c.o two_file_test_1c.o: two_file_test_1.o cp two_file_test_1.o $@ +check_PROGRAMS += plugin_test_10 +check_SCRIPTS += plugin_test_10.sh +check_DATA += plugin_test_10.sections +MOSTLYCLEANFILES += plugin_test_10.sections +plugin_test_10: plugin_common_test_1.syms plugin_common_test_2.o gcctestdir/ld plugin_test.so + $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.syms plugin_common_test_2.o +plugin_test_10.sections: plugin_test_10 + $(TEST_READELF) -SW $< >$@ 2>/dev/null + + + plugin_test.so: plugin_test.o $(LINK) -Bgcctestdir/ -shared plugin_test.o plugin_test.o: plugin_test.c @@ -2154,6 +2220,61 @@ gdb_index_test_4.stdout: gdb_index_test_4 endif HAVE_PUBNAMES +# Test that __ehdr_start is defined correctly. +check_PROGRAMS += ehdr_start_test_1 +ehdr_start_test_1_SOURCES = ehdr_start_test.cc +ehdr_start_test_1_DEPENDENCIES = gcctestdir/ld +ehdr_start_test_1_CXXFLAGS = +ehdr_start_test_1_LDFLAGS = -Bgcctestdir/ +ehdr_start_test_1_LDADD = + +# Test that __ehdr_start is defined correctly with a weak reference. +check_PROGRAMS += ehdr_start_test_2 +ehdr_start_test_2_SOURCES = ehdr_start_test.cc +ehdr_start_test_2_DEPENDENCIES = gcctestdir/ld +ehdr_start_test_2_CXXFLAGS = -DEHDR_START_WEAK +ehdr_start_test_2_LDFLAGS = -Bgcctestdir/ +ehdr_start_test_2_LDADD = + +# Test that __ehdr_start is defined correctly when used with a linker script. +check_PROGRAMS += ehdr_start_test_3 +ehdr_start_test_3_SOURCES = ehdr_start_test.cc +ehdr_start_test_3_DEPENDENCIES = gcctestdir/ld $(srcdir)/ehdr_start_test.t +ehdr_start_test_3_CXXFLAGS = -DEHDR_START_WEAK +ehdr_start_test_3_LDFLAGS = -Bgcctestdir/ -Wl,-T,$(srcdir)/ehdr_start_test.t +ehdr_start_test_3_LDADD = + +# Test that __ehdr_start is left undefined when the text segment is not +# appropriately aligned. +check_SCRIPTS += ehdr_start_test_4.sh +check_DATA += ehdr_start_test_4.syms +MOSTLYCLEANFILES += ehdr_start_test_4 +ehdr_start_test_4.syms: ehdr_start_test_4 + $(TEST_NM) ehdr_start_test_4 > $@ +ehdr_start_test_4: ehdr_start_test_4.o gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ -Wl,-Ttext=0x100100 $< +ehdr_start_test_4.o: ehdr_start_test.cc + $(CXXCOMPILE) -c -DEHDR_START_WEAK -o $@ $< + +# Test that __ehdr_start is not overridden when supplied by the user. +check_PROGRAMS += ehdr_start_test_5 +ehdr_start_test_5_SOURCES = ehdr_start_test.cc ehdr_start_def.cc +ehdr_start_test_5_DEPENDENCIES = gcctestdir/ld +ehdr_start_test_5_CXXFLAGS = -DEHDR_START_USER_DEF +ehdr_start_test_5_LDFLAGS = -Bgcctestdir/ +ehdr_start_test_5_LDADD = + +# Test that the --defsym option copies the symbol type and visibility. +check_SCRIPTS += defsym_test.sh +check_DATA += defsym_test.syms +MOSTLYCLEANFILES += defsym_test.syms +defsym_test.syms: defsym_test + $(TEST_READELF) -sW $< > $@ +defsym_test: defsym_test.o gcctestdir/ld + $(LINK) -Bgcctestdir/ -Wl,--defsym=bar=foo defsym_test.o +defsym_test.o: defsym_test.c + $(COMPILE) -c -o $@ $< + # End-to-end incremental linking tests. # Incremental linking is currently supported only on the x86_64 target. @@ -2256,6 +2377,18 @@ incremental_comdat_test_1: incr_comdat_test_1.o incr_comdat_test_2_v1.o incr_com endif DEFAULT_TARGET_X86_64 +if DEFAULT_TARGET_X86_64 +check_PROGRAMS += exception_x86_64_bnd_test +exception_x86_64_bnd_test_SOURCES = exception_test_main.cc +exception_x86_64_bnd_test_DEPENDENCIES = gcctestdir/ld exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o +exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS) +exception_x86_64_bnd_test_LDADD = exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o +exception_x86_64_bnd_1.o: exception_test_1.cc gcctestdir/as + $(CXXCOMPILE) -c -fpic -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $< +exception_x86_64_bnd_2.o: exception_test_2.cc gcctestdir/as + $(CXXCOMPILE) -c -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $< +endif DEFAULT_TARGET_X86_64 + endif GCC endif NATIVE_LINKER diff --git a/binutils-2.25/gold/testsuite/Makefile.in b/binutils-2.25/gold/testsuite/Makefile.in index 07bb534..8fbb644 100644 --- a/binutils-2.25/gold/testsuite/Makefile.in +++ b/binutils-2.25/gold/testsuite/Makefile.in @@ -78,7 +78,9 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = incremental_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.sh gc_tls_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.sh \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.sh icf_test.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test.sh \ @@ -109,7 +111,9 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.stdout \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.stdout icf_test.map \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test_1.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test_2.stdout \ @@ -132,7 +136,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test.cmdline \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test gc_tls_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test pr14265 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test icf_test.map \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test icf_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test icf_safe_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test \ @@ -176,7 +181,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_12_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_21_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_relocatable_test \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_pie_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_pie_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ pie_copyrelocs_test # The nonpic tests will fail on platforms which can not put non-PIC # code into shared libraries, so we just don't run them in that case. @@ -203,7 +209,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @NATIVE_LINKER_FALSE@exception_test_DEPENDENCIES = @GCC_TRUE@@HAVE_STATIC_TRUE@@NATIVE_LINKER_TRUE@am__append_14 = exception_static_test @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_15 = weak_test \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test_2 @GCC_FALSE@weak_test_DEPENDENCIES = @NATIVE_LINKER_FALSE@weak_test_DEPENDENCIES = @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_16 = weak_undef_nonpic_test @@ -318,6 +325,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_phdrs_script_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_script_test script_test_11 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list_2 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2 @GCC_FALSE@script_test_1_DEPENDENCIES = @@ -342,14 +350,16 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_5 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_8 +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_8 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_34 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6.sh \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7.sh +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10.sh # Test that symbols known in the IR file but not in the replacement file # produce an unresolved symbol error. @@ -361,7 +371,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7.syms \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_9.err +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_9.err \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10.sections # Make a copy of two_file_test_1.o, which does not define the symbol _Z4t16av. @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_36 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.err \ @@ -372,7 +383,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_9.err \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ two_file_test_1c.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ two_file_test_1c.o \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10.sections @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@@TLS_TRUE@am__append_37 = plugin_test_tls @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@@TLS_TRUE@am__append_38 = plugin_test_tls.sh @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@@TLS_TRUE@am__append_39 = plugin_test_tls.err @@ -516,7 +528,19 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @NATIVE_LINKER_FALSE@ifuncmain7_DEPENDENCIES = # Test that --start-lib and --end-lib function correctly. -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_60 = start_lib_test + +# Test that __ehdr_start is defined correctly. + +# Test that __ehdr_start is defined correctly with a weak reference. + +# Test that __ehdr_start is defined correctly when used with a linker script. + +# Test that __ehdr_start is not overridden when supplied by the user. +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_60 = start_lib_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_1 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_2 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_3 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_5 # Test that --gdb-index functions correctly without gcc-generated pubnames. @GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@am__append_61 = gdb_index_test_1.sh @@ -539,18 +563,38 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@ gdb_index_test_3 \ @GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@ gdb_index_test_4.stdout \ @GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@ gdb_index_test_4 +@GCC_FALSE@ehdr_start_test_1_DEPENDENCIES = +@NATIVE_LINKER_FALSE@ehdr_start_test_1_DEPENDENCIES = +@GCC_FALSE@ehdr_start_test_2_DEPENDENCIES = +@NATIVE_LINKER_FALSE@ehdr_start_test_2_DEPENDENCIES = +@GCC_FALSE@ehdr_start_test_3_DEPENDENCIES = +@NATIVE_LINKER_FALSE@ehdr_start_test_3_DEPENDENCIES = + +# Test that __ehdr_start is left undefined when the text segment is not +# appropriately aligned. + +# Test that the --defsym option copies the symbol type and visibility. +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_70 = ehdr_start_test_4.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ defsym_test.sh +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_71 = ehdr_start_test_4.syms \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ defsym_test.syms +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_72 = ehdr_start_test_4 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ defsym_test.syms +@GCC_FALSE@ehdr_start_test_5_DEPENDENCIES = +@NATIVE_LINKER_FALSE@ehdr_start_test_5_DEPENDENCIES = # Test the --incremental-unchanged flag with an archive library. # The second link should not update the library. -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_70 = incremental_test_2 \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_73 = incremental_test_2 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_3 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_4 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_5 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_6 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_copy_test \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1 \ -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1 -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_71 = two_file_test_tmp_2.o \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1 \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_x86_64_bnd_test +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_74 = two_file_test_tmp_2.o \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_tmp_3.o \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_4.base \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_tmp_4.o \ @@ -560,23 +604,23 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ # These tests work with native and cross linkers. # Test script section order. -@NATIVE_OR_CROSS_LINKER_TRUE@am__append_72 = script_test_10.sh -@NATIVE_OR_CROSS_LINKER_TRUE@am__append_73 = script_test_10.stdout -@NATIVE_OR_CROSS_LINKER_TRUE@am__append_74 = script_test_10 +@NATIVE_OR_CROSS_LINKER_TRUE@am__append_75 = script_test_10.sh +@NATIVE_OR_CROSS_LINKER_TRUE@am__append_76 = script_test_10.stdout +@NATIVE_OR_CROSS_LINKER_TRUE@am__append_77 = script_test_10 # These tests work with cross linkers only. -@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_75 = split_i386.sh -@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_76 = split_i386_1.stdout split_i386_2.stdout \ +@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_78 = split_i386.sh +@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_79 = split_i386_1.stdout split_i386_2.stdout \ @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout -@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_77 = split_i386_1 split_i386_2 split_i386_3 \ +@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_80 = split_i386_1 split_i386_2 split_i386_3 \ @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_i386_4 split_i386_r -@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_78 = split_x86_64.sh -@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_79 = split_x86_64_1.stdout split_x86_64_2.stdout \ +@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_81 = split_x86_64.sh +@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_82 = split_x86_64_1.stdout split_x86_64_2.stdout \ @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout -@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_80 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \ +@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_83 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \ @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_4 split_x86_64_r @@ -591,7 +635,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ # Check Thumb to Thumb farcall veneers # Check Thumb to ARM farcall veneers -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_81 = arm_abs_global.sh \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_84 = arm_abs_global.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_branch_in_range.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_branch_out_of_range.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_fix_v4bx.sh \ @@ -605,7 +649,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_arm_thumb.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm.sh -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_82 = arm_abs_global.stdout \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_85 = arm_abs_global.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_in_range.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_out_of_range.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ thumb_bl_in_range.stdout \ @@ -650,7 +694,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_6m.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm_5t.stdout -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_83 = arm_abs_global \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_86 = arm_abs_global \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_in_range \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_out_of_range \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ thumb_bl_in_range \ @@ -693,10 +737,10 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_6m \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm_5t -@DEFAULT_TARGET_X86_64_TRUE@am__append_84 = *.dwo *.dwp -@DEFAULT_TARGET_X86_64_TRUE@am__append_85 = dwp_test_1.sh \ +@DEFAULT_TARGET_X86_64_TRUE@am__append_87 = *.dwo *.dwp +@DEFAULT_TARGET_X86_64_TRUE@am__append_88 = dwp_test_1.sh \ @DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.sh -@DEFAULT_TARGET_X86_64_TRUE@am__append_86 = dwp_test_1.stdout \ +@DEFAULT_TARGET_X86_64_TRUE@am__append_89 = dwp_test_1.stdout \ @DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.stdout subdir = testsuite DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am @@ -748,7 +792,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_12_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_21_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_relocatable_test$(EXEEXT) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_pie_test$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_pie_test$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ pie_copyrelocs_test$(EXEEXT) @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_9 = two_file_shared_1_nonpic_test$(EXEEXT) \ @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_2_nonpic_test$(EXEEXT) \ @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_same_shared_nonpic_test$(EXEEXT) \ @@ -770,7 +815,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_21_test$(EXEEXT) @GCC_TRUE@@HAVE_STATIC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_11 = exception_static_test$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_12 = weak_test$(EXEEXT) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test_2$(EXEEXT) @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_13 = weak_undef_nonpic_test$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_14 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test$(EXEEXT) \ @@ -822,6 +868,7 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_phdrs_script_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_script_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_11$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list_2$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__EXEEXT_23 = plugin_test_1$(EXEEXT) \ @@ -831,7 +878,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_5$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7$(EXEEXT) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_8$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_8$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@@TLS_TRUE@am__EXEEXT_24 = plugin_test_tls$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_25 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test$(EXEEXT) \ @@ -877,7 +925,11 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain7pic$(EXEEXT) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain7pie$(EXEEXT) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncvar$(EXEEXT) -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_38 = start_lib_test$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_38 = start_lib_test$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_1$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_2$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_3$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_5$(EXEEXT) @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_39 = incremental_test_2$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_3$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_4$(EXEEXT) \ @@ -885,7 +937,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_6$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_copy_test$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1$(EXEEXT) \ -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1$(EXEEXT) +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1$(EXEEXT) \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_x86_64_bnd_test$(EXEEXT) basic_pic_test_SOURCES = basic_pic_test.c basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT) basic_pic_test_LDADD = $(LDADD) @@ -965,6 +1018,28 @@ discard_locals_test_DEPENDENCIES = libgoldtest.a ../libgold.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) discard_locals_test_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(discard_locals_test_LDFLAGS) $(LDFLAGS) -o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_dynamic_list_2_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list_2.$(OBJEXT) +dynamic_list_2_OBJECTS = $(am_dynamic_list_2_OBJECTS) +dynamic_list_2_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ + $(dynamic_list_2_LDFLAGS) $(LDFLAGS) -o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ehdr_start_test_1_OBJECTS = ehdr_start_test_1-ehdr_start_test.$(OBJEXT) +ehdr_start_test_1_OBJECTS = $(am_ehdr_start_test_1_OBJECTS) +ehdr_start_test_1_LINK = $(CXXLD) $(ehdr_start_test_1_CXXFLAGS) \ + $(CXXFLAGS) $(ehdr_start_test_1_LDFLAGS) $(LDFLAGS) -o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ehdr_start_test_2_OBJECTS = ehdr_start_test_2-ehdr_start_test.$(OBJEXT) +ehdr_start_test_2_OBJECTS = $(am_ehdr_start_test_2_OBJECTS) +ehdr_start_test_2_LINK = $(CXXLD) $(ehdr_start_test_2_CXXFLAGS) \ + $(CXXFLAGS) $(ehdr_start_test_2_LDFLAGS) $(LDFLAGS) -o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ehdr_start_test_3_OBJECTS = ehdr_start_test_3-ehdr_start_test.$(OBJEXT) +ehdr_start_test_3_OBJECTS = $(am_ehdr_start_test_3_OBJECTS) +ehdr_start_test_3_LINK = $(CXXLD) $(ehdr_start_test_3_CXXFLAGS) \ + $(CXXFLAGS) $(ehdr_start_test_3_LDFLAGS) $(LDFLAGS) -o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ehdr_start_test_5_OBJECTS = ehdr_start_test_5-ehdr_start_test.$(OBJEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ehdr_start_test_5-ehdr_start_def.$(OBJEXT) +ehdr_start_test_5_OBJECTS = $(am_ehdr_start_test_5_OBJECTS) +ehdr_start_test_5_LINK = $(CXXLD) $(ehdr_start_test_5_CXXFLAGS) \ + $(CXXFLAGS) $(ehdr_start_test_5_LDFLAGS) $(LDFLAGS) -o $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@am_exception_same_shared_test_OBJECTS = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_test_main.$(OBJEXT) exception_same_shared_test_OBJECTS = \ @@ -1014,6 +1089,11 @@ exception_static_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ exception_test_OBJECTS = $(am_exception_test_OBJECTS) exception_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ $(exception_test_LDFLAGS) $(LDFLAGS) -o $@ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_exception_x86_64_bnd_test_OBJECTS = exception_test_main.$(OBJEXT) +exception_x86_64_bnd_test_OBJECTS = \ + $(am_exception_x86_64_bnd_test_OBJECTS) +exception_x86_64_bnd_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ + $(exception_x86_64_bnd_test_LDFLAGS) $(LDFLAGS) -o $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@am_exclude_libs_test_OBJECTS = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test.$(OBJEXT) exclude_libs_test_OBJECTS = $(am_exclude_libs_test_OBJECTS) @@ -1339,12 +1419,23 @@ permission_test_LDADD = $(LDADD) permission_test_DEPENDENCIES = libgoldtest.a ../libgold.a \ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_pie_copyrelocs_test_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ pie_copyrelocs_test.$(OBJEXT) +pie_copyrelocs_test_OBJECTS = $(am_pie_copyrelocs_test_OBJECTS) +pie_copyrelocs_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ + $(pie_copyrelocs_test_LDFLAGS) $(LDFLAGS) -o $@ plugin_test_1_SOURCES = plugin_test_1.c plugin_test_1_OBJECTS = plugin_test_1.$(OBJEXT) plugin_test_1_LDADD = $(LDADD) plugin_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +plugin_test_10_SOURCES = plugin_test_10.c +plugin_test_10_OBJECTS = plugin_test_10.$(OBJEXT) +plugin_test_10_LDADD = $(LDADD) +plugin_test_10_DEPENDENCIES = libgoldtest.a ../libgold.a \ + ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) plugin_test_2_SOURCES = plugin_test_2.c plugin_test_2_OBJECTS = plugin_test_2.$(OBJEXT) plugin_test_2_LDADD = $(LDADD) @@ -1754,6 +1845,11 @@ weak_undef_nonpic_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ weak_undef_test_OBJECTS = $(am_weak_undef_test_OBJECTS) weak_undef_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ $(weak_undef_test_LDFLAGS) $(LDFLAGS) -o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_weak_undef_test_2_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test_2.$(OBJEXT) +weak_undef_test_2_OBJECTS = $(am_weak_undef_test_2_OBJECTS) +weak_undef_test_2_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ + $(weak_undef_test_2_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/../depcomp am__depfiles_maybe = depfiles @@ -1766,12 +1862,16 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ $(common_test_1_SOURCES) $(common_test_2_SOURCES) \ $(constructor_static_test_SOURCES) $(constructor_test_SOURCES) \ $(copy_test_SOURCES) $(discard_locals_test_SOURCES) \ + $(dynamic_list_2_SOURCES) $(ehdr_start_test_1_SOURCES) \ + $(ehdr_start_test_2_SOURCES) $(ehdr_start_test_3_SOURCES) \ + $(ehdr_start_test_5_SOURCES) \ $(exception_same_shared_test_SOURCES) \ $(exception_separate_shared_12_test_SOURCES) \ $(exception_separate_shared_21_test_SOURCES) \ $(exception_shared_1_test_SOURCES) \ $(exception_shared_2_test_SOURCES) \ $(exception_static_test_SOURCES) $(exception_test_SOURCES) \ + $(exception_x86_64_bnd_test_SOURCES) \ $(exclude_libs_test_SOURCES) \ flagstest_compress_debug_sections.c flagstest_o_specialfile.c \ flagstest_o_specialfile_and_compress_debug_sections.c \ @@ -1798,7 +1898,8 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ $(large_symbol_alignment_SOURCES) $(leb128_unittest_SOURCES) \ local_labels_test.c many_sections_r_test.c \ $(many_sections_test_SOURCES) $(object_unittest_SOURCES) \ - permission_test.c plugin_test_1.c plugin_test_2.c \ + permission_test.c $(pie_copyrelocs_test_SOURCES) \ + plugin_test_1.c plugin_test_10.c plugin_test_2.c \ plugin_test_3.c plugin_test_4.c plugin_test_5.c \ plugin_test_6.c plugin_test_7.c plugin_test_8.c \ plugin_test_tls.c $(protected_1_SOURCES) \ @@ -1839,7 +1940,8 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ $(ver_test_2_SOURCES) $(ver_test_6_SOURCES) \ $(ver_test_8_SOURCES) $(ver_test_9_SOURCES) \ $(weak_alias_test_SOURCES) weak_plt.c $(weak_test_SOURCES) \ - $(weak_undef_nonpic_test_SOURCES) $(weak_undef_test_SOURCES) + $(weak_undef_nonpic_test_SOURCES) $(weak_undef_test_SOURCES) \ + $(weak_undef_test_2_SOURCES) ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -2067,21 +2169,27 @@ AM_CPPFLAGS = \ @INCINTL@ +# Some versions of GCC now automatically enable linker plugins, +# but we want to run our tests without GCC's plugins. +@HAVE_NO_USE_LINKER_PLUGIN_TRUE@OPT_NO_PLUGINS = -fno-use-linker-plugin + # COMPILE1, LINK1, CXXCOMPILE1, CXXLINK1 are renamed from COMPILE, LINK, # CXXCOMPILE and CXXLINK generated by automake 1.11.1. FIXME: they should # be updated if they are different from automake used by gold. COMPILE1 = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ + CXXCOMPILE1 = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ +CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(OPT_NO_PLUGINS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ -# Strip out -Wp,-D_FORTIFY_SOURCE=, which is rrelevant for the gold +# Strip out -Wp,-D_FORTIFY_SOURCE=, which is irrelevant for the gold # testsuite and incompatible with -O0 used in gold tests, from # COMPILE, LINK, CXXCOMPILE and CXXLINK. COMPILE = `echo $(COMPILE1) | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9[0-9]]*//'` @@ -2114,23 +2222,24 @@ MOSTLYCLEANFILES = *.so *.syms *.stdout $(am__append_4) \ $(am__append_17) $(am__append_26) $(am__append_28) \ $(am__append_30) $(am__append_36) $(am__append_40) \ $(am__append_41) $(am__append_47) $(am__append_63) \ - $(am__append_66) $(am__append_69) $(am__append_71) \ + $(am__append_66) $(am__append_69) $(am__append_72) \ $(am__append_74) $(am__append_77) $(am__append_80) \ - $(am__append_83) $(am__append_84) + $(am__append_83) $(am__append_86) $(am__append_87) # We will add to these later, for each individual test. Note # that we add each test under check_SCRIPTS or check_PROGRAMS; # the TESTS variable is automatically populated from these. check_SCRIPTS = $(am__append_2) $(am__append_34) $(am__append_38) \ $(am__append_42) $(am__append_45) $(am__append_61) \ - $(am__append_64) $(am__append_67) $(am__append_72) \ + $(am__append_64) $(am__append_67) $(am__append_70) \ $(am__append_75) $(am__append_78) $(am__append_81) \ - $(am__append_85) + $(am__append_84) $(am__append_88) check_DATA = $(am__append_3) $(am__append_27) $(am__append_29) \ $(am__append_35) $(am__append_39) $(am__append_43) \ $(am__append_46) $(am__append_62) $(am__append_65) \ - $(am__append_68) $(am__append_73) $(am__append_76) \ - $(am__append_79) $(am__append_82) $(am__append_86) + $(am__append_68) $(am__append_71) $(am__append_76) \ + $(am__append_79) $(am__append_82) $(am__append_85) \ + $(am__append_89) BUILT_SOURCES = $(am__append_25) TESTS = $(check_SCRIPTS) $(check_PROGRAMS) @@ -2227,6 +2336,10 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_relocatable_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. @GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_relocatable_test_LDADD = two_file_relocatable.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@pie_copyrelocs_test_SOURCES = pie_copyrelocs_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@pie_copyrelocs_test_DEPENDENCIES = gcctestdir/ld pie_copyrelocs_shared_test.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@pie_copyrelocs_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -pie +@GCC_TRUE@@NATIVE_LINKER_TRUE@pie_copyrelocs_test_LDADD = pie_copyrelocs_shared_test.so @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_1_nonpic_test_SOURCES = \ @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_2.cc two_file_test_main.cc @@ -2340,6 +2453,10 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_DEPENDENCIES = gcctestdir/ld weak_undef_lib.so alt/weak_undef_lib.so @GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,alt @GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_LDADD = -L . weak_undef_lib.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_2_SOURCES = weak_undef_test_2.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_2_DEPENDENCIES = gcctestdir/ld libweak_undef_2.a +@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_2_LDFLAGS = -Bgcctestdir/ -u weak_undef_2 +@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_2_LDADD = -L . -lweak_undef_2 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_nonpic_test_SOURCES = weak_undef_test.cc @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_nonpic_test_DEPENDENCIES = gcctestdir/ld weak_undef_lib_nonpic.so alt/weak_undef_lib_nonpic.so @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,alt @@ -2508,6 +2625,10 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@tls_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_4.t @GCC_TRUE@@NATIVE_LINKER_TRUE@tls_script_test_LDFLAGS = $(tls_test_LDFLAGS) -Wl,-T,$(srcdir)/script_test_4.t @GCC_TRUE@@NATIVE_LINKER_TRUE@tls_script_test_LDADD = $(tls_test_LDADD) +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_2_SOURCES = dynamic_list_2.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_2_DEPENDENCIES = gcctestdir/ld dynamic_list_lib1.so dynamic_list_lib2.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_2_LDFLAGS = -Bgcctestdir/ -L. -Wl,-R,. -Wl,--no-as-needed +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_2_LDADD = dynamic_list_lib1.so dynamic_list_lib2.so @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_SOURCES = thin_archive_main.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt @@ -2590,6 +2711,30 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncvar_DEPENDENCIES = gcctestdir/ld ifuncvar.so @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncvar_LDFLAGS = -Bgcctestdir/ -Wl,-R,. @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncvar_LDADD = ifuncvar.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_1_SOURCES = ehdr_start_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_1_DEPENDENCIES = gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_1_CXXFLAGS = +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_1_LDFLAGS = -Bgcctestdir/ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_1_LDADD = +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_2_SOURCES = ehdr_start_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_2_DEPENDENCIES = gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_2_CXXFLAGS = -DEHDR_START_WEAK +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_2_LDFLAGS = -Bgcctestdir/ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_2_LDADD = +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_3_SOURCES = ehdr_start_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_3_DEPENDENCIES = gcctestdir/ld $(srcdir)/ehdr_start_test.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_3_CXXFLAGS = -DEHDR_START_WEAK +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_3_LDFLAGS = -Bgcctestdir/ -Wl,-T,$(srcdir)/ehdr_start_test.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_3_LDADD = +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_5_SOURCES = ehdr_start_test.cc ehdr_start_def.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_5_DEPENDENCIES = gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_5_CXXFLAGS = -DEHDR_START_USER_DEF +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_5_LDFLAGS = -Bgcctestdir/ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_5_LDADD = +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_SOURCES = exception_test_main.cc +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_DEPENDENCIES = gcctestdir/ld exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS) +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDADD = exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 all: $(BUILT_SOURCES) @@ -2697,6 +2842,21 @@ copy_test$(EXEEXT): $(copy_test_OBJECTS) $(copy_test_DEPENDENCIES) discard_locals_test$(EXEEXT): $(discard_locals_test_OBJECTS) $(discard_locals_test_DEPENDENCIES) @rm -f discard_locals_test$(EXEEXT) $(discard_locals_test_LINK) $(discard_locals_test_OBJECTS) $(discard_locals_test_LDADD) $(LIBS) +dynamic_list_2$(EXEEXT): $(dynamic_list_2_OBJECTS) $(dynamic_list_2_DEPENDENCIES) + @rm -f dynamic_list_2$(EXEEXT) + $(dynamic_list_2_LINK) $(dynamic_list_2_OBJECTS) $(dynamic_list_2_LDADD) $(LIBS) +ehdr_start_test_1$(EXEEXT): $(ehdr_start_test_1_OBJECTS) $(ehdr_start_test_1_DEPENDENCIES) + @rm -f ehdr_start_test_1$(EXEEXT) + $(ehdr_start_test_1_LINK) $(ehdr_start_test_1_OBJECTS) $(ehdr_start_test_1_LDADD) $(LIBS) +ehdr_start_test_2$(EXEEXT): $(ehdr_start_test_2_OBJECTS) $(ehdr_start_test_2_DEPENDENCIES) + @rm -f ehdr_start_test_2$(EXEEXT) + $(ehdr_start_test_2_LINK) $(ehdr_start_test_2_OBJECTS) $(ehdr_start_test_2_LDADD) $(LIBS) +ehdr_start_test_3$(EXEEXT): $(ehdr_start_test_3_OBJECTS) $(ehdr_start_test_3_DEPENDENCIES) + @rm -f ehdr_start_test_3$(EXEEXT) + $(ehdr_start_test_3_LINK) $(ehdr_start_test_3_OBJECTS) $(ehdr_start_test_3_LDADD) $(LIBS) +ehdr_start_test_5$(EXEEXT): $(ehdr_start_test_5_OBJECTS) $(ehdr_start_test_5_DEPENDENCIES) + @rm -f ehdr_start_test_5$(EXEEXT) + $(ehdr_start_test_5_LINK) $(ehdr_start_test_5_OBJECTS) $(ehdr_start_test_5_LDADD) $(LIBS) exception_same_shared_test$(EXEEXT): $(exception_same_shared_test_OBJECTS) $(exception_same_shared_test_DEPENDENCIES) @rm -f exception_same_shared_test$(EXEEXT) $(exception_same_shared_test_LINK) $(exception_same_shared_test_OBJECTS) $(exception_same_shared_test_LDADD) $(LIBS) @@ -2718,6 +2878,9 @@ exception_static_test$(EXEEXT): $(exception_static_test_OBJECTS) $(exception_sta exception_test$(EXEEXT): $(exception_test_OBJECTS) $(exception_test_DEPENDENCIES) @rm -f exception_test$(EXEEXT) $(exception_test_LINK) $(exception_test_OBJECTS) $(exception_test_LDADD) $(LIBS) +exception_x86_64_bnd_test$(EXEEXT): $(exception_x86_64_bnd_test_OBJECTS) $(exception_x86_64_bnd_test_DEPENDENCIES) + @rm -f exception_x86_64_bnd_test$(EXEEXT) + $(exception_x86_64_bnd_test_LINK) $(exception_x86_64_bnd_test_OBJECTS) $(exception_x86_64_bnd_test_LDADD) $(LIBS) exclude_libs_test$(EXEEXT): $(exclude_libs_test_OBJECTS) $(exclude_libs_test_DEPENDENCIES) @rm -f exclude_libs_test$(EXEEXT) $(exclude_libs_test_LINK) $(exclude_libs_test_OBJECTS) $(exclude_libs_test_LDADD) $(LIBS) @@ -3108,6 +3271,9 @@ object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENC @NATIVE_LINKER_FALSE@permission_test$(EXEEXT): $(permission_test_OBJECTS) $(permission_test_DEPENDENCIES) @NATIVE_LINKER_FALSE@ @rm -f permission_test$(EXEEXT) @NATIVE_LINKER_FALSE@ $(LINK) $(permission_test_OBJECTS) $(permission_test_LDADD) $(LIBS) +pie_copyrelocs_test$(EXEEXT): $(pie_copyrelocs_test_OBJECTS) $(pie_copyrelocs_test_DEPENDENCIES) + @rm -f pie_copyrelocs_test$(EXEEXT) + $(pie_copyrelocs_test_LINK) $(pie_copyrelocs_test_OBJECTS) $(pie_copyrelocs_test_LDADD) $(LIBS) @GCC_FALSE@plugin_test_1$(EXEEXT): $(plugin_test_1_OBJECTS) $(plugin_test_1_DEPENDENCIES) @GCC_FALSE@ @rm -f plugin_test_1$(EXEEXT) @GCC_FALSE@ $(LINK) $(plugin_test_1_OBJECTS) $(plugin_test_1_LDADD) $(LIBS) @@ -3117,6 +3283,15 @@ object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENC @PLUGINS_FALSE@plugin_test_1$(EXEEXT): $(plugin_test_1_OBJECTS) $(plugin_test_1_DEPENDENCIES) @PLUGINS_FALSE@ @rm -f plugin_test_1$(EXEEXT) @PLUGINS_FALSE@ $(LINK) $(plugin_test_1_OBJECTS) $(plugin_test_1_LDADD) $(LIBS) +@GCC_FALSE@plugin_test_10$(EXEEXT): $(plugin_test_10_OBJECTS) $(plugin_test_10_DEPENDENCIES) +@GCC_FALSE@ @rm -f plugin_test_10$(EXEEXT) +@GCC_FALSE@ $(LINK) $(plugin_test_10_OBJECTS) $(plugin_test_10_LDADD) $(LIBS) +@NATIVE_LINKER_FALSE@plugin_test_10$(EXEEXT): $(plugin_test_10_OBJECTS) $(plugin_test_10_DEPENDENCIES) +@NATIVE_LINKER_FALSE@ @rm -f plugin_test_10$(EXEEXT) +@NATIVE_LINKER_FALSE@ $(LINK) $(plugin_test_10_OBJECTS) $(plugin_test_10_LDADD) $(LIBS) +@PLUGINS_FALSE@plugin_test_10$(EXEEXT): $(plugin_test_10_OBJECTS) $(plugin_test_10_DEPENDENCIES) +@PLUGINS_FALSE@ @rm -f plugin_test_10$(EXEEXT) +@PLUGINS_FALSE@ $(LINK) $(plugin_test_10_OBJECTS) $(plugin_test_10_LDADD) $(LIBS) @GCC_FALSE@plugin_test_2$(EXEEXT): $(plugin_test_2_OBJECTS) $(plugin_test_2_DEPENDENCIES) @GCC_FALSE@ @rm -f plugin_test_2$(EXEEXT) @GCC_FALSE@ $(LINK) $(plugin_test_2_OBJECTS) $(plugin_test_2_LDADD) $(LIBS) @@ -3414,6 +3589,9 @@ weak_undef_nonpic_test$(EXEEXT): $(weak_undef_nonpic_test_OBJECTS) $(weak_undef_ weak_undef_test$(EXEEXT): $(weak_undef_test_OBJECTS) $(weak_undef_test_DEPENDENCIES) @rm -f weak_undef_test$(EXEEXT) $(weak_undef_test_LINK) $(weak_undef_test_OBJECTS) $(weak_undef_test_LDADD) $(LIBS) +weak_undef_test_2$(EXEEXT): $(weak_undef_test_2_OBJECTS) $(weak_undef_test_2_DEPENDENCIES) + @rm -f weak_undef_test_2$(EXEEXT) + $(weak_undef_test_2_LINK) $(weak_undef_test_2_OBJECTS) $(weak_undef_test_2_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -3432,6 +3610,12 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constructor_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/discard_locals_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamic_list_2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehdr_start_test_1-ehdr_start_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehdr_start_test_2-ehdr_start_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehdr_start_test_3-ehdr_start_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehdr_start_test_5-ehdr_start_def.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehdr_start_test_5-ehdr_start_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_main.Po@am__quote@ @@ -3489,7 +3673,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_unittest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/permission_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pie_copyrelocs_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_10.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_4.Po@am__quote@ @@ -3534,6 +3720,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_plt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_undef_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_undef_test_2.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -3577,6 +3764,76 @@ large-large.obj: large.c @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +ehdr_start_test_1-ehdr_start_test.o: ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_1_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_1-ehdr_start_test.o -MD -MP -MF $(DEPDIR)/ehdr_start_test_1-ehdr_start_test.Tpo -c -o ehdr_start_test_1-ehdr_start_test.o `test -f 'ehdr_start_test.cc' || echo '$(srcdir)/'`ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_1-ehdr_start_test.Tpo $(DEPDIR)/ehdr_start_test_1-ehdr_start_test.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_test.cc' object='ehdr_start_test_1-ehdr_start_test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_1_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_1-ehdr_start_test.o `test -f 'ehdr_start_test.cc' || echo '$(srcdir)/'`ehdr_start_test.cc + +ehdr_start_test_1-ehdr_start_test.obj: ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_1_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_1-ehdr_start_test.obj -MD -MP -MF $(DEPDIR)/ehdr_start_test_1-ehdr_start_test.Tpo -c -o ehdr_start_test_1-ehdr_start_test.obj `if test -f 'ehdr_start_test.cc'; then $(CYGPATH_W) 'ehdr_start_test.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_test.cc'; fi` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_1-ehdr_start_test.Tpo $(DEPDIR)/ehdr_start_test_1-ehdr_start_test.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_test.cc' object='ehdr_start_test_1-ehdr_start_test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_1_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_1-ehdr_start_test.obj `if test -f 'ehdr_start_test.cc'; then $(CYGPATH_W) 'ehdr_start_test.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_test.cc'; fi` + +ehdr_start_test_2-ehdr_start_test.o: ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_2_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_2-ehdr_start_test.o -MD -MP -MF $(DEPDIR)/ehdr_start_test_2-ehdr_start_test.Tpo -c -o ehdr_start_test_2-ehdr_start_test.o `test -f 'ehdr_start_test.cc' || echo '$(srcdir)/'`ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_2-ehdr_start_test.Tpo $(DEPDIR)/ehdr_start_test_2-ehdr_start_test.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_test.cc' object='ehdr_start_test_2-ehdr_start_test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_2_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_2-ehdr_start_test.o `test -f 'ehdr_start_test.cc' || echo '$(srcdir)/'`ehdr_start_test.cc + +ehdr_start_test_2-ehdr_start_test.obj: ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_2_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_2-ehdr_start_test.obj -MD -MP -MF $(DEPDIR)/ehdr_start_test_2-ehdr_start_test.Tpo -c -o ehdr_start_test_2-ehdr_start_test.obj `if test -f 'ehdr_start_test.cc'; then $(CYGPATH_W) 'ehdr_start_test.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_test.cc'; fi` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_2-ehdr_start_test.Tpo $(DEPDIR)/ehdr_start_test_2-ehdr_start_test.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_test.cc' object='ehdr_start_test_2-ehdr_start_test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_2_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_2-ehdr_start_test.obj `if test -f 'ehdr_start_test.cc'; then $(CYGPATH_W) 'ehdr_start_test.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_test.cc'; fi` + +ehdr_start_test_3-ehdr_start_test.o: ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_3_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_3-ehdr_start_test.o -MD -MP -MF $(DEPDIR)/ehdr_start_test_3-ehdr_start_test.Tpo -c -o ehdr_start_test_3-ehdr_start_test.o `test -f 'ehdr_start_test.cc' || echo '$(srcdir)/'`ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_3-ehdr_start_test.Tpo $(DEPDIR)/ehdr_start_test_3-ehdr_start_test.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_test.cc' object='ehdr_start_test_3-ehdr_start_test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_3_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_3-ehdr_start_test.o `test -f 'ehdr_start_test.cc' || echo '$(srcdir)/'`ehdr_start_test.cc + +ehdr_start_test_3-ehdr_start_test.obj: ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_3_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_3-ehdr_start_test.obj -MD -MP -MF $(DEPDIR)/ehdr_start_test_3-ehdr_start_test.Tpo -c -o ehdr_start_test_3-ehdr_start_test.obj `if test -f 'ehdr_start_test.cc'; then $(CYGPATH_W) 'ehdr_start_test.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_test.cc'; fi` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_3-ehdr_start_test.Tpo $(DEPDIR)/ehdr_start_test_3-ehdr_start_test.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_test.cc' object='ehdr_start_test_3-ehdr_start_test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_3_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_3-ehdr_start_test.obj `if test -f 'ehdr_start_test.cc'; then $(CYGPATH_W) 'ehdr_start_test.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_test.cc'; fi` + +ehdr_start_test_5-ehdr_start_test.o: ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_5_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_5-ehdr_start_test.o -MD -MP -MF $(DEPDIR)/ehdr_start_test_5-ehdr_start_test.Tpo -c -o ehdr_start_test_5-ehdr_start_test.o `test -f 'ehdr_start_test.cc' || echo '$(srcdir)/'`ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_5-ehdr_start_test.Tpo $(DEPDIR)/ehdr_start_test_5-ehdr_start_test.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_test.cc' object='ehdr_start_test_5-ehdr_start_test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_5_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_5-ehdr_start_test.o `test -f 'ehdr_start_test.cc' || echo '$(srcdir)/'`ehdr_start_test.cc + +ehdr_start_test_5-ehdr_start_test.obj: ehdr_start_test.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_5_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_5-ehdr_start_test.obj -MD -MP -MF $(DEPDIR)/ehdr_start_test_5-ehdr_start_test.Tpo -c -o ehdr_start_test_5-ehdr_start_test.obj `if test -f 'ehdr_start_test.cc'; then $(CYGPATH_W) 'ehdr_start_test.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_test.cc'; fi` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_5-ehdr_start_test.Tpo $(DEPDIR)/ehdr_start_test_5-ehdr_start_test.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_test.cc' object='ehdr_start_test_5-ehdr_start_test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_5_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_5-ehdr_start_test.obj `if test -f 'ehdr_start_test.cc'; then $(CYGPATH_W) 'ehdr_start_test.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_test.cc'; fi` + +ehdr_start_test_5-ehdr_start_def.o: ehdr_start_def.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_5_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_5-ehdr_start_def.o -MD -MP -MF $(DEPDIR)/ehdr_start_test_5-ehdr_start_def.Tpo -c -o ehdr_start_test_5-ehdr_start_def.o `test -f 'ehdr_start_def.cc' || echo '$(srcdir)/'`ehdr_start_def.cc +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_5-ehdr_start_def.Tpo $(DEPDIR)/ehdr_start_test_5-ehdr_start_def.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_def.cc' object='ehdr_start_test_5-ehdr_start_def.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_5_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_5-ehdr_start_def.o `test -f 'ehdr_start_def.cc' || echo '$(srcdir)/'`ehdr_start_def.cc + +ehdr_start_test_5-ehdr_start_def.obj: ehdr_start_def.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_5_CXXFLAGS) $(CXXFLAGS) -MT ehdr_start_test_5-ehdr_start_def.obj -MD -MP -MF $(DEPDIR)/ehdr_start_test_5-ehdr_start_def.Tpo -c -o ehdr_start_test_5-ehdr_start_def.obj `if test -f 'ehdr_start_def.cc'; then $(CYGPATH_W) 'ehdr_start_def.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_def.cc'; fi` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/ehdr_start_test_5-ehdr_start_def.Tpo $(DEPDIR)/ehdr_start_test_5-ehdr_start_def.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ehdr_start_def.cc' object='ehdr_start_test_5-ehdr_start_def.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ehdr_start_test_5_CXXFLAGS) $(CXXFLAGS) -c -o ehdr_start_test_5-ehdr_start_def.obj `if test -f 'ehdr_start_def.cc'; then $(CYGPATH_W) 'ehdr_start_def.cc'; else $(CYGPATH_W) '$(srcdir)/ehdr_start_def.cc'; fi` + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -3791,6 +4048,8 @@ gc_orphan_section_test.sh.log: gc_orphan_section_test.sh @p='gc_orphan_section_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) pr14265.sh.log: pr14265.sh @p='pr14265.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +gc_dynamic_list_test.sh.log: gc_dynamic_list_test.sh + @p='gc_dynamic_list_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) icf_test.sh.log: icf_test.sh @p='icf_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) icf_keep_unique_test.sh.log: icf_keep_unique_test.sh @@ -3867,6 +4126,8 @@ plugin_test_6.sh.log: plugin_test_6.sh @p='plugin_test_6.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_test_7.sh.log: plugin_test_7.sh @p='plugin_test_7.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +plugin_test_10.sh.log: plugin_test_10.sh + @p='plugin_test_10.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_test_tls.sh.log: plugin_test_tls.sh @p='plugin_test_tls.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_final_layout.sh.log: plugin_final_layout.sh @@ -3895,6 +4156,10 @@ gdb_index_test_3.sh.log: gdb_index_test_3.sh @p='gdb_index_test_3.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) gdb_index_test_4.sh.log: gdb_index_test_4.sh @p='gdb_index_test_4.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +ehdr_start_test_4.sh.log: ehdr_start_test_4.sh + @p='ehdr_start_test_4.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +defsym_test.sh.log: defsym_test.sh + @p='defsym_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) script_test_10.sh.log: script_test_10.sh @p='script_test_10.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) split_i386.sh.log: split_i386.sh @@ -3981,6 +4246,8 @@ two_file_relocatable_test.log: two_file_relocatable_test$(EXEEXT) @p='two_file_relocatable_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) two_file_pie_test.log: two_file_pie_test$(EXEEXT) @p='two_file_pie_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +pie_copyrelocs_test.log: pie_copyrelocs_test$(EXEEXT) + @p='pie_copyrelocs_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) two_file_shared_1_nonpic_test.log: two_file_shared_1_nonpic_test$(EXEEXT) @p='two_file_shared_1_nonpic_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) two_file_shared_2_nonpic_test.log: two_file_shared_2_nonpic_test$(EXEEXT) @@ -4023,6 +4290,8 @@ weak_test.log: weak_test$(EXEEXT) @p='weak_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) weak_undef_test.log: weak_undef_test$(EXEEXT) @p='weak_undef_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +weak_undef_test_2.log: weak_undef_test_2$(EXEEXT) + @p='weak_undef_test_2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) weak_undef_nonpic_test.log: weak_undef_nonpic_test$(EXEEXT) @p='weak_undef_nonpic_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) weak_alias_test.log: weak_alias_test$(EXEEXT) @@ -4117,6 +4386,8 @@ tls_script_test.log: tls_script_test$(EXEEXT) @p='tls_script_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) script_test_11.log: script_test_11$(EXEEXT) @p='script_test_11$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +dynamic_list_2.log: dynamic_list_2$(EXEEXT) + @p='dynamic_list_2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) thin_archive_test_1.log: thin_archive_test_1$(EXEEXT) @p='thin_archive_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) thin_archive_test_2.log: thin_archive_test_2$(EXEEXT) @@ -4137,6 +4408,8 @@ plugin_test_7.log: plugin_test_7$(EXEEXT) @p='plugin_test_7$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_test_8.log: plugin_test_8$(EXEEXT) @p='plugin_test_8$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +plugin_test_10.log: plugin_test_10$(EXEEXT) + @p='plugin_test_10$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_test_tls.log: plugin_test_tls$(EXEEXT) @p='plugin_test_tls$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) exclude_libs_test.log: exclude_libs_test$(EXEEXT) @@ -4215,6 +4488,14 @@ ifuncvar.log: ifuncvar$(EXEEXT) @p='ifuncvar$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) start_lib_test.log: start_lib_test$(EXEEXT) @p='start_lib_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +ehdr_start_test_1.log: ehdr_start_test_1$(EXEEXT) + @p='ehdr_start_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +ehdr_start_test_2.log: ehdr_start_test_2$(EXEEXT) + @p='ehdr_start_test_2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +ehdr_start_test_3.log: ehdr_start_test_3$(EXEEXT) + @p='ehdr_start_test_3$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +ehdr_start_test_5.log: ehdr_start_test_5$(EXEEXT) + @p='ehdr_start_test_5$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) incremental_test_2.log: incremental_test_2$(EXEEXT) @p='incremental_test_2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) incremental_test_3.log: incremental_test_3$(EXEEXT) @@ -4231,6 +4512,8 @@ incremental_common_test_1.log: incremental_common_test_1$(EXEEXT) @p='incremental_common_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) incremental_comdat_test_1.log: incremental_comdat_test_1$(EXEEXT) @p='incremental_comdat_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +exception_x86_64_bnd_test.log: exception_x86_64_bnd_test$(EXEEXT) + @p='exception_x86_64_bnd_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) .test.log: @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @@ -4432,6 +4715,12 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,-T,$(srcdir)/pr14265.t -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@pr14265.stdout: pr14265 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) --format=bsd --numeric-sort $< > $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_dynamic_list_test.o: gc_dynamic_list_test.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -ffunction-sections -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_dynamic_list_test: gc_dynamic_list_test.o gcctestdir/ld $(srcdir)/gc_dynamic_list_test.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,--dynamic-list,$(srcdir)/gc_dynamic_list_test.t gc_dynamic_list_test.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_dynamic_list_test.stdout: gc_dynamic_list_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) gc_dynamic_list_test > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.o: icf_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test: icf_test.o gcctestdir/ld @@ -4564,6 +4853,10 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_pie_test: two_file_test_1_pie.o two_file_test_1b_pie.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_2_pie.o two_file_test_main_pie.o gcctestdir/ld @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -pie two_file_test_1_pie.o two_file_test_1b_pie.o two_file_test_2_pie.o two_file_test_main_pie.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@pie_copyrelocs_shared_test.o: pie_copyrelocs_shared_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O2 -fpic -c -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@pie_copyrelocs_shared_test.so: pie_copyrelocs_shared_test.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared pie_copyrelocs_shared_test.o @GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared.dbg: two_file_shared.so @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -w $< >$@ 2>/dev/null @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_1_nonpic.so: two_file_test_1.o gcctestdir/ld @@ -4610,6 +4903,12 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@alt/weak_undef_lib.so: weak_undef_file2.o @GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file2.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@libweak_undef_2.a: weak_undef_file3.o weak_undef_file4.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^ +@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_file3.o: weak_undef_file3.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_file4.o: weak_undef_file4.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $< @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_file1_nonpic.o: weak_undef_file1.cc @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $< @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_file2_nonpic.o: weak_undef_file2.cc @@ -4961,6 +5260,16 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list.stdout: dynamic_list @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_lib1.so: gcctestdir/ld dynamic_list_lib1.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared dynamic_list_lib1.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_lib1.o: dynamic_list_lib1.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $< + +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_lib2.so: gcctestdir/ld dynamic_list_lib2.o $(srcdir)/dynamic_list_2.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,--dynamic-list,$(srcdir)/dynamic_list_2.t dynamic_list_lib2.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_lib2.o: dynamic_list_lib2.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $< + @GCC_TRUE@@NATIVE_LINKER_TRUE@libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o @GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^ @@ -5038,6 +5347,10 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ mv -f $@.tmp $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_1c.o: two_file_test_1.o @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ cp two_file_test_1.o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_10: plugin_common_test_1.syms plugin_common_test_2.o gcctestdir/ld plugin_test.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.syms plugin_common_test_2.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_10.sections: plugin_test_10 +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -SW $< >$@ 2>/dev/null @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test.so: plugin_test.o @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(LINK) -Bgcctestdir/ -shared plugin_test.o @@ -5315,6 +5628,18 @@ uninstall-am: @GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $< @GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@gdb_index_test_4.stdout: gdb_index_test_4 @GCC_TRUE@@HAVE_PUBNAMES_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) --debug-dump=gdb_index $< > $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_4.syms: ehdr_start_test_4 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) ehdr_start_test_4 > $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_4: ehdr_start_test_4.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,-Ttext=0x100100 $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_4.o: ehdr_start_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -DEHDR_START_WEAK -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@defsym_test.syms: defsym_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -sW $< > $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@defsym_test: defsym_test.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--defsym=bar=foo defsym_test.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@defsym_test.o: defsym_test.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -o $@ $< # End-to-end incremental linking tests. # Incremental linking is currently supported only on the x86_64 target. @@ -5390,6 +5715,10 @@ uninstall-am: @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ @sleep 1 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp -f incr_comdat_test_2_v3.o incr_comdat_test_1_tmp.o @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_1.o: exception_test_1.cc gcctestdir/as +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $< +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_2.o: exception_test_2.cc gcctestdir/as +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $< @NATIVE_OR_CROSS_LINKER_TRUE@script_test_10.o: script_test_10.s @NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $< @NATIVE_OR_CROSS_LINKER_TRUE@script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld diff --git a/binutils-2.25/gold/testsuite/arm_abs_global.sh b/binutils-2.25/gold/testsuite/arm_abs_global.sh index 26abc24..7445b1c 100755 --- a/binutils-2.25/gold/testsuite/arm_abs_global.sh +++ b/binutils-2.25/gold/testsuite/arm_abs_global.sh @@ -2,7 +2,7 @@ # arm_abs_global.sh -- test ARM absolute relocations against global symbols. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_attr_merge.sh b/binutils-2.25/gold/testsuite/arm_attr_merge.sh index 3066f4f..a579bb4 100755 --- a/binutils-2.25/gold/testsuite/arm_attr_merge.sh +++ b/binutils-2.25/gold/testsuite/arm_attr_merge.sh @@ -2,7 +2,7 @@ # arm_attr_merge.sh -- test ARM attributes merging. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_branch_in_range.sh b/binutils-2.25/gold/testsuite/arm_branch_in_range.sh index dc6f36f..b034c9b 100755 --- a/binutils-2.25/gold/testsuite/arm_branch_in_range.sh +++ b/binutils-2.25/gold/testsuite/arm_branch_in_range.sh @@ -3,7 +3,7 @@ # arm_branch_in_range.sh -- test ARM/THUMB/THUMB branch instructions whose # targets are just within the branch range limits. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_branch_out_of_range.sh b/binutils-2.25/gold/testsuite/arm_branch_out_of_range.sh index aac638f..aba1873 100755 --- a/binutils-2.25/gold/testsuite/arm_branch_out_of_range.sh +++ b/binutils-2.25/gold/testsuite/arm_branch_out_of_range.sh @@ -3,7 +3,7 @@ # arm_branch_out_of_range.sh -- test ARM/THUMB/THUMB branch instructions whose # targets are just out of the branch range limits. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_branch_range.t b/binutils-2.25/gold/testsuite/arm_branch_range.t index 865e404..7db4c64 100644 --- a/binutils-2.25/gold/testsuite/arm_branch_range.t +++ b/binutils-2.25/gold/testsuite/arm_branch_range.t @@ -1,6 +1,6 @@ /* arm_banch_range.t -- linker script to test ARM branch range. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Doug Kwan <dougkwan@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_cortex_a8.sh b/binutils-2.25/gold/testsuite/arm_cortex_a8.sh index 5e25c25..cd7c3c8 100755 --- a/binutils-2.25/gold/testsuite/arm_cortex_a8.sh +++ b/binutils-2.25/gold/testsuite/arm_cortex_a8.sh @@ -2,7 +2,7 @@ # arm_cortex_a8.sh -- a test case for the Cortex-A8 workaround. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_exidx_test.sh b/binutils-2.25/gold/testsuite/arm_exidx_test.sh index e196f12..9f7bd75 100755 --- a/binutils-2.25/gold/testsuite/arm_exidx_test.sh +++ b/binutils-2.25/gold/testsuite/arm_exidx_test.sh @@ -2,7 +2,7 @@ # arm_exidx_test.sh -- a test case for .ARM.exidx section. -# Copyright 2011 Free Software Foundation, Inc. +# Copyright (C) 2011-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_farcall_arm_arm.sh b/binutils-2.25/gold/testsuite/arm_farcall_arm_arm.sh index 7d95528..ae59dd2 100755 --- a/binutils-2.25/gold/testsuite/arm_farcall_arm_arm.sh +++ b/binutils-2.25/gold/testsuite/arm_farcall_arm_arm.sh @@ -2,7 +2,7 @@ # arm_farcall_arm_arm.sh -- a test case for ARM->ARM farcall veneers -# Copyright 2010, 2011, Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Matthew Gretton-Dann <matthew.gretton-dann@arm.com> # Based upon arm_cortex_a8.sh # Written by Doug Kwan <dougkwan@google.com>. diff --git a/binutils-2.25/gold/testsuite/arm_farcall_arm_thumb.sh b/binutils-2.25/gold/testsuite/arm_farcall_arm_thumb.sh index 2df2d65..8847f44 100755 --- a/binutils-2.25/gold/testsuite/arm_farcall_arm_thumb.sh +++ b/binutils-2.25/gold/testsuite/arm_farcall_arm_thumb.sh @@ -2,7 +2,7 @@ # arm_farcall_arm_thumb.sh -- a test case for ARM->Thumb farcall veneers. -# Copyright 2010, 2011, Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Matthew Gretton-Dann <matthew.gretton-dann@arm.com> # Based upon arm_cortex_a8.sh # Written by Doug Kwan <dougkwan@google.com>. diff --git a/binutils-2.25/gold/testsuite/arm_farcall_thumb_arm.sh b/binutils-2.25/gold/testsuite/arm_farcall_thumb_arm.sh index e22da46..b13e783 100755 --- a/binutils-2.25/gold/testsuite/arm_farcall_thumb_arm.sh +++ b/binutils-2.25/gold/testsuite/arm_farcall_thumb_arm.sh @@ -2,7 +2,7 @@ # arm_farcall_thumb_arm.sh -- a test case for Thumb->ARM farcall veneers. -# Copyright 2010, 2011, Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Matthew Gretton-Dann <matthew.gretton-dann@arm.com> # Based upon arm_cortex_a8.sh # Written by Doug Kwan <dougkwan@google.com>. diff --git a/binutils-2.25/gold/testsuite/arm_farcall_thumb_thumb.sh b/binutils-2.25/gold/testsuite/arm_farcall_thumb_thumb.sh index 23fb0cd..838535c 100755 --- a/binutils-2.25/gold/testsuite/arm_farcall_thumb_thumb.sh +++ b/binutils-2.25/gold/testsuite/arm_farcall_thumb_thumb.sh @@ -2,7 +2,7 @@ # arm_farcall_thumb_thumb.sh -- a test case for Thumb->Thumb farcall veneers. -# Copyright 2010, 2011, Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Matthew Gretton-Dann <matthew.gretton-dann@arm.com> # Based upon arm_cortex_a8.sh # Written by Doug Kwan <dougkwan@google.com>. diff --git a/binutils-2.25/gold/testsuite/arm_fix_1176.sh b/binutils-2.25/gold/testsuite/arm_fix_1176.sh index 152b0a3..4fe5465 100755 --- a/binutils-2.25/gold/testsuite/arm_fix_1176.sh +++ b/binutils-2.25/gold/testsuite/arm_fix_1176.sh @@ -2,7 +2,7 @@ # arm_fix_1176.sh -- a test case for the ARM1176 workaround. -# Copyright 2010, 2011, Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Matthew Gretton-Dann <matthew.gretton-dann@arm.com> # Based upon arm_cortex_a8.sh # Written by Doug Kwan <dougkwan@google.com>. diff --git a/binutils-2.25/gold/testsuite/arm_fix_v4bx.sh b/binutils-2.25/gold/testsuite/arm_fix_v4bx.sh index a331ff9..aeead67 100755 --- a/binutils-2.25/gold/testsuite/arm_fix_v4bx.sh +++ b/binutils-2.25/gold/testsuite/arm_fix_v4bx.sh @@ -2,7 +2,7 @@ # arm_v4bx.sh -- a test case for --fix-v4bx and --fix-v4bx-interworking. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_thm_jump11.t b/binutils-2.25/gold/testsuite/arm_thm_jump11.t index 2ec4143..abd2252 100644 --- a/binutils-2.25/gold/testsuite/arm_thm_jump11.t +++ b/binutils-2.25/gold/testsuite/arm_thm_jump11.t @@ -1,6 +1,6 @@ /* arm_thm_jump11.t -- linker script to test R_ARM_THM_JUMP11 relocation. - Copyright 2011 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. Written by Doug Kwan <dougkwan@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_thm_jump8.t b/binutils-2.25/gold/testsuite/arm_thm_jump8.t index fa674b4..d2af57d 100644 --- a/binutils-2.25/gold/testsuite/arm_thm_jump8.t +++ b/binutils-2.25/gold/testsuite/arm_thm_jump8.t @@ -1,6 +1,6 @@ /* arm_thm_jump8.t -- linker script to test R_ARM_THM_JUMP8 relocation. - Copyright 2011 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. Written by Doug Kwan <dougkwan@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/arm_unaligned_reloc.sh b/binutils-2.25/gold/testsuite/arm_unaligned_reloc.sh index 39a5a11..bb1c43e 100755 --- a/binutils-2.25/gold/testsuite/arm_unaligned_reloc.sh +++ b/binutils-2.25/gold/testsuite/arm_unaligned_reloc.sh @@ -2,7 +2,7 @@ # arm_unaligned_reloc.sh -- test ARM unaligned static data relocations. -# Copyright 2011 Free Software Foundation, Inc. +# Copyright (C) 2011-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/basic_test.cc b/binutils-2.25/gold/testsuite/basic_test.cc index 94910be..a8729cf 100644 --- a/binutils-2.25/gold/testsuite/basic_test.cc +++ b/binutils-2.25/gold/testsuite/basic_test.cc @@ -1,6 +1,6 @@ // basic_test.cc -- a test case for gold -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/binary_test.cc b/binutils-2.25/gold/testsuite/binary_test.cc index d645536..be788bd 100644 --- a/binutils-2.25/gold/testsuite/binary_test.cc +++ b/binutils-2.25/gold/testsuite/binary_test.cc @@ -1,6 +1,6 @@ // binary_test.cc -- test --format binary for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/binary_unittest.cc b/binutils-2.25/gold/testsuite/binary_unittest.cc index fe10922..f920de8 100644 --- a/binutils-2.25/gold/testsuite/binary_unittest.cc +++ b/binutils-2.25/gold/testsuite/binary_unittest.cc @@ -1,6 +1,6 @@ // binary_unittest.cc -- test Binary_to_elf -// Copyright 2008, 2012 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/common_test_1.c b/binutils-2.25/gold/testsuite/common_test_1.c index f5a28f4..8c79a0b 100644 --- a/binutils-2.25/gold/testsuite/common_test_1.c +++ b/binutils-2.25/gold/testsuite/common_test_1.c @@ -1,6 +1,6 @@ /* common_test_1.c -- test common symbol sorting - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/common_test_1_v1.c b/binutils-2.25/gold/testsuite/common_test_1_v1.c index 86abc40..db65063 100644 --- a/binutils-2.25/gold/testsuite/common_test_1_v1.c +++ b/binutils-2.25/gold/testsuite/common_test_1_v1.c @@ -1,6 +1,6 @@ /* common_test_1_v1.c -- test common symbol sorting - Copyright 2008, 2011 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/common_test_1_v2.c b/binutils-2.25/gold/testsuite/common_test_1_v2.c index c66a647..81614bf 100644 --- a/binutils-2.25/gold/testsuite/common_test_1_v2.c +++ b/binutils-2.25/gold/testsuite/common_test_1_v2.c @@ -1,6 +1,6 @@ /* common_test_1_v2.c -- test common symbol sorting - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/common_test_2.c b/binutils-2.25/gold/testsuite/common_test_2.c index ef6d83d..9f29dfb 100644 --- a/binutils-2.25/gold/testsuite/common_test_2.c +++ b/binutils-2.25/gold/testsuite/common_test_2.c @@ -1,6 +1,6 @@ /* common_test_2.c -- test common symbol name conflicts - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/common_test_3.c b/binutils-2.25/gold/testsuite/common_test_3.c index ba8960c..a8d8120 100644 --- a/binutils-2.25/gold/testsuite/common_test_3.c +++ b/binutils-2.25/gold/testsuite/common_test_3.c @@ -1,6 +1,6 @@ /* common_test_3.c -- test common symbol name conflicts - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/constructor_test.cc b/binutils-2.25/gold/testsuite/constructor_test.cc index 8889a83..5c3aa53 100644 --- a/binutils-2.25/gold/testsuite/constructor_test.cc +++ b/binutils-2.25/gold/testsuite/constructor_test.cc @@ -1,6 +1,6 @@ // constructor_test.cc -- a test case for gold global constructors -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/copy_test.cc b/binutils-2.25/gold/testsuite/copy_test.cc index 715529d..856511d 100644 --- a/binutils-2.25/gold/testsuite/copy_test.cc +++ b/binutils-2.25/gold/testsuite/copy_test.cc @@ -1,6 +1,6 @@ // copy_test.cc -- test copy relocs for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/copy_test_1.cc b/binutils-2.25/gold/testsuite/copy_test_1.cc index 1471bb5..b653ded 100644 --- a/binutils-2.25/gold/testsuite/copy_test_1.cc +++ b/binutils-2.25/gold/testsuite/copy_test_1.cc @@ -1,6 +1,6 @@ // copy_test_1.cc -- test copy relocs for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/copy_test_2.cc b/binutils-2.25/gold/testsuite/copy_test_2.cc index 0105150..8fd722a 100644 --- a/binutils-2.25/gold/testsuite/copy_test_2.cc +++ b/binutils-2.25/gold/testsuite/copy_test_2.cc @@ -1,6 +1,6 @@ // copy_test_2.cc -- test copy relocs variables for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/copy_test_v1.cc b/binutils-2.25/gold/testsuite/copy_test_v1.cc index 63f7dfd..ce02884 100644 --- a/binutils-2.25/gold/testsuite/copy_test_v1.cc +++ b/binutils-2.25/gold/testsuite/copy_test_v1.cc @@ -1,6 +1,6 @@ // copy_test_v1.cc -- test copy relocs for gold -// Copyright 2008, 2011 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/debug_msg.cc b/binutils-2.25/gold/testsuite/debug_msg.cc index 0912002..e5beb5f 100644 --- a/binutils-2.25/gold/testsuite/debug_msg.cc +++ b/binutils-2.25/gold/testsuite/debug_msg.cc @@ -1,6 +1,6 @@ // debug_msg.cc -- a test case for printing debug info for missing symbols. -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/debug_msg.sh b/binutils-2.25/gold/testsuite/debug_msg.sh index 1227f3f..4426762 100755 --- a/binutils-2.25/gold/testsuite/debug_msg.sh +++ b/binutils-2.25/gold/testsuite/debug_msg.sh @@ -2,8 +2,7 @@ # debug_msg.sh -- a test case for printing debug info for missing symbols. -# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013 -# Free Software Foundation, Inc. +# Copyright (C) 2006-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/defsym_test.c b/binutils-2.25/gold/testsuite/defsym_test.c new file mode 100644 index 0000000..0bf68b2 --- /dev/null +++ b/binutils-2.25/gold/testsuite/defsym_test.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +void foo (void) __attribute__ ((noinline, visibility ("hidden"))); + +void foo (void) { + printf("foo called.\n"); +} + +void bar(void); + +int main(void) { + foo(); + bar(); + return 0; +} diff --git a/binutils-2.25/gold/testsuite/defsym_test.sh b/binutils-2.25/gold/testsuite/defsym_test.sh new file mode 100755 index 0000000..6c1ff11 --- /dev/null +++ b/binutils-2.25/gold/testsuite/defsym_test.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# defsym_test.sh -- test that --defsym copies type and visiblity. + +# Copyright (C) 2014 Free Software Foundation, Inc. +# Written by Cary Coutant <ccoutant@google.com>. + +# This file is part of gold. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Did not find expected symbol in $1:" + echo " $2" + echo "" + echo "Actual output below:" + cat "$1" + exit 1 + fi +} + +check defsym_test.syms "FUNC *GLOBAL *HIDDEN .* bar" + +exit 0 diff --git a/binutils-2.25/gold/testsuite/discard_locals_relocatable_test.c b/binutils-2.25/gold/testsuite/discard_locals_relocatable_test.c index f7f8b27..79f82db 100644 --- a/binutils-2.25/gold/testsuite/discard_locals_relocatable_test.c +++ b/binutils-2.25/gold/testsuite/discard_locals_relocatable_test.c @@ -1,6 +1,6 @@ /* discard_locals_relocatable_test.c -- test --discard-locals/--discard-all -r - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Viktor Kutuzov <vkutuzov@accesssoftek.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/discard_locals_test.c b/binutils-2.25/gold/testsuite/discard_locals_test.c index b722447..e8766c8 100644 --- a/binutils-2.25/gold/testsuite/discard_locals_test.c +++ b/binutils-2.25/gold/testsuite/discard_locals_test.c @@ -1,6 +1,6 @@ /* discard_locals_test.c -- test --discard-locals option. - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Doug Kwan <dougkwan@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/discard_locals_test.sh b/binutils-2.25/gold/testsuite/discard_locals_test.sh index 3fc679a..185d09b 100755 --- a/binutils-2.25/gold/testsuite/discard_locals_test.sh +++ b/binutils-2.25/gold/testsuite/discard_locals_test.sh @@ -2,7 +2,7 @@ # discard_locals_test.sh -- test that local symbols are discarded. -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dwp_test.h b/binutils-2.25/gold/testsuite/dwp_test.h index 37256d3..8e265ee 100644 --- a/binutils-2.25/gold/testsuite/dwp_test.h +++ b/binutils-2.25/gold/testsuite/dwp_test.h @@ -1,6 +1,6 @@ // dwp_test.h -- a test case for dwp, header file -*- C++ -*- -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dwp_test_1.cc b/binutils-2.25/gold/testsuite/dwp_test_1.cc index 71fbc5b..b3ae8bc 100644 --- a/binutils-2.25/gold/testsuite/dwp_test_1.cc +++ b/binutils-2.25/gold/testsuite/dwp_test_1.cc @@ -1,6 +1,6 @@ // dwp_test_1.cc -- a test case for dwp -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dwp_test_1.sh b/binutils-2.25/gold/testsuite/dwp_test_1.sh index 7831a49..90146ac 100755 --- a/binutils-2.25/gold/testsuite/dwp_test_1.sh +++ b/binutils-2.25/gold/testsuite/dwp_test_1.sh @@ -2,7 +2,7 @@ # dwp_test_1.sh -- Test the dwp tool. -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dwp_test_1b.cc b/binutils-2.25/gold/testsuite/dwp_test_1b.cc index c75376b..7ca28a5 100644 --- a/binutils-2.25/gold/testsuite/dwp_test_1b.cc +++ b/binutils-2.25/gold/testsuite/dwp_test_1b.cc @@ -1,6 +1,6 @@ // dwp_test_1b.cc -- a test case for dwp -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dwp_test_2.cc b/binutils-2.25/gold/testsuite/dwp_test_2.cc index a1172b3..10baef0 100644 --- a/binutils-2.25/gold/testsuite/dwp_test_2.cc +++ b/binutils-2.25/gold/testsuite/dwp_test_2.cc @@ -1,6 +1,6 @@ // dwp_test_2.cc -- a test case for dwp -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dwp_test_2.sh b/binutils-2.25/gold/testsuite/dwp_test_2.sh index 619d73b..dd0fe51 100755 --- a/binutils-2.25/gold/testsuite/dwp_test_2.sh +++ b/binutils-2.25/gold/testsuite/dwp_test_2.sh @@ -2,7 +2,7 @@ # dwp_test_2.sh -- Test the dwp tool. -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dwp_test_main.cc b/binutils-2.25/gold/testsuite/dwp_test_main.cc index abddc0f..7cf72ca 100644 --- a/binutils-2.25/gold/testsuite/dwp_test_main.cc +++ b/binutils-2.25/gold/testsuite/dwp_test_main.cc @@ -1,6 +1,6 @@ // dwp_test_main.cc -- a test case for dwp -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dyn_weak_ref.sh b/binutils-2.25/gold/testsuite/dyn_weak_ref.sh index b52efac..e2d200d 100755 --- a/binutils-2.25/gold/testsuite/dyn_weak_ref.sh +++ b/binutils-2.25/gold/testsuite/dyn_weak_ref.sh @@ -3,7 +3,7 @@ # dyn_weak_ref.sh -- test weak reference remains weak in output even if # gold sees a dynamic weak reference before a static one. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dyn_weak_ref_1.c b/binutils-2.25/gold/testsuite/dyn_weak_ref_1.c index fdd78dd..b32f3a8 100644 --- a/binutils-2.25/gold/testsuite/dyn_weak_ref_1.c +++ b/binutils-2.25/gold/testsuite/dyn_weak_ref_1.c @@ -1,7 +1,7 @@ // dyn_weak_ref_1.c -- test that a weak ref remains weak in output when // there is a DSO with the same weak ref. -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dyn_weak_ref_2.c b/binutils-2.25/gold/testsuite/dyn_weak_ref_2.c index 8a087a1..dfd4be1 100644 --- a/binutils-2.25/gold/testsuite/dyn_weak_ref_2.c +++ b/binutils-2.25/gold/testsuite/dyn_weak_ref_2.c @@ -1,7 +1,7 @@ // dyn_weak_ref_1.c -- test that a weak ref remains weak in output when // there is a DSO with the same weak ref. -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dynamic_list.sh b/binutils-2.25/gold/testsuite/dynamic_list.sh index dfd9f0f..e2ef9fd 100755 --- a/binutils-2.25/gold/testsuite/dynamic_list.sh +++ b/binutils-2.25/gold/testsuite/dynamic_list.sh @@ -2,7 +2,7 @@ # dynamic_list.sh -- test --dynamic-list and --dynamic-list-* -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/dynamic_list_2.cc b/binutils-2.25/gold/testsuite/dynamic_list_2.cc new file mode 100644 index 0000000..5913312 --- /dev/null +++ b/binutils-2.25/gold/testsuite/dynamic_list_2.cc @@ -0,0 +1,40 @@ +// dynamic_list_test_2.cc -- Test --dynamic-list with shared libraries. + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// The goal of this program is to verify that the --dynamic-list option +// allows overrides for symbols listed in the file, and does symbolic +// binding for symbols not listed. + +#include <cstring> + +extern const char* test_foo(); +extern const char* test_bar(); + +int +main(void) +{ + if (strcmp(test_foo(), "override") != 0) + return 1; + if (strcmp(test_bar(), "original") != 0) + return 2; + return 0; +} diff --git a/binutils-2.25/gold/testsuite/dynamic_list_2.t b/binutils-2.25/gold/testsuite/dynamic_list_2.t new file mode 100644 index 0000000..eef848d --- /dev/null +++ b/binutils-2.25/gold/testsuite/dynamic_list_2.t @@ -0,0 +1,27 @@ +/* dynamic_list_2.t -- script file for building dynamic_list_lib2.so. + + Copyright (C) 2014 Free Software Foundation, Inc. + Written by Cary Coutant <ccoutant@google.com>. + + This file is part of gold. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +{ + extern "C" { + "foo"; + }; +}; diff --git a/binutils-2.25/gold/testsuite/dynamic_list_lib1.cc b/binutils-2.25/gold/testsuite/dynamic_list_lib1.cc new file mode 100644 index 0000000..afc36ca --- /dev/null +++ b/binutils-2.25/gold/testsuite/dynamic_list_lib1.cc @@ -0,0 +1,37 @@ +// dynamic_list_test_lib1.cc -- Test --dynamic-list with shared libraries. + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// The goal of this program is to verify that the --dynamic-list option +// allows overrides for symbols listed in the file, and does symbolic +// binding for symbols not listed. + +extern "C" const char* +foo() +{ + return "override"; +} + +extern "C" const char* +bar() +{ + return "override"; +} diff --git a/binutils-2.25/gold/testsuite/dynamic_list_lib2.cc b/binutils-2.25/gold/testsuite/dynamic_list_lib2.cc new file mode 100644 index 0000000..8ed5be5 --- /dev/null +++ b/binutils-2.25/gold/testsuite/dynamic_list_lib2.cc @@ -0,0 +1,49 @@ +// dynamic_list_test_lib2.cc -- Test --dynamic-list with shared libraries. + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// The goal of this program is to verify that the --dynamic-list option +// allows overrides for symbols listed in the file, and does symbolic +// binding for symbols not listed. + +extern "C" const char* +foo() +{ + return "original"; +} + +const char* +test_foo() +{ + return foo(); +} + +extern "C" const char* +bar() +{ + return "original"; +} + +const char* +test_bar() +{ + return bar(); +} diff --git a/binutils-2.25/gold/testsuite/ehdr_start_def.cc b/binutils-2.25/gold/testsuite/ehdr_start_def.cc new file mode 100644 index 0000000..f102a78 --- /dev/null +++ b/binutils-2.25/gold/testsuite/ehdr_start_def.cc @@ -0,0 +1,26 @@ +// ehdr_start_def.cc -- test for __ehdr_start linker-defined symbol. + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// We provide a user-defined __ehdr_start, to make sure that the +// linker does not override this with the linker-defined symbol. + +char __ehdr_start[] = { 'a', 'b', 'c', 'd' }; diff --git a/binutils-2.25/gold/testsuite/ehdr_start_test.cc b/binutils-2.25/gold/testsuite/ehdr_start_test.cc new file mode 100644 index 0000000..a119b5e --- /dev/null +++ b/binutils-2.25/gold/testsuite/ehdr_start_test.cc @@ -0,0 +1,67 @@ +// ehdr_start_test.cc -- test for __ehdr_start linker-defined symbol. + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// The goal of this program is to produce as many different types of +// relocations as we can in a stand-alone program that does not use +// TLS. This program is compiled without optimization. + +#include "config.h" + +#include <cassert> +#include <cstdio> + +#include "elfcpp.h" + +#ifdef EHDR_START_WEAK +#define WEAK_ATTR __attribute__ ((weak)) +#else +#define WEAK_ATTR +#endif + +extern char __ehdr_start[] WEAK_ATTR; + +int +main() { + printf("&__ehdr_start = %p\n", &__ehdr_start); + +#ifdef EHDR_START_UNDEF + assert(&__ehdr_start == 0); +#else + assert(&__ehdr_start != NULL); + + printf("ELF header: \\x%02x%c%c%c\n", __ehdr_start[0], __ehdr_start[1], + __ehdr_start[2], __ehdr_start[3]); +#ifdef EHDR_START_USER_DEF + assert(__ehdr_start[0] == 'a' + && __ehdr_start[1] == 'b' + && __ehdr_start[2] == 'c' + && __ehdr_start[3] == 'd'); +#else + assert(__ehdr_start[elfcpp::EI_MAG0] == elfcpp::ELFMAG0 + && __ehdr_start[elfcpp::EI_MAG1] == elfcpp::ELFMAG1 + && __ehdr_start[elfcpp::EI_MAG2] == elfcpp::ELFMAG2 + && __ehdr_start[elfcpp::EI_MAG3] == elfcpp::ELFMAG3); +#endif +#endif + + return 0; +} diff --git a/binutils-2.25/gold/testsuite/ehdr_start_test.t b/binutils-2.25/gold/testsuite/ehdr_start_test.t new file mode 100644 index 0000000..50daa64 --- /dev/null +++ b/binutils-2.25/gold/testsuite/ehdr_start_test.t @@ -0,0 +1,42 @@ +/* ehdr_start_test.t -- __ehdr_start test for gold + + Copyright (C) 2008-2014 Free Software Foundation, Inc. + Written by Ian Lance Taylor <iant@google.com>. + + This file is part of gold. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +/* With luck this will work on all platforms. */ + +SECTIONS +{ + /* Set the text segment to start on a non-page boundary. */ + . = 0x10000040; + + .text : { *(.text) } + . += 0x100000; + . = ALIGN(0x100); + + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) + *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + .got : { *(.got) } + .got.plt : { *(.got.plt) } + .data : { *(.data .data.* .gnu.linkonce.d.*) } +} diff --git a/binutils-2.25/gold/testsuite/ehdr_start_test_4.sh b/binutils-2.25/gold/testsuite/ehdr_start_test_4.sh new file mode 100755 index 0000000..5e3d20f --- /dev/null +++ b/binutils-2.25/gold/testsuite/ehdr_start_test_4.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# ehdr_start_test_4.sh -- test that __ehdr_start symbol is undefined. + +# Copyright (C) 2014 Free Software Foundation, Inc. +# Written by Cary Coutant <ccoutant@google.com>. + +# This file is part of gold. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Did not find expected symbol in $1:" + echo " $2" + echo "" + echo "Actual output below:" + cat "$1" + exit 1 + fi +} + +check ehdr_start_test_4.syms "U __ehdr_start" + +exit 0 diff --git a/binutils-2.25/gold/testsuite/exception_test.h b/binutils-2.25/gold/testsuite/exception_test.h index 0dcd8f2..f7825bf 100644 --- a/binutils-2.25/gold/testsuite/exception_test.h +++ b/binutils-2.25/gold/testsuite/exception_test.h @@ -1,6 +1,6 @@ // exception_test.h -- exception test case for gold, header file -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/exception_test_1.cc b/binutils-2.25/gold/testsuite/exception_test_1.cc index 56ae143..7972f01 100644 --- a/binutils-2.25/gold/testsuite/exception_test_1.cc +++ b/binutils-2.25/gold/testsuite/exception_test_1.cc @@ -1,6 +1,6 @@ // exception_test_1.cc -- test exception handling for gold, file 1 of 2 -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/exception_test_2.cc b/binutils-2.25/gold/testsuite/exception_test_2.cc index 1098bd1..1267cf6 100644 --- a/binutils-2.25/gold/testsuite/exception_test_2.cc +++ b/binutils-2.25/gold/testsuite/exception_test_2.cc @@ -1,6 +1,6 @@ // exception_test_1.cc -- test exception handling for gold, file 1 of 2 -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/exception_test_main.cc b/binutils-2.25/gold/testsuite/exception_test_main.cc index 09a018d..a4c644b 100644 --- a/binutils-2.25/gold/testsuite/exception_test_main.cc +++ b/binutils-2.25/gold/testsuite/exception_test_main.cc @@ -1,6 +1,6 @@ // exception_test_main.cc -- an exception test case for gold, main function -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/exclude_libs_test.sh b/binutils-2.25/gold/testsuite/exclude_libs_test.sh index 65ce03b..09f50b9 100755 --- a/binutils-2.25/gold/testsuite/exclude_libs_test.sh +++ b/binutils-2.25/gold/testsuite/exclude_libs_test.sh @@ -2,7 +2,7 @@ # exclude_libs_test.sh -- test that library symbols are not exported. -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/final_layout.cc b/binutils-2.25/gold/testsuite/final_layout.cc index f533885..71065c7 100644 --- a/binutils-2.25/gold/testsuite/final_layout.cc +++ b/binutils-2.25/gold/testsuite/final_layout.cc @@ -1,6 +1,6 @@ // final_layout.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/final_layout.sh b/binutils-2.25/gold/testsuite/final_layout.sh index d9d86ee..c93e265 100755 --- a/binutils-2.25/gold/testsuite/final_layout.sh +++ b/binutils-2.25/gold/testsuite/final_layout.sh @@ -2,7 +2,7 @@ # final_layout.sh -- test --final-layout -# Copyright 2010, 2011 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gc_comdat_test.sh b/binutils-2.25/gold/testsuite/gc_comdat_test.sh index baff98d..1a38f21 100755 --- a/binutils-2.25/gold/testsuite/gc_comdat_test.sh +++ b/binutils-2.25/gold/testsuite/gc_comdat_test.sh @@ -2,7 +2,7 @@ # gc_comdat_test.sh -- test --gc-sections -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gc_comdat_test_1.cc b/binutils-2.25/gold/testsuite/gc_comdat_test_1.cc index 0b4b286..8db55e9 100644 --- a/binutils-2.25/gold/testsuite/gc_comdat_test_1.cc +++ b/binutils-2.25/gold/testsuite/gc_comdat_test_1.cc @@ -1,6 +1,6 @@ // gc_comdat_test_1.cc -- a test case for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gc_comdat_test_2.cc b/binutils-2.25/gold/testsuite/gc_comdat_test_2.cc index 5841bdf..1d68be2 100644 --- a/binutils-2.25/gold/testsuite/gc_comdat_test_2.cc +++ b/binutils-2.25/gold/testsuite/gc_comdat_test_2.cc @@ -1,6 +1,6 @@ // gc_comdat_test_2.cc -- a test case for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gc_dynamic_list_test.c b/binutils-2.25/gold/testsuite/gc_dynamic_list_test.c new file mode 100644 index 0000000..fb9a92e --- /dev/null +++ b/binutils-2.25/gold/testsuite/gc_dynamic_list_test.c @@ -0,0 +1,34 @@ +// gc_dynamic_list_test.cc -- Check that --gc-sections honors --dynamic-list. + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// The goal of this program is to verify that the symbol "keep" is not +// garbage-collected when it is named in a --dynamic-list script. + +extern void keep(void); + +void +keep(void) +{} + +int +main(void) +{ return 0; } diff --git a/binutils-2.25/gold/testsuite/gc_dynamic_list_test.sh b/binutils-2.25/gold/testsuite/gc_dynamic_list_test.sh new file mode 100755 index 0000000..a586929 --- /dev/null +++ b/binutils-2.25/gold/testsuite/gc_dynamic_list_test.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# gc_comdat_test.sh -- test --gc-sections + +# Copyright (C) 2014 Free Software Foundation, Inc. +# Written by Cary Coutant <ccoutant@google.com>. + +# This file is part of gold. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +# The goal of this program is to verify if comdat's and garbage +# collection work together. Files gc_comdat_test_1.cc and +# gc_comdat_test_2.cc are used in this test. This program checks +# if the kept comdat section is garbage collected. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Garbage collection should not have collected '$2'" + exit 1 + fi +} + +check gc_dynamic_list_test.stdout "keep" diff --git a/binutils-2.25/gold/testsuite/gc_dynamic_list_test.t b/binutils-2.25/gold/testsuite/gc_dynamic_list_test.t new file mode 100644 index 0000000..c0b818e --- /dev/null +++ b/binutils-2.25/gold/testsuite/gc_dynamic_list_test.t @@ -0,0 +1,25 @@ +/* gc_dynamic_list_test.t -- script file for gc_dynamic_list_test.cc + + Copyright (C) 2014 Free Software Foundation, Inc. + Written by Cary Coutant <ccoutant@google.com>. + + This file is part of gold. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +{ + keep; +}; diff --git a/binutils-2.25/gold/testsuite/gc_orphan_section_test.cc b/binutils-2.25/gold/testsuite/gc_orphan_section_test.cc index 3443f8d..bcf06e4 100644 --- a/binutils-2.25/gold/testsuite/gc_orphan_section_test.cc +++ b/binutils-2.25/gold/testsuite/gc_orphan_section_test.cc @@ -1,6 +1,6 @@ // gc_orphan_section_test.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gc_orphan_section_test.sh b/binutils-2.25/gold/testsuite/gc_orphan_section_test.sh index 6ce524d..de2d2fe 100755 --- a/binutils-2.25/gold/testsuite/gc_orphan_section_test.sh +++ b/binutils-2.25/gold/testsuite/gc_orphan_section_test.sh @@ -2,7 +2,7 @@ # gc_orphan_section_test.sh -- test --gc-sections -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gc_tls_test.cc b/binutils-2.25/gold/testsuite/gc_tls_test.cc index 1b10d98..2d29d68 100644 --- a/binutils-2.25/gold/testsuite/gc_tls_test.cc +++ b/binutils-2.25/gold/testsuite/gc_tls_test.cc @@ -1,6 +1,6 @@ // gc_tls_test.cc -- a test case for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gc_tls_test.sh b/binutils-2.25/gold/testsuite/gc_tls_test.sh index c4635c9..7b6485e 100755 --- a/binutils-2.25/gold/testsuite/gc_tls_test.sh +++ b/binutils-2.25/gold/testsuite/gc_tls_test.sh @@ -2,7 +2,7 @@ # gc_tls_test.sh -- test -- gc + tls -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gdb_index_test.cc b/binutils-2.25/gold/testsuite/gdb_index_test.cc index d5ac2f1..6a562c3 100644 --- a/binutils-2.25/gold/testsuite/gdb_index_test.cc +++ b/binutils-2.25/gold/testsuite/gdb_index_test.cc @@ -1,6 +1,6 @@ // gdb_index_test.cc -- a test case for the --gdb-index option. -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gdb_index_test_1.sh b/binutils-2.25/gold/testsuite/gdb_index_test_1.sh index f04c8a7..5fae550 100755 --- a/binutils-2.25/gold/testsuite/gdb_index_test_1.sh +++ b/binutils-2.25/gold/testsuite/gdb_index_test_1.sh @@ -2,7 +2,7 @@ # gdb_index_test_1.sh -- a test case for the --gdb-index option. -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gdb_index_test_2.sh b/binutils-2.25/gold/testsuite/gdb_index_test_2.sh index e31aa42..a1d4d83 100755 --- a/binutils-2.25/gold/testsuite/gdb_index_test_2.sh +++ b/binutils-2.25/gold/testsuite/gdb_index_test_2.sh @@ -2,7 +2,7 @@ # gdb_index_test_2.sh -- a test case for the --gdb-index option. -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gdb_index_test_3.c b/binutils-2.25/gold/testsuite/gdb_index_test_3.c index df49261..683510c 100644 --- a/binutils-2.25/gold/testsuite/gdb_index_test_3.c +++ b/binutils-2.25/gold/testsuite/gdb_index_test_3.c @@ -1,6 +1,6 @@ // gdb_index_test.c -- a test case for the --gdb-index option. -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gdb_index_test_3.sh b/binutils-2.25/gold/testsuite/gdb_index_test_3.sh index bd1500b..7b4948d 100755 --- a/binutils-2.25/gold/testsuite/gdb_index_test_3.sh +++ b/binutils-2.25/gold/testsuite/gdb_index_test_3.sh @@ -2,7 +2,7 @@ # gdb_index_test_3.sh -- a test case for the --gdb-index option. -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. @@ -37,7 +37,7 @@ check() STDOUT=gdb_index_test_3.stdout -check $STDOUT "^Version [45]" +check $STDOUT "^Version [4-7]" # Look for the symbols we know should be in the symbol table. diff --git a/binutils-2.25/gold/testsuite/gdb_index_test_4.sh b/binutils-2.25/gold/testsuite/gdb_index_test_4.sh index 44c8a9a..3d5d66b 100755 --- a/binutils-2.25/gold/testsuite/gdb_index_test_4.sh +++ b/binutils-2.25/gold/testsuite/gdb_index_test_4.sh @@ -2,7 +2,7 @@ # gdb_index_test_4.sh -- a test case for the --gdb-index option. -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/gdb_index_test_comm.sh b/binutils-2.25/gold/testsuite/gdb_index_test_comm.sh index 4ab07b3..e888825 100755 --- a/binutils-2.25/gold/testsuite/gdb_index_test_comm.sh +++ b/binutils-2.25/gold/testsuite/gdb_index_test_comm.sh @@ -2,7 +2,7 @@ # gdb_index_test_comm.sh -- common code for --gdb-index tests. -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. @@ -37,7 +37,7 @@ check() STDOUT="$1" -check $STDOUT "^Version [45]" +check $STDOUT "^Version [4-7]" # Look for the symbols we know should be in the symbol table. diff --git a/binutils-2.25/gold/testsuite/hidden_test.sh b/binutils-2.25/gold/testsuite/hidden_test.sh index df51b37..39ebbf6 100755 --- a/binutils-2.25/gold/testsuite/hidden_test.sh +++ b/binutils-2.25/gold/testsuite/hidden_test.sh @@ -2,7 +2,7 @@ # hidden_test.sh -- a test case for hidden and internal symbols. -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/hidden_test_1.c b/binutils-2.25/gold/testsuite/hidden_test_1.c index f685cab..e9c96e6 100644 --- a/binutils-2.25/gold/testsuite/hidden_test_1.c +++ b/binutils-2.25/gold/testsuite/hidden_test_1.c @@ -1,6 +1,6 @@ /* hidden_test_1.c -- test hidden and internal symbols - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/hidden_test_main.c b/binutils-2.25/gold/testsuite/hidden_test_main.c index c54864d..60b8893 100644 --- a/binutils-2.25/gold/testsuite/hidden_test_main.c +++ b/binutils-2.25/gold/testsuite/hidden_test_main.c @@ -1,6 +1,6 @@ /* hidden_test_main.c -- test hidden and internal symbols - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_keep_unique_test.cc b/binutils-2.25/gold/testsuite/icf_keep_unique_test.cc index 37f6437..75a8385 100644 --- a/binutils-2.25/gold/testsuite/icf_keep_unique_test.cc +++ b/binutils-2.25/gold/testsuite/icf_keep_unique_test.cc @@ -1,6 +1,6 @@ // icf_keep_unique_test.cc -- a test case for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_keep_unique_test.sh b/binutils-2.25/gold/testsuite/icf_keep_unique_test.sh index c267373..d481d01 100755 --- a/binutils-2.25/gold/testsuite/icf_keep_unique_test.sh +++ b/binutils-2.25/gold/testsuite/icf_keep_unique_test.sh @@ -2,7 +2,7 @@ # icf_keep_unique_test.sh -- test --icf --keep-unique -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_preemptible_functions_test.cc b/binutils-2.25/gold/testsuite/icf_preemptible_functions_test.cc index 35a96bc..dc588a3 100644 --- a/binutils-2.25/gold/testsuite/icf_preemptible_functions_test.cc +++ b/binutils-2.25/gold/testsuite/icf_preemptible_functions_test.cc @@ -1,6 +1,6 @@ // icf_preemptible_functions_test.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_preemptible_functions_test.sh b/binutils-2.25/gold/testsuite/icf_preemptible_functions_test.sh index dd90d7f..c2a9f1c 100755 --- a/binutils-2.25/gold/testsuite/icf_preemptible_functions_test.sh +++ b/binutils-2.25/gold/testsuite/icf_preemptible_functions_test.sh @@ -2,7 +2,7 @@ # icf_preemptible_functions_test.sh -- test --icf=all -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_safe_so_test.cc b/binutils-2.25/gold/testsuite/icf_safe_so_test.cc index 0f50ad6..bca852f 100644 --- a/binutils-2.25/gold/testsuite/icf_safe_so_test.cc +++ b/binutils-2.25/gold/testsuite/icf_safe_so_test.cc @@ -1,6 +1,6 @@ // icf_safe_so_test.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_safe_so_test.sh b/binutils-2.25/gold/testsuite/icf_safe_so_test.sh index 813248e..804334d 100755 --- a/binutils-2.25/gold/testsuite/icf_safe_so_test.sh +++ b/binutils-2.25/gold/testsuite/icf_safe_so_test.sh @@ -2,7 +2,7 @@ # icf_safe_so_test.sh -- test --icf=safe -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_safe_test.cc b/binutils-2.25/gold/testsuite/icf_safe_test.cc index 87294dc..46bced1 100644 --- a/binutils-2.25/gold/testsuite/icf_safe_test.cc +++ b/binutils-2.25/gold/testsuite/icf_safe_test.cc @@ -1,6 +1,6 @@ // icf_safe_test.cc -- a test case for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_safe_test.sh b/binutils-2.25/gold/testsuite/icf_safe_test.sh index fe224f6..e18468c 100755 --- a/binutils-2.25/gold/testsuite/icf_safe_test.sh +++ b/binutils-2.25/gold/testsuite/icf_safe_test.sh @@ -2,7 +2,7 @@ # icf_safe_test.sh -- test --icf=safe -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test.sh b/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test.sh index 9077e25..64b69d3 100755 --- a/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test.sh +++ b/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test.sh @@ -2,7 +2,7 @@ # icf_sht_rel_addend_test.sh -- test --icf=all -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test_1.cc b/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test_1.cc index ecc2a1b..8f20a71 100644 --- a/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test_1.cc +++ b/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test_1.cc @@ -1,6 +1,6 @@ // icf_sht_rel_addend_test_1.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test_2.cc b/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test_2.cc index d85e3b4..dfc2bd4 100644 --- a/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test_2.cc +++ b/binutils-2.25/gold/testsuite/icf_sht_rel_addend_test_2.cc @@ -1,6 +1,6 @@ // icf_sht_rel_addend_test_2.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_string_merge_test.cc b/binutils-2.25/gold/testsuite/icf_string_merge_test.cc index b1e1191..869ee80 100644 --- a/binutils-2.25/gold/testsuite/icf_string_merge_test.cc +++ b/binutils-2.25/gold/testsuite/icf_string_merge_test.cc @@ -1,6 +1,6 @@ // icf_string_merge_test.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_string_merge_test.sh b/binutils-2.25/gold/testsuite/icf_string_merge_test.sh index e8d70de..a86728c 100755 --- a/binutils-2.25/gold/testsuite/icf_string_merge_test.sh +++ b/binutils-2.25/gold/testsuite/icf_string_merge_test.sh @@ -2,7 +2,7 @@ # icf_string_merge_test.sh -- test --icf=all -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_test.cc b/binutils-2.25/gold/testsuite/icf_test.cc index c7a5ea9..41168ec 100644 --- a/binutils-2.25/gold/testsuite/icf_test.cc +++ b/binutils-2.25/gold/testsuite/icf_test.cc @@ -1,6 +1,6 @@ // icf_test.cc -- a test case for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_test.sh b/binutils-2.25/gold/testsuite/icf_test.sh index 50abd90..07af1a9 100755 --- a/binutils-2.25/gold/testsuite/icf_test.sh +++ b/binutils-2.25/gold/testsuite/icf_test.sh @@ -2,7 +2,7 @@ # icf_test.sh -- test --icf -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/icf_virtual_function_folding_test.cc b/binutils-2.25/gold/testsuite/icf_virtual_function_folding_test.cc index ba063c8..ba144bf 100644 --- a/binutils-2.25/gold/testsuite/icf_virtual_function_folding_test.cc +++ b/binutils-2.25/gold/testsuite/icf_virtual_function_folding_test.cc @@ -1,6 +1,6 @@ // icf_virtual_function_folding_test.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/incr_comdat_test_1.cc b/binutils-2.25/gold/testsuite/incr_comdat_test_1.cc index 7a232c2..7a798bd 100644 --- a/binutils-2.25/gold/testsuite/incr_comdat_test_1.cc +++ b/binutils-2.25/gold/testsuite/incr_comdat_test_1.cc @@ -1,6 +1,6 @@ // incr_comdat_test_1.cc -- test incremental update with comdat sections -// Copyright 2011 Free Software Foundation, Inc. +// Copyright (C) 2011-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/incr_comdat_test_2_v1.cc b/binutils-2.25/gold/testsuite/incr_comdat_test_2_v1.cc index f7d6a8c..02307ac 100644 --- a/binutils-2.25/gold/testsuite/incr_comdat_test_2_v1.cc +++ b/binutils-2.25/gold/testsuite/incr_comdat_test_2_v1.cc @@ -1,6 +1,6 @@ // incr_comdat_test_2.cc -- test incremental update with comdat sections -// Copyright 2011 Free Software Foundation, Inc. +// Copyright (C) 2011-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/incr_comdat_test_2_v2.cc b/binutils-2.25/gold/testsuite/incr_comdat_test_2_v2.cc index fca7fda..936d7a1 100644 --- a/binutils-2.25/gold/testsuite/incr_comdat_test_2_v2.cc +++ b/binutils-2.25/gold/testsuite/incr_comdat_test_2_v2.cc @@ -1,6 +1,6 @@ // incr_comdat_test_2.cc -- test incremental update with comdat sections -// Copyright 2011 Free Software Foundation, Inc. +// Copyright (C) 2011-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/incr_comdat_test_2_v3.cc b/binutils-2.25/gold/testsuite/incr_comdat_test_2_v3.cc index cbb83c1..3c402e9 100644 --- a/binutils-2.25/gold/testsuite/incr_comdat_test_2_v3.cc +++ b/binutils-2.25/gold/testsuite/incr_comdat_test_2_v3.cc @@ -1,6 +1,6 @@ // incr_comdat_test_2.cc -- test incremental update with comdat sections -// Copyright 2011 Free Software Foundation, Inc. +// Copyright (C) 2011-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/incremental_test.sh b/binutils-2.25/gold/testsuite/incremental_test.sh index 930d7d1..d8c0c84 100755 --- a/binutils-2.25/gold/testsuite/incremental_test.sh +++ b/binutils-2.25/gold/testsuite/incremental_test.sh @@ -2,7 +2,7 @@ # incremental_test.sh -- test that incremental linking information is correct. -# Copyright 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Rafael Avila de Espindola <espindola@google.com> # and Cary Coutant <ccoutant@google.com> diff --git a/binutils-2.25/gold/testsuite/incremental_test_1.c b/binutils-2.25/gold/testsuite/incremental_test_1.c index 291caa0..850d116 100644 --- a/binutils-2.25/gold/testsuite/incremental_test_1.c +++ b/binutils-2.25/gold/testsuite/incremental_test_1.c @@ -1,4 +1,4 @@ -// Copyright 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Rafael Avila de Espindola <espindola@google.com> // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/incremental_test_2.c b/binutils-2.25/gold/testsuite/incremental_test_2.c index 7fcecc4..a86c0fb 100644 --- a/binutils-2.25/gold/testsuite/incremental_test_2.c +++ b/binutils-2.25/gold/testsuite/incremental_test_2.c @@ -1,4 +1,4 @@ -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Rafael Avila de Espindola <espindola@google.com> // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/initpri1.c b/binutils-2.25/gold/testsuite/initpri1.c index 1c5252d..2fbe6bd 100644 --- a/binutils-2.25/gold/testsuite/initpri1.c +++ b/binutils-2.25/gold/testsuite/initpri1.c @@ -1,6 +1,6 @@ /* initpri1.c -- test constructor priorities. - Copyright 2007, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2007-2014 Free Software Foundation, Inc. Copied from the gcc testsuite, where the test was contributed by Mark Mitchell <mark@codesourcery.com>. diff --git a/binutils-2.25/gold/testsuite/initpri2.c b/binutils-2.25/gold/testsuite/initpri2.c index 525661f..023d76a 100644 --- a/binutils-2.25/gold/testsuite/initpri2.c +++ b/binutils-2.25/gold/testsuite/initpri2.c @@ -1,6 +1,6 @@ /* initpri2.c -- test mixing init_array and ctor priorities. - Copyright 2011 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. Copied from the gcc configury, where the test was contributed by H.J. Lu <hongjiu.lu@intel.com>. diff --git a/binutils-2.25/gold/testsuite/initpri3.c b/binutils-2.25/gold/testsuite/initpri3.c index 01e233d..65963a9 100644 --- a/binutils-2.25/gold/testsuite/initpri3.c +++ b/binutils-2.25/gold/testsuite/initpri3.c @@ -1,6 +1,6 @@ /* initpri3.c -- test ctor odering when using init_array. - Copyright 2011 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/justsyms.t b/binutils-2.25/gold/testsuite/justsyms.t index 45418be..2af2d01 100644 --- a/binutils-2.25/gold/testsuite/justsyms.t +++ b/binutils-2.25/gold/testsuite/justsyms.t @@ -1,6 +1,6 @@ /* justsyms.t -- test --just-symbols for gold. - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/justsyms_1.cc b/binutils-2.25/gold/testsuite/justsyms_1.cc index 50716b0..362f939 100644 --- a/binutils-2.25/gold/testsuite/justsyms_1.cc +++ b/binutils-2.25/gold/testsuite/justsyms_1.cc @@ -1,6 +1,6 @@ // justsyms_1.cc -- test --just-symbols for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/justsyms_2.cc b/binutils-2.25/gold/testsuite/justsyms_2.cc index dbbf4b5..c0d9c94 100644 --- a/binutils-2.25/gold/testsuite/justsyms_2.cc +++ b/binutils-2.25/gold/testsuite/justsyms_2.cc @@ -1,6 +1,6 @@ // justsyms_2.cc -- test --just-symbols for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/justsyms_exec.c b/binutils-2.25/gold/testsuite/justsyms_exec.c index 6670286..3bb6d2f 100644 --- a/binutils-2.25/gold/testsuite/justsyms_exec.c +++ b/binutils-2.25/gold/testsuite/justsyms_exec.c @@ -1,6 +1,6 @@ // justsyms_exec.c -- test --just-symbols for gold -// Copyright 2011 Free Software Foundation, Inc. +// Copyright (C) 2011-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/justsyms_lib.c b/binutils-2.25/gold/testsuite/justsyms_lib.c index 9666fb7..9e043d9 100644 --- a/binutils-2.25/gold/testsuite/justsyms_lib.c +++ b/binutils-2.25/gold/testsuite/justsyms_lib.c @@ -1,6 +1,6 @@ // justsyms_lib.cc -- test --just-symbols for gold -// Copyright 2011 Free Software Foundation, Inc. +// Copyright (C) 2011-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/large.c b/binutils-2.25/gold/testsuite/large.c index 796242a..0702d11 100644 --- a/binutils-2.25/gold/testsuite/large.c +++ b/binutils-2.25/gold/testsuite/large.c @@ -1,6 +1,6 @@ /* large.c -- a test case for gold - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/large_symbol_alignment.cc b/binutils-2.25/gold/testsuite/large_symbol_alignment.cc index 1b4a63d..296d7aa 100644 --- a/binutils-2.25/gold/testsuite/large_symbol_alignment.cc +++ b/binutils-2.25/gold/testsuite/large_symbol_alignment.cc @@ -1,6 +1,6 @@ // large_symbol_alignment.cc -- a test case for gold -// Copyright 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 Free Software Foundation, Inc. // Written by Alexander Ivchenko <alexander.ivchenko@intel.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/leb128_unittest.cc b/binutils-2.25/gold/testsuite/leb128_unittest.cc index 05c7093..5b438b3 100644 --- a/binutils-2.25/gold/testsuite/leb128_unittest.cc +++ b/binutils-2.25/gold/testsuite/leb128_unittest.cc @@ -1,6 +1,6 @@ // leb_unittest.cc -- test read_signed_LEB_128 and read_unsigned_LEB_128 -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/many_sections_test.cc b/binutils-2.25/gold/testsuite/many_sections_test.cc index e4b74c3..44530e2 100644 --- a/binutils-2.25/gold/testsuite/many_sections_test.cc +++ b/binutils-2.25/gold/testsuite/many_sections_test.cc @@ -1,6 +1,6 @@ // many_sections_test.cc -- test lots of sections for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/memory_test.sh b/binutils-2.25/gold/testsuite/memory_test.sh index db3917a..4e85801 100755 --- a/binutils-2.25/gold/testsuite/memory_test.sh +++ b/binutils-2.25/gold/testsuite/memory_test.sh @@ -2,7 +2,7 @@ # memory_test.sh -- test MEMORY regions. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Nick Clifton <nickc@redhat.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/merge_string_literals.sh b/binutils-2.25/gold/testsuite/merge_string_literals.sh index 486a895..f17ab13 100755 --- a/binutils-2.25/gold/testsuite/merge_string_literals.sh +++ b/binutils-2.25/gold/testsuite/merge_string_literals.sh @@ -2,7 +2,7 @@ # merge_string_literals.sh -- test -# Copyright 2013 Free Software Foundation, Inc. +# Copyright (C) 2013-2014 Free Software Foundation, Inc. # Written by Alexander Ivchenko <alexander.ivchenko@intel.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/merge_string_literals_1.cc b/binutils-2.25/gold/testsuite/merge_string_literals_1.cc index fc0487c..b313dfc 100644 --- a/binutils-2.25/gold/testsuite/merge_string_literals_1.cc +++ b/binutils-2.25/gold/testsuite/merge_string_literals_1.cc @@ -1,6 +1,6 @@ // merge_string_literals_1.c -- a test case for gold -// Copyright 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 Free Software Foundation, Inc. // Written by Alexander Ivchenko <alexander.ivchenko@intel.com> // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/merge_string_literals_2.cc b/binutils-2.25/gold/testsuite/merge_string_literals_2.cc index d1185cd..73265f5 100644 --- a/binutils-2.25/gold/testsuite/merge_string_literals_2.cc +++ b/binutils-2.25/gold/testsuite/merge_string_literals_2.cc @@ -1,6 +1,6 @@ // merge_string_literals_2.c -- a test case for gold -// Copyright 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 Free Software Foundation, Inc. // Written by Alexander Ivchenko <alexander.ivchenko@intel.com> // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/missing_key_func.cc b/binutils-2.25/gold/testsuite/missing_key_func.cc index 5a5b7d9..e89e95a 100644 --- a/binutils-2.25/gold/testsuite/missing_key_func.cc +++ b/binutils-2.25/gold/testsuite/missing_key_func.cc @@ -1,6 +1,6 @@ // basic_test.cc -- a test case for gold -// Copyright 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/missing_key_func.sh b/binutils-2.25/gold/testsuite/missing_key_func.sh index 54c7b57..0027c7f 100755 --- a/binutils-2.25/gold/testsuite/missing_key_func.sh +++ b/binutils-2.25/gold/testsuite/missing_key_func.sh @@ -3,7 +3,7 @@ # missing_key_func.sh -- a test case for printing error messages when # a class is missing its key function. -# Copyright 2013 Free Software Foundation, Inc. +# Copyright (C) 2013-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/no_version_test.c b/binutils-2.25/gold/testsuite/no_version_test.c index e42d04f..1171fad 100644 --- a/binutils-2.25/gold/testsuite/no_version_test.c +++ b/binutils-2.25/gold/testsuite/no_version_test.c @@ -1,6 +1,6 @@ // ver_no_default.c -- a test case for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/no_version_test.sh b/binutils-2.25/gold/testsuite/no_version_test.sh index f4ca9b1..cbcf24f 100755 --- a/binutils-2.25/gold/testsuite/no_version_test.sh +++ b/binutils-2.25/gold/testsuite/no_version_test.sh @@ -3,7 +3,7 @@ # no_version_test.sh -- test that .gnu.version* sections are not created # in a shared object when symbol versioning is not used. -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/object_unittest.cc b/binutils-2.25/gold/testsuite/object_unittest.cc index 7dedeae..adbd275 100644 --- a/binutils-2.25/gold/testsuite/object_unittest.cc +++ b/binutils-2.25/gold/testsuite/object_unittest.cc @@ -1,6 +1,6 @@ // object_unittest.cc -- test Object, Relobj, etc. -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/pie_copyrelocs_shared_test.cc b/binutils-2.25/gold/testsuite/pie_copyrelocs_shared_test.cc new file mode 100644 index 0000000..8513417 --- /dev/null +++ b/binutils-2.25/gold/testsuite/pie_copyrelocs_shared_test.cc @@ -0,0 +1,26 @@ +// pie_copyrelocs_shared_test.cc -- a test case for gold, used +// by pie_copyrelocs_test + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Sriraman Tallam <tmsriram@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + + + +int glob_a = 128; diff --git a/binutils-2.25/gold/testsuite/pie_copyrelocs_test.cc b/binutils-2.25/gold/testsuite/pie_copyrelocs_test.cc new file mode 100644 index 0000000..bebe89d --- /dev/null +++ b/binutils-2.25/gold/testsuite/pie_copyrelocs_test.cc @@ -0,0 +1,31 @@ +// pie_coprelocs_test.cc -- a test case for gold + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Sriraman Tallam <tmsriram@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// Check if copy relocs are used to access globals below when -fpie is +// is not used to compile but -pie is used to link. + +extern int glob_a; + +int main () +{ + return glob_a - 128; +} diff --git a/binutils-2.25/gold/testsuite/plugin_common_test_1.c b/binutils-2.25/gold/testsuite/plugin_common_test_1.c index 262c298..6f764fd 100644 --- a/binutils-2.25/gold/testsuite/plugin_common_test_1.c +++ b/binutils-2.25/gold/testsuite/plugin_common_test_1.c @@ -1,6 +1,6 @@ /* plugin_common_test_1.c -- test common symbol handling in plugins - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_common_test_2.c b/binutils-2.25/gold/testsuite/plugin_common_test_2.c index 54139ce..df9f7f1 100644 --- a/binutils-2.25/gold/testsuite/plugin_common_test_2.c +++ b/binutils-2.25/gold/testsuite/plugin_common_test_2.c @@ -1,6 +1,6 @@ /* plugin_common_test_2.c -- test common symbol handling in plugins - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com> This file is part of gold. @@ -26,7 +26,7 @@ #include <assert.h> -int c1; +int c1 __attribute__((aligned (8))); extern int c2; int c3; int c4 = 40; diff --git a/binutils-2.25/gold/testsuite/plugin_final_layout.cc b/binutils-2.25/gold/testsuite/plugin_final_layout.cc index 169eeef..a40c5d6 100644 --- a/binutils-2.25/gold/testsuite/plugin_final_layout.cc +++ b/binutils-2.25/gold/testsuite/plugin_final_layout.cc @@ -1,6 +1,6 @@ // plugin_final_layout.cc -- a test case for gold -// Copyright 2011 Free Software Foundation, Inc. +// Copyright (C) 2011-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_final_layout.sh b/binutils-2.25/gold/testsuite/plugin_final_layout.sh index 75a40d3..dc456fa 100755 --- a/binutils-2.25/gold/testsuite/plugin_final_layout.sh +++ b/binutils-2.25/gold/testsuite/plugin_final_layout.sh @@ -2,7 +2,7 @@ # plugin_final_layout.sh -- test -# Copyright 2011 Free Software Foundation, Inc. +# Copyright (C) 2011-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_section_order.c b/binutils-2.25/gold/testsuite/plugin_section_order.c index fdc6fe4..48d30df 100644 --- a/binutils-2.25/gold/testsuite/plugin_section_order.c +++ b/binutils-2.25/gold/testsuite/plugin_section_order.c @@ -1,6 +1,6 @@ /* plugin_section_reorder.c -- Simple plugin to reorder function sections - Copyright 2011 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. Written by Sriraman Tallam <tmsriram@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test.c b/binutils-2.25/gold/testsuite/plugin_test.c index 47d400a..79ae44e 100644 --- a/binutils-2.25/gold/testsuite/plugin_test.c +++ b/binutils-2.25/gold/testsuite/plugin_test.c @@ -1,6 +1,6 @@ /* test_plugin.c -- simple linker plugin test - Copyright 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com>. This file is part of gold. @@ -584,6 +584,13 @@ parse_readelf_line(char* p, struct sym_info* info) p += strcspn(p, " "); p += strspn(p, " "); + if (*p == '[') + { + /* Skip st_other. */ + p += strcspn(p, "]"); + p += strspn(p, "] "); + } + /* Section field. */ info->sect = p; p += strcspn(p, " "); diff --git a/binutils-2.25/gold/testsuite/plugin_test_1.sh b/binutils-2.25/gold/testsuite/plugin_test_1.sh index 4d3ed41..0f9c9b1 100755 --- a/binutils-2.25/gold/testsuite/plugin_test_1.sh +++ b/binutils-2.25/gold/testsuite/plugin_test_1.sh @@ -2,7 +2,7 @@ # plugin_test_1.sh -- a test case for the plugin API. -# Copyright 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test_10.sh b/binutils-2.25/gold/testsuite/plugin_test_10.sh new file mode 100755 index 0000000..80b9f15 --- /dev/null +++ b/binutils-2.25/gold/testsuite/plugin_test_10.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +# plugin_test_10.sh -- a test case for the plugin API. + +# Copyright (C) 2010-2014 Free Software Foundation, Inc. +# Written by Rafael Ávila de Espíndola <rafael.espindola@gmail.com> + +# This file is part of gold. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +# This file goes with plugin_common_test_1.c and plugin_common_test_2.c. +# The first file is claimed by the plugin, the second one is not. We test +# the bigger alignment in plugin_common_test_2.c is used. + +set -e + +grep -q ".bss.* 8$" plugin_test_10.sections + +exit 0 diff --git a/binutils-2.25/gold/testsuite/plugin_test_2.sh b/binutils-2.25/gold/testsuite/plugin_test_2.sh index 293b1f0..e06a85f 100755 --- a/binutils-2.25/gold/testsuite/plugin_test_2.sh +++ b/binutils-2.25/gold/testsuite/plugin_test_2.sh @@ -2,7 +2,7 @@ # plugin_test_2.sh -- a test case for the plugin API. -# Copyright 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test_3.sh b/binutils-2.25/gold/testsuite/plugin_test_3.sh index 39356d1..61a7d95 100755 --- a/binutils-2.25/gold/testsuite/plugin_test_3.sh +++ b/binutils-2.25/gold/testsuite/plugin_test_3.sh @@ -2,7 +2,7 @@ # plugin_test_3.sh -- a test case for the plugin API. -# Copyright 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test_4.sh b/binutils-2.25/gold/testsuite/plugin_test_4.sh index 89df46c..9500e41 100755 --- a/binutils-2.25/gold/testsuite/plugin_test_4.sh +++ b/binutils-2.25/gold/testsuite/plugin_test_4.sh @@ -2,7 +2,7 @@ # plugin_test_4.sh -- a test case for the plugin API. -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test_6.sh b/binutils-2.25/gold/testsuite/plugin_test_6.sh index 9b368e7..1edb461 100755 --- a/binutils-2.25/gold/testsuite/plugin_test_6.sh +++ b/binutils-2.25/gold/testsuite/plugin_test_6.sh @@ -2,7 +2,7 @@ # plugin_test_6.sh -- a test case for the plugin API. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test_7.sh b/binutils-2.25/gold/testsuite/plugin_test_7.sh index 27723f9..04a554a 100755 --- a/binutils-2.25/gold/testsuite/plugin_test_7.sh +++ b/binutils-2.25/gold/testsuite/plugin_test_7.sh @@ -2,7 +2,7 @@ # plugin_test_7.sh -- a test case for the plugin API with GC. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Rafael Avila de Espindola <espindola@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test_7_1.c b/binutils-2.25/gold/testsuite/plugin_test_7_1.c index 5f4c4f3..fdb0074 100644 --- a/binutils-2.25/gold/testsuite/plugin_test_7_1.c +++ b/binutils-2.25/gold/testsuite/plugin_test_7_1.c @@ -1,6 +1,6 @@ /* plugin_test_7_1.c -- a test case for the plugin API with GC. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Rafael Avila de Espindola <espindola@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test_7_2.c b/binutils-2.25/gold/testsuite/plugin_test_7_2.c index 06b7676..e2ca426 100644 --- a/binutils-2.25/gold/testsuite/plugin_test_7_2.c +++ b/binutils-2.25/gold/testsuite/plugin_test_7_2.c @@ -1,6 +1,6 @@ /* plugin_test_7_1.c -- a test case for the plugin API with GC. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Rafael Avila de Espindola <espindola@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/plugin_test_tls.sh b/binutils-2.25/gold/testsuite/plugin_test_tls.sh index 22b5458..fe30cf4 100755 --- a/binutils-2.25/gold/testsuite/plugin_test_tls.sh +++ b/binutils-2.25/gold/testsuite/plugin_test_tls.sh @@ -2,7 +2,7 @@ # plugin_test_tls.sh -- a test case for the plugin API. -# Copyright 2013 Free Software Foundation, Inc. +# Copyright (C) 2013-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/pr12826.sh b/binutils-2.25/gold/testsuite/pr12826.sh index a4fa2e3..bd3e3a9 100755 --- a/binutils-2.25/gold/testsuite/pr12826.sh +++ b/binutils-2.25/gold/testsuite/pr12826.sh @@ -2,7 +2,7 @@ # pr12826.sh -- a test case for combining ARM arch attributes. -# Copyright 2011 Free Software Foundation, Inc. +# Copyright (C) 2011-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/pr14265.sh b/binutils-2.25/gold/testsuite/pr14265.sh index 4e477b2..c82875f 100755 --- a/binutils-2.25/gold/testsuite/pr14265.sh +++ b/binutils-2.25/gold/testsuite/pr14265.sh @@ -2,7 +2,7 @@ # pr14265.sh -- test --gc-sections with KEEP -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Nick Clifton <nickc@redhat.com> # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/protected_1.cc b/binutils-2.25/gold/testsuite/protected_1.cc index 049bda7..e9725a9 100644 --- a/binutils-2.25/gold/testsuite/protected_1.cc +++ b/binutils-2.25/gold/testsuite/protected_1.cc @@ -1,6 +1,6 @@ // protected_1.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/protected_2.cc b/binutils-2.25/gold/testsuite/protected_2.cc index 19d8276..44bd9af 100644 --- a/binutils-2.25/gold/testsuite/protected_2.cc +++ b/binutils-2.25/gold/testsuite/protected_2.cc @@ -1,6 +1,6 @@ // protected_2.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/protected_3.cc b/binutils-2.25/gold/testsuite/protected_3.cc index 8a27a2a..b22181c 100644 --- a/binutils-2.25/gold/testsuite/protected_3.cc +++ b/binutils-2.25/gold/testsuite/protected_3.cc @@ -1,6 +1,6 @@ // protected_2.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/protected_4.cc b/binutils-2.25/gold/testsuite/protected_4.cc index 58e3e2b..918d7c1 100644 --- a/binutils-2.25/gold/testsuite/protected_4.cc +++ b/binutils-2.25/gold/testsuite/protected_4.cc @@ -1,6 +1,6 @@ // protected_4.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/protected_main_1.cc b/binutils-2.25/gold/testsuite/protected_main_1.cc index 271446f..b1c3b87 100644 --- a/binutils-2.25/gold/testsuite/protected_main_1.cc +++ b/binutils-2.25/gold/testsuite/protected_main_1.cc @@ -1,6 +1,6 @@ // protected_main_1.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/protected_main_2.cc b/binutils-2.25/gold/testsuite/protected_main_2.cc index 6960322..29bfcfa 100644 --- a/binutils-2.25/gold/testsuite/protected_main_2.cc +++ b/binutils-2.25/gold/testsuite/protected_main_2.cc @@ -1,6 +1,6 @@ // protected_main_2.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/protected_main_3.cc b/binutils-2.25/gold/testsuite/protected_main_3.cc index f356f3d..02f4c94 100644 --- a/binutils-2.25/gold/testsuite/protected_main_3.cc +++ b/binutils-2.25/gold/testsuite/protected_main_3.cc @@ -1,6 +1,6 @@ // protected_main_3.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/relro_script_test.t b/binutils-2.25/gold/testsuite/relro_script_test.t index 3a6e3e9..e4af879 100644 --- a/binutils-2.25/gold/testsuite/relro_script_test.t +++ b/binutils-2.25/gold/testsuite/relro_script_test.t @@ -1,6 +1,6 @@ /* relro_test.t -- relro script test for gold - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/relro_test.cc b/binutils-2.25/gold/testsuite/relro_test.cc index 795ad39..b64e5cf 100644 --- a/binutils-2.25/gold/testsuite/relro_test.cc +++ b/binutils-2.25/gold/testsuite/relro_test.cc @@ -1,6 +1,6 @@ // relro_test.cc -- test -z relro for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/relro_test.sh b/binutils-2.25/gold/testsuite/relro_test.sh index 47a9491..69f0ff7 100755 --- a/binutils-2.25/gold/testsuite/relro_test.sh +++ b/binutils-2.25/gold/testsuite/relro_test.sh @@ -2,7 +2,7 @@ # relro_test.sh -- test -z relro -# Copyright 2010, 2011 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/relro_test_main.cc b/binutils-2.25/gold/testsuite/relro_test_main.cc index 6f5ea2b..8a14274 100644 --- a/binutils-2.25/gold/testsuite/relro_test_main.cc +++ b/binutils-2.25/gold/testsuite/relro_test_main.cc @@ -1,6 +1,6 @@ // relro_test_main.cc -- test -z relro for gold, main function -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/retain_symbols_file_test.sh b/binutils-2.25/gold/testsuite/retain_symbols_file_test.sh index e0d3ffc..21373d1 100755 --- a/binutils-2.25/gold/testsuite/retain_symbols_file_test.sh +++ b/binutils-2.25/gold/testsuite/retain_symbols_file_test.sh @@ -2,7 +2,7 @@ # retain_symbols_file_test.sh -- a test case for -retain-symbols-file -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Craig Silverstein <csilvers@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_1.cc b/binutils-2.25/gold/testsuite/script_test_1.cc index 1bdf770..ecdf67e 100644 --- a/binutils-2.25/gold/testsuite/script_test_1.cc +++ b/binutils-2.25/gold/testsuite/script_test_1.cc @@ -1,6 +1,6 @@ // script_test_1.cc -- linker script test 1 for gold -*- C++ -*- -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_1.t b/binutils-2.25/gold/testsuite/script_test_1.t index af971c6..22a1e39 100644 --- a/binutils-2.25/gold/testsuite/script_test_1.t +++ b/binutils-2.25/gold/testsuite/script_test_1.t @@ -1,6 +1,6 @@ /* script_test_1.t -- linker script test 1 for gold - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_10.sh b/binutils-2.25/gold/testsuite/script_test_10.sh index 58446ab..41b2bc7 100755 --- a/binutils-2.25/gold/testsuite/script_test_10.sh +++ b/binutils-2.25/gold/testsuite/script_test_10.sh @@ -2,7 +2,7 @@ # script_test_10.sh -- test for the section order. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Viktor Kutuzov <vkutuzov@accesssoftek.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_10.t b/binutils-2.25/gold/testsuite/script_test_10.t index 98f2107..14b0578 100644 --- a/binutils-2.25/gold/testsuite/script_test_10.t +++ b/binutils-2.25/gold/testsuite/script_test_10.t @@ -1,6 +1,6 @@ /* script_test_10.t -- test section order for gold. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Viktor Kutuzov <vkutuzov@accesssoftek.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_2.cc b/binutils-2.25/gold/testsuite/script_test_2.cc index 7104551..59c007c 100644 --- a/binutils-2.25/gold/testsuite/script_test_2.cc +++ b/binutils-2.25/gold/testsuite/script_test_2.cc @@ -1,6 +1,6 @@ // script_test_2.cc -- linker script test 2 for gold -*- C++ -*- -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_2.t b/binutils-2.25/gold/testsuite/script_test_2.t index 81ed9aa..eabf4ec 100644 --- a/binutils-2.25/gold/testsuite/script_test_2.t +++ b/binutils-2.25/gold/testsuite/script_test_2.t @@ -1,6 +1,6 @@ /* script_test_2.t -- linker script test 2 for gold - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_2a.cc b/binutils-2.25/gold/testsuite/script_test_2a.cc index 6c665eb..7c1990d 100644 --- a/binutils-2.25/gold/testsuite/script_test_2a.cc +++ b/binutils-2.25/gold/testsuite/script_test_2a.cc @@ -1,6 +1,6 @@ // script_test_2a.cc -- linker script test 2, file 1 -*- C++ -*- -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_2b.cc b/binutils-2.25/gold/testsuite/script_test_2b.cc index 9b19eb0..c99d10d 100644 --- a/binutils-2.25/gold/testsuite/script_test_2b.cc +++ b/binutils-2.25/gold/testsuite/script_test_2b.cc @@ -1,6 +1,6 @@ // script_test_2a.cc -- linker script test 2, file 2 -*- C++ -*- -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_3.sh b/binutils-2.25/gold/testsuite/script_test_3.sh index d114edd..a24505e 100755 --- a/binutils-2.25/gold/testsuite/script_test_3.sh +++ b/binutils-2.25/gold/testsuite/script_test_3.sh @@ -2,7 +2,7 @@ # script_test_3.sh -- test PHDRS -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_3.t b/binutils-2.25/gold/testsuite/script_test_3.t index accd055..22a0c6f 100644 --- a/binutils-2.25/gold/testsuite/script_test_3.t +++ b/binutils-2.25/gold/testsuite/script_test_3.t @@ -1,6 +1,6 @@ /* script_test_3.t -- linker script test 3 for gold - Copyright 2008, 2010 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_4.sh b/binutils-2.25/gold/testsuite/script_test_4.sh index 755d1a0..6a0a26b 100755 --- a/binutils-2.25/gold/testsuite/script_test_4.sh +++ b/binutils-2.25/gold/testsuite/script_test_4.sh @@ -2,7 +2,7 @@ # script_test_4.sh -- test load segment -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_4.t b/binutils-2.25/gold/testsuite/script_test_4.t index 3ba5e93..c441ad5 100644 --- a/binutils-2.25/gold/testsuite/script_test_4.t +++ b/binutils-2.25/gold/testsuite/script_test_4.t @@ -1,6 +1,6 @@ /* script_test_4.t -- linker script test 4 for gold - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_5.cc b/binutils-2.25/gold/testsuite/script_test_5.cc index b5aec29..d90477c 100644 --- a/binutils-2.25/gold/testsuite/script_test_5.cc +++ b/binutils-2.25/gold/testsuite/script_test_5.cc @@ -1,6 +1,6 @@ // script_test_5.cc -- a test case for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_5.sh b/binutils-2.25/gold/testsuite/script_test_5.sh index 76e2e31..9ff9486 100755 --- a/binutils-2.25/gold/testsuite/script_test_5.sh +++ b/binutils-2.25/gold/testsuite/script_test_5.sh @@ -2,7 +2,7 @@ # script_test_5.sh -- test linker script with uncovered sections -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Cary Coutant <ccoutant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_5.t b/binutils-2.25/gold/testsuite/script_test_5.t index 4a7d13f..65ada93 100644 --- a/binutils-2.25/gold/testsuite/script_test_5.t +++ b/binutils-2.25/gold/testsuite/script_test_5.t @@ -1,6 +1,6 @@ /* script_test_5.t -- linker script test 5 for gold - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_6.sh b/binutils-2.25/gold/testsuite/script_test_6.sh index bbc96d8..fc8d504 100755 --- a/binutils-2.25/gold/testsuite/script_test_6.sh +++ b/binutils-2.25/gold/testsuite/script_test_6.sh @@ -2,7 +2,7 @@ # script_test_6.sh -- test for -Ttext, -Tdata and -Tbss with a script. -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_6.t b/binutils-2.25/gold/testsuite/script_test_6.t index d3127e3..e123a1e 100644 --- a/binutils-2.25/gold/testsuite/script_test_6.t +++ b/binutils-2.25/gold/testsuite/script_test_6.t @@ -1,6 +1,6 @@ /* script_test_5.t -- linker script test 5 for gold - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_7.sh b/binutils-2.25/gold/testsuite/script_test_7.sh index 982a1c1..efcbb4c 100755 --- a/binutils-2.25/gold/testsuite/script_test_7.sh +++ b/binutils-2.25/gold/testsuite/script_test_7.sh @@ -2,7 +2,7 @@ # script_test_7.sh -- test for SEGMENT_START expressions. -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_7.t b/binutils-2.25/gold/testsuite/script_test_7.t index ab2bbee..575225d 100644 --- a/binutils-2.25/gold/testsuite/script_test_7.t +++ b/binutils-2.25/gold/testsuite/script_test_7.t @@ -1,6 +1,6 @@ /* script_test_5.t -- linker script test 5 for gold - Copyright 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_8.sh b/binutils-2.25/gold/testsuite/script_test_8.sh index 83e8e72..02531d2 100755 --- a/binutils-2.25/gold/testsuite/script_test_8.sh +++ b/binutils-2.25/gold/testsuite/script_test_8.sh @@ -3,7 +3,7 @@ # script_test_8.sh -- test for SEGMENT_START expressions with # -Ttext, -Tdata and -Tbss in a script. -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_9.cc b/binutils-2.25/gold/testsuite/script_test_9.cc index 84f12f6..19d7153 100644 --- a/binutils-2.25/gold/testsuite/script_test_9.cc +++ b/binutils-2.25/gold/testsuite/script_test_9.cc @@ -1,6 +1,6 @@ // script_test_9.cc -- a test case for gold -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Rafael Avila de Espindola <espindola@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/script_test_9.sh b/binutils-2.25/gold/testsuite/script_test_9.sh index 9f9aba6..29a8efe 100755 --- a/binutils-2.25/gold/testsuite/script_test_9.sh +++ b/binutils-2.25/gold/testsuite/script_test_9.sh @@ -3,7 +3,7 @@ # script_test_9.sh -- Check that the script_test_9.t script has placed # .init and .text in the same segment. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Rafael Avila de Espindola <espindola@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/searched_file_test.cc b/binutils-2.25/gold/testsuite/searched_file_test.cc index aa99e24..31277f1 100644 --- a/binutils-2.25/gold/testsuite/searched_file_test.cc +++ b/binutils-2.25/gold/testsuite/searched_file_test.cc @@ -1,6 +1,6 @@ // searched_file_test.cc -- test -l:foo.a for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Chris Demetriou <cgd@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/searched_file_test_lib.cc b/binutils-2.25/gold/testsuite/searched_file_test_lib.cc index 0686e52..340afc4 100644 --- a/binutils-2.25/gold/testsuite/searched_file_test_lib.cc +++ b/binutils-2.25/gold/testsuite/searched_file_test_lib.cc @@ -1,6 +1,6 @@ // searched_file_test_lib.cc -- test -l:foo.a for gold -// Copyright 2009 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Chris Demetriou <cgd@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/section_sorting_name.cc b/binutils-2.25/gold/testsuite/section_sorting_name.cc index e89c1ed..cb7260c 100644 --- a/binutils-2.25/gold/testsuite/section_sorting_name.cc +++ b/binutils-2.25/gold/testsuite/section_sorting_name.cc @@ -1,6 +1,6 @@ // section_sorting_name.cc -- a test case for gold -// Copyright 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 Free Software Foundation, Inc. // Written by Alexander Ivchenko <alexander.ivchenko@intel.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/section_sorting_name.sh b/binutils-2.25/gold/testsuite/section_sorting_name.sh index 00b6994..b413299 100755 --- a/binutils-2.25/gold/testsuite/section_sorting_name.sh +++ b/binutils-2.25/gold/testsuite/section_sorting_name.sh @@ -2,7 +2,7 @@ # section_sorting_name.sh -- test -# Copyright 2013 Free Software Foundation, Inc. +# Copyright (C) 2013-2014 Free Software Foundation, Inc. # Written by Alexander Ivchenko <alexander.ivchenko@intel.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/split_i386.sh b/binutils-2.25/gold/testsuite/split_i386.sh index e94fea2..f48ea5d 100755 --- a/binutils-2.25/gold/testsuite/split_i386.sh +++ b/binutils-2.25/gold/testsuite/split_i386.sh @@ -2,7 +2,7 @@ # split_i386.sh -- test -fstack-split for i386 -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/split_x86_64.sh b/binutils-2.25/gold/testsuite/split_x86_64.sh index 61544b2..530c4b1 100755 --- a/binutils-2.25/gold/testsuite/split_x86_64.sh +++ b/binutils-2.25/gold/testsuite/split_x86_64.sh @@ -2,7 +2,7 @@ # split_x86_64.sh -- test -fstack-split for x86_64 -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/start_lib_test_1.c b/binutils-2.25/gold/testsuite/start_lib_test_1.c index 024276a..3cd8a51 100644 --- a/binutils-2.25/gold/testsuite/start_lib_test_1.c +++ b/binutils-2.25/gold/testsuite/start_lib_test_1.c @@ -1,6 +1,6 @@ /* start_lib_test_1.c -- test --start-lib/--end-lib. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/start_lib_test_2.c b/binutils-2.25/gold/testsuite/start_lib_test_2.c index 443a79c..b6a99a1 100644 --- a/binutils-2.25/gold/testsuite/start_lib_test_2.c +++ b/binutils-2.25/gold/testsuite/start_lib_test_2.c @@ -1,6 +1,6 @@ /* start_lib_test_2.c -- test --start-lib/--end-lib. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/start_lib_test_3.c b/binutils-2.25/gold/testsuite/start_lib_test_3.c index 79b467b..64a1ebf 100644 --- a/binutils-2.25/gold/testsuite/start_lib_test_3.c +++ b/binutils-2.25/gold/testsuite/start_lib_test_3.c @@ -1,6 +1,6 @@ /* start_lib_test_3.c -- test --start-lib/--end-lib. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/start_lib_test_main.c b/binutils-2.25/gold/testsuite/start_lib_test_main.c index 7809baa..6531ba9 100644 --- a/binutils-2.25/gold/testsuite/start_lib_test_main.c +++ b/binutils-2.25/gold/testsuite/start_lib_test_main.c @@ -1,6 +1,6 @@ /* start_lib_test_main.c -- test --start-lib/--end-lib. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/strong_ref_weak_def.sh b/binutils-2.25/gold/testsuite/strong_ref_weak_def.sh index 17afc5b..d5b766f 100755 --- a/binutils-2.25/gold/testsuite/strong_ref_weak_def.sh +++ b/binutils-2.25/gold/testsuite/strong_ref_weak_def.sh @@ -3,7 +3,7 @@ # strong_ref_weak_def.sh -- test non-weak reference to a weak symbol defined # in a DSO. -# Copyright 2010 Free Software Foundation, Inc. +# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Written by Doug Kwan <dougkwan@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/strong_ref_weak_def_1.c b/binutils-2.25/gold/testsuite/strong_ref_weak_def_1.c index bc00e77..61493f2 100644 --- a/binutils-2.25/gold/testsuite/strong_ref_weak_def_1.c +++ b/binutils-2.25/gold/testsuite/strong_ref_weak_def_1.c @@ -1,7 +1,7 @@ // strong_ref_weak_def_1.c -- test a strong reference to a weak definition // in a DSO. -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/strong_ref_weak_def_2.c b/binutils-2.25/gold/testsuite/strong_ref_weak_def_2.c index 4801f6d..c7c9ede 100644 --- a/binutils-2.25/gold/testsuite/strong_ref_weak_def_2.c +++ b/binutils-2.25/gold/testsuite/strong_ref_weak_def_2.c @@ -1,7 +1,7 @@ // strong_ref_weak_def_2.c -- test a strong reference to a weak definition // in a DSO. -// Copyright 2010 Free Software Foundation, Inc. +// Copyright (C) 2010-2014 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/test.cc b/binutils-2.25/gold/testsuite/test.cc index b08d6d7..80f2ab5 100644 --- a/binutils-2.25/gold/testsuite/test.cc +++ b/binutils-2.25/gold/testsuite/test.cc @@ -1,6 +1,6 @@ // test.cc -- simplistic test framework for gold. -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/test.h b/binutils-2.25/gold/testsuite/test.h index 37060d3..1522bcf 100644 --- a/binutils-2.25/gold/testsuite/test.h +++ b/binutils-2.25/gold/testsuite/test.h @@ -1,6 +1,6 @@ // test.h -- simplistic test framework for gold unittests -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/testfile.cc b/binutils-2.25/gold/testsuite/testfile.cc index f360e3d..3defb4d 100644 --- a/binutils-2.25/gold/testsuite/testfile.cc +++ b/binutils-2.25/gold/testsuite/testfile.cc @@ -1,6 +1,6 @@ // testfile.cc -- Dummy ELF objects for testing purposes. -// Copyright 2006, 2007, 2008, 2009, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/testfile.h b/binutils-2.25/gold/testsuite/testfile.h index 9178179..dac02ff 100644 --- a/binutils-2.25/gold/testsuite/testfile.h +++ b/binutils-2.25/gold/testsuite/testfile.h @@ -1,6 +1,6 @@ // testfile.h -- test input files -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/testmain.cc b/binutils-2.25/gold/testsuite/testmain.cc index ac99000..a3a105c 100644 --- a/binutils-2.25/gold/testsuite/testmain.cc +++ b/binutils-2.25/gold/testsuite/testmain.cc @@ -1,6 +1,6 @@ // testmain.cc -- main function for simplisitic gold test framework. -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/text_section_grouping.cc b/binutils-2.25/gold/testsuite/text_section_grouping.cc index 5a3a809..dc29a1f 100644 --- a/binutils-2.25/gold/testsuite/text_section_grouping.cc +++ b/binutils-2.25/gold/testsuite/text_section_grouping.cc @@ -1,6 +1,6 @@ // text_section_grouping.cc -- a test case for gold -// Copyright 2012 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Sriraman Tallam <tmsriram@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/text_section_grouping.sh b/binutils-2.25/gold/testsuite/text_section_grouping.sh index 84ebe4c..a819e57 100755 --- a/binutils-2.25/gold/testsuite/text_section_grouping.sh +++ b/binutils-2.25/gold/testsuite/text_section_grouping.sh @@ -2,7 +2,7 @@ # text_section_grouping.sh -- test -# Copyright 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # Written by Sriraman Tallam <tmsriram@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/thin_archive_main.cc b/binutils-2.25/gold/testsuite/thin_archive_main.cc index 6c38715..6f19c0a 100644 --- a/binutils-2.25/gold/testsuite/thin_archive_main.cc +++ b/binutils-2.25/gold/testsuite/thin_archive_main.cc @@ -1,6 +1,6 @@ // thin_archive_main.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/thin_archive_test_1.cc b/binutils-2.25/gold/testsuite/thin_archive_test_1.cc index db23937..f44b3dd 100644 --- a/binutils-2.25/gold/testsuite/thin_archive_test_1.cc +++ b/binutils-2.25/gold/testsuite/thin_archive_test_1.cc @@ -1,6 +1,6 @@ // thin_archive_test_1.cc -- part of a test case for thin archives -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/thin_archive_test_2.cc b/binutils-2.25/gold/testsuite/thin_archive_test_2.cc index 2c1ee31..15c9a7a 100644 --- a/binutils-2.25/gold/testsuite/thin_archive_test_2.cc +++ b/binutils-2.25/gold/testsuite/thin_archive_test_2.cc @@ -1,6 +1,6 @@ // thin_archive_test_2.cc -- part of a test case for thin archives -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/thin_archive_test_3.cc b/binutils-2.25/gold/testsuite/thin_archive_test_3.cc index b58c59f..96cd79d 100644 --- a/binutils-2.25/gold/testsuite/thin_archive_test_3.cc +++ b/binutils-2.25/gold/testsuite/thin_archive_test_3.cc @@ -1,6 +1,6 @@ // thin_archive_test_3.cc -- part of a test case for thin archives -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/thin_archive_test_4.cc b/binutils-2.25/gold/testsuite/thin_archive_test_4.cc index 1b67c94..903de11 100644 --- a/binutils-2.25/gold/testsuite/thin_archive_test_4.cc +++ b/binutils-2.25/gold/testsuite/thin_archive_test_4.cc @@ -1,6 +1,6 @@ // thin_archive_test_4.cc -- part of a test case for thin archives -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/thumb2_branch_range.t b/binutils-2.25/gold/testsuite/thumb2_branch_range.t index 8fdc783..2002fb9 100644 --- a/binutils-2.25/gold/testsuite/thumb2_branch_range.t +++ b/binutils-2.25/gold/testsuite/thumb2_branch_range.t @@ -1,6 +1,6 @@ /* thumb2_banch_range.t -- linker script to test THUMB-2 branch range. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Doug Kwan <dougkwan@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/thumb_branch_range.t b/binutils-2.25/gold/testsuite/thumb_branch_range.t index fa858b5..2b0e54e 100644 --- a/binutils-2.25/gold/testsuite/thumb_branch_range.t +++ b/binutils-2.25/gold/testsuite/thumb_branch_range.t @@ -1,6 +1,6 @@ /* thumb_banch_range.t -- linker script to test ARM branch range. - Copyright 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2014 Free Software Foundation, Inc. Written by Doug Kwan <dougkwan@google.com>. This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/tls_test.cc b/binutils-2.25/gold/testsuite/tls_test.cc index c875752..7d38658 100644 --- a/binutils-2.25/gold/testsuite/tls_test.cc +++ b/binutils-2.25/gold/testsuite/tls_test.cc @@ -1,6 +1,6 @@ // tls_test.cc -- test TLS variables for gold -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/tls_test.h b/binutils-2.25/gold/testsuite/tls_test.h index 1c98b17..b70c0ee 100644 --- a/binutils-2.25/gold/testsuite/tls_test.h +++ b/binutils-2.25/gold/testsuite/tls_test.h @@ -1,6 +1,6 @@ // tls_test.h -- test TLS variables for gold, header file -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/tls_test_c.c b/binutils-2.25/gold/testsuite/tls_test_c.c index 896191f..918a5b2 100644 --- a/binutils-2.25/gold/testsuite/tls_test_c.c +++ b/binutils-2.25/gold/testsuite/tls_test_c.c @@ -1,6 +1,6 @@ /* tls_test_c.c -- test TLS common symbol - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/tls_test_file2.cc b/binutils-2.25/gold/testsuite/tls_test_file2.cc index b02a7bd..86cee67 100644 --- a/binutils-2.25/gold/testsuite/tls_test_file2.cc +++ b/binutils-2.25/gold/testsuite/tls_test_file2.cc @@ -1,6 +1,6 @@ // tls_test.cc -- test TLS variables for gold -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/tls_test_main.cc b/binutils-2.25/gold/testsuite/tls_test_main.cc index d781a15..42db36f 100644 --- a/binutils-2.25/gold/testsuite/tls_test_main.cc +++ b/binutils-2.25/gold/testsuite/tls_test_main.cc @@ -1,6 +1,6 @@ // tls_test.cc -- test TLS variables for gold, main function -// Copyright 2006, 2007, 2008, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_shared.sh b/binutils-2.25/gold/testsuite/two_file_shared.sh index 6240311..84465f8 100755 --- a/binutils-2.25/gold/testsuite/two_file_shared.sh +++ b/binutils-2.25/gold/testsuite/two_file_shared.sh @@ -2,7 +2,7 @@ # two_file_shared.sh -- check that debug info gets symbol addresses -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test.h b/binutils-2.25/gold/testsuite/two_file_test.h index d89f050..617b8d2 100644 --- a/binutils-2.25/gold/testsuite/two_file_test.h +++ b/binutils-2.25/gold/testsuite/two_file_test.h @@ -1,6 +1,6 @@ // two_file_test.h -- a two file test case for gold, header file -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_1.cc b/binutils-2.25/gold/testsuite/two_file_test_1.cc index 8b4c8ad..fdcb7d5 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_1.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_1.cc @@ -1,6 +1,6 @@ // two_file_test_1.cc -- a two file test case for gold, file 1 of 2 -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_1_v1.cc b/binutils-2.25/gold/testsuite/two_file_test_1_v1.cc index 2a23654..2518479 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_1_v1.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_1_v1.cc @@ -1,6 +1,6 @@ // two_file_test_1_v1.cc -- a two file test case for gold, file 1 of 2 -// Copyright 2006, 2007, 2008, 2011 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_1b.cc b/binutils-2.25/gold/testsuite/two_file_test_1b.cc index 8f6d4e6..4083f0b 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_1b.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_1b.cc @@ -1,7 +1,7 @@ // two_file_test_1b.cc -- supplementary file for a three-file test case // for gold. -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_1b_v1.cc b/binutils-2.25/gold/testsuite/two_file_test_1b_v1.cc index 0adaf84..3306e9c 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_1b_v1.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_1b_v1.cc @@ -1,7 +1,7 @@ // two_file_test_1b_v1.cc -- supplementary file for a three-file test case // for gold. -// Copyright 2008, 2011 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_2.cc b/binutils-2.25/gold/testsuite/two_file_test_2.cc index e1aeaf4..e3818f9 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_2.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_2.cc @@ -1,6 +1,6 @@ // two_file_test_2.cc -- a two file test case for gold, file 2 of 2 -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_2_tls.cc b/binutils-2.25/gold/testsuite/two_file_test_2_tls.cc index 6c74c69..3f6dc0b 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_2_tls.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_2_tls.cc @@ -1,6 +1,6 @@ // two_file_test_2_tls.cc -- a two file test case for gold, with a TLS symbol -// Copyright 2006, 2007, 2008, 2013 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_2_v1.cc b/binutils-2.25/gold/testsuite/two_file_test_2_v1.cc index ea26c66..664380b 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_2_v1.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_2_v1.cc @@ -1,6 +1,6 @@ // two_file_test_2_v1.cc -- a two file test case for gold, file 2 of 2 -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_main.cc b/binutils-2.25/gold/testsuite/two_file_test_main.cc index b7e3838..6c1c52c 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_main.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_main.cc @@ -1,6 +1,6 @@ // two_file_test_main.cc -- a two file test case for gold, main function -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/two_file_test_tls.cc b/binutils-2.25/gold/testsuite/two_file_test_tls.cc index d9a1c39..5f450a4 100644 --- a/binutils-2.25/gold/testsuite/two_file_test_tls.cc +++ b/binutils-2.25/gold/testsuite/two_file_test_tls.cc @@ -1,6 +1,6 @@ // two_file_test_tls.cc -- a two file test case for gold, main function, with TLS -// Copyright 2006, 2007, 2008, 2013 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/undef_symbol.cc b/binutils-2.25/gold/testsuite/undef_symbol.cc index e35b2b2..306f29a 100644 --- a/binutils-2.25/gold/testsuite/undef_symbol.cc +++ b/binutils-2.25/gold/testsuite/undef_symbol.cc @@ -1,6 +1,6 @@ // undef_symbol.cc -- a test case for undefined references -// Copyright 2007, 2008, 2013 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/undef_symbol.sh b/binutils-2.25/gold/testsuite/undef_symbol.sh index b689edc..4f6308f 100755 --- a/binutils-2.25/gold/testsuite/undef_symbol.sh +++ b/binutils-2.25/gold/testsuite/undef_symbol.sh @@ -2,7 +2,7 @@ # undef_symbol.sh -- a test case for undefined symbols in shared libraries -# Copyright 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2007-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/undef_symbol_main.cc b/binutils-2.25/gold/testsuite/undef_symbol_main.cc index 2c21044..537eed8 100644 --- a/binutils-2.25/gold/testsuite/undef_symbol_main.cc +++ b/binutils-2.25/gold/testsuite/undef_symbol_main.cc @@ -1,6 +1,6 @@ // undef_symbol_1.cc -- a test case for undefined references -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_matching_def.cc b/binutils-2.25/gold/testsuite/ver_matching_def.cc index b654dff..ee2edc3 100644 --- a/binutils-2.25/gold/testsuite/ver_matching_def.cc +++ b/binutils-2.25/gold/testsuite/ver_matching_def.cc @@ -1,6 +1,6 @@ // ver_matching_def.cc - test matching rules in version_script.map -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_matching_test.sh b/binutils-2.25/gold/testsuite/ver_matching_test.sh index 4880efa..9c7722e 100755 --- a/binutils-2.25/gold/testsuite/ver_matching_test.sh +++ b/binutils-2.25/gold/testsuite/ver_matching_test.sh @@ -2,7 +2,7 @@ # ver_matching_test.sh -- a test case for version script matching -# Copyright 2008, 2010 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test.h b/binutils-2.25/gold/testsuite/ver_test.h index 0b1aea8..62a4b37 100644 --- a/binutils-2.25/gold/testsuite/ver_test.h +++ b/binutils-2.25/gold/testsuite/ver_test.h @@ -1,6 +1,6 @@ // ver_test.h -- a test case for gold -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_1.cc b/binutils-2.25/gold/testsuite/ver_test_1.cc index 42a18ec..6336234 100644 --- a/binutils-2.25/gold/testsuite/ver_test_1.cc +++ b/binutils-2.25/gold/testsuite/ver_test_1.cc @@ -1,6 +1,6 @@ // ver_test_1.cc -- a test case for gold -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_1.sh b/binutils-2.25/gold/testsuite/ver_test_1.sh index edf7351..63d5d49 100755 --- a/binutils-2.25/gold/testsuite/ver_test_1.sh +++ b/binutils-2.25/gold/testsuite/ver_test_1.sh @@ -2,7 +2,7 @@ # ver_test_1.sh -- check that protected symbols are local -# Copyright 2009 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_10.script b/binutils-2.25/gold/testsuite/ver_test_10.script index fa9f175..720220c 100644 --- a/binutils-2.25/gold/testsuite/ver_test_10.script +++ b/binutils-2.25/gold/testsuite/ver_test_10.script @@ -1,6 +1,6 @@ ## ver_test_10.script -- a test case for gold -## Copyright 2008 Free Software Foundation, Inc. +## Copyright (C) 2008-2014 Free Software Foundation, Inc. ## Written by Ian Lance Taylor <iant@google.com>. ## This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_10.sh b/binutils-2.25/gold/testsuite/ver_test_10.sh index 68138a6..11044f3 100755 --- a/binutils-2.25/gold/testsuite/ver_test_10.sh +++ b/binutils-2.25/gold/testsuite/ver_test_10.sh @@ -2,7 +2,7 @@ # ver_test_10.sh -- test global/local symbols -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_2.cc b/binutils-2.25/gold/testsuite/ver_test_2.cc index b81e62e..bf230d3 100644 --- a/binutils-2.25/gold/testsuite/ver_test_2.cc +++ b/binutils-2.25/gold/testsuite/ver_test_2.cc @@ -1,6 +1,6 @@ // ver_test_2.cc -- a test case for gold -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_2.script b/binutils-2.25/gold/testsuite/ver_test_2.script index 15329d7..bd62fc1 100644 --- a/binutils-2.25/gold/testsuite/ver_test_2.script +++ b/binutils-2.25/gold/testsuite/ver_test_2.script @@ -1,6 +1,6 @@ ## ver_test_2.script -- a test case for gold -## Copyright 2007, 2008 Free Software Foundation, Inc. +## Copyright (C) 2007-2014 Free Software Foundation, Inc. ## Written by Cary Coutant <ccoutant@google.com>. ## This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_2.sh b/binutils-2.25/gold/testsuite/ver_test_2.sh index 0bd0f90..bd973bc 100755 --- a/binutils-2.25/gold/testsuite/ver_test_2.sh +++ b/binutils-2.25/gold/testsuite/ver_test_2.sh @@ -2,7 +2,7 @@ # ver_test_2.sh -- test that symbol has correct version -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_3.cc b/binutils-2.25/gold/testsuite/ver_test_3.cc index 022a888..ec05792 100644 --- a/binutils-2.25/gold/testsuite/ver_test_3.cc +++ b/binutils-2.25/gold/testsuite/ver_test_3.cc @@ -1,6 +1,6 @@ // ver_test_3.cc -- a test case for gold -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_4.cc b/binutils-2.25/gold/testsuite/ver_test_4.cc index 404dfbc..ef06e2c 100644 --- a/binutils-2.25/gold/testsuite/ver_test_4.cc +++ b/binutils-2.25/gold/testsuite/ver_test_4.cc @@ -1,6 +1,6 @@ // ver_test_4.cc -- a test case for gold -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_4.script b/binutils-2.25/gold/testsuite/ver_test_4.script index e97c74e..071e3f6 100644 --- a/binutils-2.25/gold/testsuite/ver_test_4.script +++ b/binutils-2.25/gold/testsuite/ver_test_4.script @@ -1,6 +1,6 @@ ## ver_test_4.script -- a test case for gold -## Copyright 2007, 2008 Free Software Foundation, Inc. +## Copyright (C) 2007-2014 Free Software Foundation, Inc. ## Written by Cary Coutant <ccoutant@google.com>. ## This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_4.sh b/binutils-2.25/gold/testsuite/ver_test_4.sh index 3466a5d..f125f2b 100755 --- a/binutils-2.25/gold/testsuite/ver_test_4.sh +++ b/binutils-2.25/gold/testsuite/ver_test_4.sh @@ -2,7 +2,7 @@ # ver_test_4.sh -- test that version symbol is visible. -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_5.cc b/binutils-2.25/gold/testsuite/ver_test_5.cc index cffeae6..d861d48 100644 --- a/binutils-2.25/gold/testsuite/ver_test_5.cc +++ b/binutils-2.25/gold/testsuite/ver_test_5.cc @@ -1,6 +1,6 @@ // ver_test_5.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com> // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_5.script b/binutils-2.25/gold/testsuite/ver_test_5.script index 028cdd6..950adc8 100644 --- a/binutils-2.25/gold/testsuite/ver_test_5.script +++ b/binutils-2.25/gold/testsuite/ver_test_5.script @@ -1,6 +1,6 @@ ## ver_test_5.script -- a test case for gold -## Copyright 2008 Free Software Foundation, Inc. +## Copyright (C) 2008-2014 Free Software Foundation, Inc. ## Written by Ian Lance Taylor <iant@google.com> ## This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_5.sh b/binutils-2.25/gold/testsuite/ver_test_5.sh index 2eacb45..0c9b024 100755 --- a/binutils-2.25/gold/testsuite/ver_test_5.sh +++ b/binutils-2.25/gold/testsuite/ver_test_5.sh @@ -2,7 +2,7 @@ # ver_test_5.sh -- test that symbol has correct version -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_6.c b/binutils-2.25/gold/testsuite/ver_test_6.c index 44b483f..fb96c77 100644 --- a/binutils-2.25/gold/testsuite/ver_test_6.c +++ b/binutils-2.25/gold/testsuite/ver_test_6.c @@ -1,6 +1,6 @@ /* ver_test_6.c -- test common symbol with shared library version - Copyright 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com> This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_7.cc b/binutils-2.25/gold/testsuite/ver_test_7.cc index d602a48..2badcea 100644 --- a/binutils-2.25/gold/testsuite/ver_test_7.cc +++ b/binutils-2.25/gold/testsuite/ver_test_7.cc @@ -1,6 +1,6 @@ // ver_test_7.cc -- test weak duplicate symbol with version -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com> // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_7.sh b/binutils-2.25/gold/testsuite/ver_test_7.sh index 04d35fc..f0fe8f6 100755 --- a/binutils-2.25/gold/testsuite/ver_test_7.sh +++ b/binutils-2.25/gold/testsuite/ver_test_7.sh @@ -2,7 +2,7 @@ # ver_test_7.sh -- test that symbol has correct version -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_8.script b/binutils-2.25/gold/testsuite/ver_test_8.script index b5bfc3f..9e48e38 100644 --- a/binutils-2.25/gold/testsuite/ver_test_8.script +++ b/binutils-2.25/gold/testsuite/ver_test_8.script @@ -1,6 +1,6 @@ ## ver_test_8.script -- a test case for gold -## Copyright 2008 Free Software Foundation, Inc. +## Copyright (C) 2008-2014 Free Software Foundation, Inc. ## Written by Ian Lance Taylor <iant@google.com> ## This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_9.cc b/binutils-2.25/gold/testsuite/ver_test_9.cc index 5d06d4e..d0cc4e7 100644 --- a/binutils-2.25/gold/testsuite/ver_test_9.cc +++ b/binutils-2.25/gold/testsuite/ver_test_9.cc @@ -1,6 +1,6 @@ // ver_test_9.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_main.cc b/binutils-2.25/gold/testsuite/ver_test_main.cc index f8a7b75..c24beb4 100644 --- a/binutils-2.25/gold/testsuite/ver_test_main.cc +++ b/binutils-2.25/gold/testsuite/ver_test_main.cc @@ -1,6 +1,6 @@ // ver_test_main.cc -- a test case for gold -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/ver_test_main_2.cc b/binutils-2.25/gold/testsuite/ver_test_main_2.cc index 1599e0f..9a03191 100644 --- a/binutils-2.25/gold/testsuite/ver_test_main_2.cc +++ b/binutils-2.25/gold/testsuite/ver_test_main_2.cc @@ -1,6 +1,6 @@ // ver_test_main_2.cc -- a test case for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_alias_test_1.cc b/binutils-2.25/gold/testsuite/weak_alias_test_1.cc index 0ad9265..67c709d 100644 --- a/binutils-2.25/gold/testsuite/weak_alias_test_1.cc +++ b/binutils-2.25/gold/testsuite/weak_alias_test_1.cc @@ -1,6 +1,6 @@ // weak_alias_test_1.cc -- test weak aliases for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_alias_test_2.cc b/binutils-2.25/gold/testsuite/weak_alias_test_2.cc index 8294525..5933314 100644 --- a/binutils-2.25/gold/testsuite/weak_alias_test_2.cc +++ b/binutils-2.25/gold/testsuite/weak_alias_test_2.cc @@ -1,6 +1,6 @@ // weak_alias_test_2.cc -- test weak aliases for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_alias_test_3.cc b/binutils-2.25/gold/testsuite/weak_alias_test_3.cc index 99152e2..ef7b252 100644 --- a/binutils-2.25/gold/testsuite/weak_alias_test_3.cc +++ b/binutils-2.25/gold/testsuite/weak_alias_test_3.cc @@ -1,6 +1,6 @@ // weak_alias_test_3.cc -- test weak aliases for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_alias_test_4.cc b/binutils-2.25/gold/testsuite/weak_alias_test_4.cc index 714c6d6..04a0098 100644 --- a/binutils-2.25/gold/testsuite/weak_alias_test_4.cc +++ b/binutils-2.25/gold/testsuite/weak_alias_test_4.cc @@ -1,6 +1,6 @@ // weak_alias_test_4.cc -- test weak aliases for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_alias_test_5.cc b/binutils-2.25/gold/testsuite/weak_alias_test_5.cc index df48092..c3e746e 100644 --- a/binutils-2.25/gold/testsuite/weak_alias_test_5.cc +++ b/binutils-2.25/gold/testsuite/weak_alias_test_5.cc @@ -1,6 +1,6 @@ // weak_alias_test_5.cc -- test versioned weak aliases for gold -// Copyright 2011 Free Software Foundation, Inc. +// Copyright (C) 2011-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_alias_test_main.cc b/binutils-2.25/gold/testsuite/weak_alias_test_main.cc index e3f8620..1b4778d 100644 --- a/binutils-2.25/gold/testsuite/weak_alias_test_main.cc +++ b/binutils-2.25/gold/testsuite/weak_alias_test_main.cc @@ -1,6 +1,6 @@ // weak_alias_test_main.cc -- test weak aliases for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_plt.sh b/binutils-2.25/gold/testsuite/weak_plt.sh index 6c419b8..2098011 100755 --- a/binutils-2.25/gold/testsuite/weak_plt.sh +++ b/binutils-2.25/gold/testsuite/weak_plt.sh @@ -2,7 +2,7 @@ # weak_plt.sh -- test calling a weak undefined function. -# Copyright 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2014 Free Software Foundation, Inc. # Written by Ian Lance Taylor <iant@google.com>. # This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_plt_main.cc b/binutils-2.25/gold/testsuite/weak_plt_main.cc index 33cb35e..39fe46f 100644 --- a/binutils-2.25/gold/testsuite/weak_plt_main.cc +++ b/binutils-2.25/gold/testsuite/weak_plt_main.cc @@ -1,6 +1,6 @@ // weak_plt_main.cc -- test call to weak undefined function for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_plt_shared.cc b/binutils-2.25/gold/testsuite/weak_plt_shared.cc index 8d82005..0275a2e 100644 --- a/binutils-2.25/gold/testsuite/weak_plt_shared.cc +++ b/binutils-2.25/gold/testsuite/weak_plt_shared.cc @@ -1,6 +1,6 @@ // weak_plt_shared.cc -- test call to weak undefined function for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_test.cc b/binutils-2.25/gold/testsuite/weak_test.cc index c14a688..67c4438 100644 --- a/binutils-2.25/gold/testsuite/weak_test.cc +++ b/binutils-2.25/gold/testsuite/weak_test.cc @@ -1,6 +1,6 @@ // weak_test.cc -- test handling of weak symbols for gold -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_undef.h b/binutils-2.25/gold/testsuite/weak_undef.h index 17d5f02..796dca5 100644 --- a/binutils-2.25/gold/testsuite/weak_undef.h +++ b/binutils-2.25/gold/testsuite/weak_undef.h @@ -1,6 +1,6 @@ // weak_undef.h -- test handling of weak undefined symbols for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_undef_file1.cc b/binutils-2.25/gold/testsuite/weak_undef_file1.cc index fd28870..60cf5c3 100644 --- a/binutils-2.25/gold/testsuite/weak_undef_file1.cc +++ b/binutils-2.25/gold/testsuite/weak_undef_file1.cc @@ -1,6 +1,6 @@ // weak_undef_file1.cc -- test handling of weak undefined symbols for gold -// Copyright 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_undef_file2.cc b/binutils-2.25/gold/testsuite/weak_undef_file2.cc index 33701b2..7ceff00 100644 --- a/binutils-2.25/gold/testsuite/weak_undef_file2.cc +++ b/binutils-2.25/gold/testsuite/weak_undef_file2.cc @@ -1,6 +1,6 @@ // weak_undef_file2.cc -- test handling of weak undefined symbols for gold -// Copyright 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_undef_file3.cc b/binutils-2.25/gold/testsuite/weak_undef_file3.cc new file mode 100644 index 0000000..1597447 --- /dev/null +++ b/binutils-2.25/gold/testsuite/weak_undef_file3.cc @@ -0,0 +1,29 @@ +// weak_undef_file3.cc -- test handling of weak undefined symbols for gold + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// This file tests that we correctly deal with weak undefined symbols +// when searching archive libraries. If we have a weak undefined symbol, +// it should not cause us to link an archive library member that defines +// that symbol. However, if the symbol is also listed in a -u option on +// the command line, it should cause the archive member to be linked. + +int weak_undef_1 = 1; diff --git a/binutils-2.25/gold/testsuite/weak_undef_file4.cc b/binutils-2.25/gold/testsuite/weak_undef_file4.cc new file mode 100644 index 0000000..a82a49f --- /dev/null +++ b/binutils-2.25/gold/testsuite/weak_undef_file4.cc @@ -0,0 +1,29 @@ +// weak_undef_file4.cc -- test handling of weak undefined symbols for gold + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// This file tests that we correctly deal with weak undefined symbols +// when searching archive libraries. If we have a weak undefined symbol, +// it should not cause us to link an archive library member that defines +// that symbol. However, if the symbol is also listed in a -u option on +// the command line, it should cause the archive member to be linked. + +int weak_undef_2 = 2; diff --git a/binutils-2.25/gold/testsuite/weak_undef_test.cc b/binutils-2.25/gold/testsuite/weak_undef_test.cc index 880d5cd..16277a2 100644 --- a/binutils-2.25/gold/testsuite/weak_undef_test.cc +++ b/binutils-2.25/gold/testsuite/weak_undef_test.cc @@ -1,6 +1,6 @@ // weak_undef_test.cc -- test handling of weak undefined symbols for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright (C) 2008-2014 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/testsuite/weak_undef_test_2.cc b/binutils-2.25/gold/testsuite/weak_undef_test_2.cc new file mode 100644 index 0000000..549bd3f --- /dev/null +++ b/binutils-2.25/gold/testsuite/weak_undef_test_2.cc @@ -0,0 +1,79 @@ +// weak_undef_test_2.cc -- test handling of weak undefined symbols for gold + +// Copyright (C) 2014 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +// This file tests that we correctly deal with weak undefined symbols +// when searching archive libraries. If we have a weak undefined symbol, +// it should not cause us to link an archive library member that defines +// that symbol. However, if the symbol is also listed in a -u option on +// the command line, it should cause the archive member to be linked. + + +#include <cstdio> + +// This symbol is defined in weak_undef_file3.cc, but we should +// not load it from the library. +extern int weak_undef_1 __attribute__ ((weak)); + +// This symbol is defined in weak_undef_file4.cc, but is also +// listed in a -u option on the link command, so we should +// load it from the library. +extern int weak_undef_2 __attribute__ ((weak)); + +int *p1 = &weak_undef_1; + +int *p2 = &weak_undef_2; + +int +main() +{ + int status = 0; + + if (&weak_undef_1 != NULL) + { + fprintf(stderr, "FAILED weak undef test 1: %s\n", + "&weak_undef_1 is not NULL"); + status = 1; + } + + if (&weak_undef_2 == NULL) + { + fprintf(stderr, "FAILED weak undef test 2: %s\n", + "&weak_undef_2 is NULL"); + status = 1; + } + + if (p1 != NULL) + { + fprintf(stderr, "FAILED weak undef test 3: %s\n", + "p1 is not NULL"); + status = 1; + } + + if (p2 == NULL) + { + fprintf(stderr, "FAILED weak undef test 4: %s\n", + "p2 is NULL"); + status = 1; + } + + return status; +} diff --git a/binutils-2.25/gold/tilegx.cc b/binutils-2.25/gold/tilegx.cc index 576a28c..1a14dea 100644 --- a/binutils-2.25/gold/tilegx.cc +++ b/binutils-2.25/gold/tilegx.cc @@ -1,6 +1,6 @@ // tilegx.cc -- tilegx target support for gold. -// Copyright 2012, 2013 Free Software Foundation, Inc. +// Copyright (C) 2012-2014 Free Software Foundation, Inc. // Written by Jiong Wang (jiwang@tilera.com) // This file is part of gold. @@ -3758,7 +3758,8 @@ Target_tilegx<size, big_endian>::Scan::global(Symbol_table* symtab, // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (gsym->may_need_copy_reloc()) + if (!parameters->options().output_is_position_independent() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); @@ -3832,7 +3833,8 @@ Target_tilegx<size, big_endian>::Scan::global(Symbol_table* symtab, // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (gsym->may_need_copy_reloc()) + if (parameters->options().output_is_executable() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); diff --git a/binutils-2.25/gold/timer.cc b/binutils-2.25/gold/timer.cc index f3a1c91..671439f 100644 --- a/binutils-2.25/gold/timer.cc +++ b/binutils-2.25/gold/timer.cc @@ -1,6 +1,6 @@ // timer.cc -- helper class for time accounting -// Copyright 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Rafael Avila de Espindola <espindola@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/timer.h b/binutils-2.25/gold/timer.h index 4f986ca..fca5b12 100644 --- a/binutils-2.25/gold/timer.h +++ b/binutils-2.25/gold/timer.h @@ -1,6 +1,6 @@ // timer.h -- helper class for time accounting -*- C++ -*- -// Copyright 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009-2014 Free Software Foundation, Inc. // Written by Rafael Avila de Espindola <espindola@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/tls.h b/binutils-2.25/gold/tls.h index 5b5cb6e..1a287ad 100644 --- a/binutils-2.25/gold/tls.h +++ b/binutils-2.25/gold/tls.h @@ -1,6 +1,6 @@ // tls.h -- Thread-Local Storage utility routines for gold -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/token.h b/binutils-2.25/gold/token.h index 5cf64a0..47091cb 100644 --- a/binutils-2.25/gold/token.h +++ b/binutils-2.25/gold/token.h @@ -1,6 +1,6 @@ // token.h -- lock tokens for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/version.cc b/binutils-2.25/gold/version.cc index 37977e5..2369541 100644 --- a/binutils-2.25/gold/version.cc +++ b/binutils-2.25/gold/version.cc @@ -1,7 +1,6 @@ // version.c -- print gold version information -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -63,7 +62,7 @@ print_version(bool print_short) if (!print_short) { // This output is intended to follow the GNU standards. - printf(_("Copyright 2013 Free Software Foundation, Inc.\n")); + printf(_("Copyright (C) 2014 Free Software Foundation, Inc.\n")); printf(_("\ This program is free software; you may redistribute it under the terms of\n\ the GNU General Public License version 3 or (at your option) a later version.\n\ diff --git a/binutils-2.25/gold/workqueue-internal.h b/binutils-2.25/gold/workqueue-internal.h index 764dc91..f27d075 100644 --- a/binutils-2.25/gold/workqueue-internal.h +++ b/binutils-2.25/gold/workqueue-internal.h @@ -1,6 +1,6 @@ // workqueue-internal.h -- internal work queue header for gold -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/workqueue-threads.cc b/binutils-2.25/gold/workqueue-threads.cc index de2ce5b..41f0543 100644 --- a/binutils-2.25/gold/workqueue-threads.cc +++ b/binutils-2.25/gold/workqueue-threads.cc @@ -1,6 +1,6 @@ // workqueue-threads.cc -- the threaded workqueue for gold -// Copyright 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2007-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/workqueue.cc b/binutils-2.25/gold/workqueue.cc index e78e86b..2d5684e 100644 --- a/binutils-2.25/gold/workqueue.cc +++ b/binutils-2.25/gold/workqueue.cc @@ -1,6 +1,6 @@ // workqueue.cc -- the workqueue for gold -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/workqueue.h b/binutils-2.25/gold/workqueue.h index 424b5e7..d62071e 100644 --- a/binutils-2.25/gold/workqueue.h +++ b/binutils-2.25/gold/workqueue.h @@ -1,6 +1,6 @@ // workqueue.h -- the work queue for gold -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. diff --git a/binutils-2.25/gold/x86_64.cc b/binutils-2.25/gold/x86_64.cc index b95d2ed..f58c843 100644 --- a/binutils-2.25/gold/x86_64.cc +++ b/binutils-2.25/gold/x86_64.cc @@ -1,7 +1,6 @@ // x86_64.cc -- x86_64 target support for gold. -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2014 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -49,6 +48,37 @@ namespace using namespace gold; +// A class to handle the .got.plt section. + +class Output_data_got_plt_x86_64 : public Output_section_data_build +{ + public: + Output_data_got_plt_x86_64(Layout* layout) + : Output_section_data_build(8), + layout_(layout) + { } + + Output_data_got_plt_x86_64(Layout* layout, off_t data_size) + : Output_section_data_build(data_size, 8), + layout_(layout) + { } + + protected: + // Write out the PLT data. + void + do_write(Output_file*); + + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, "** GOT PLT"); } + + private: + // A pointer to the Layout class, so that we can find the .dynamic + // section when we write out the GOT PLT section. + Layout* layout_; +}; + // A class to handle the PLT data. // This is an abstract base class that handles most of the linker details // but does not know the actual contents of PLT entries. The derived @@ -62,9 +92,9 @@ class Output_data_plt_x86_64 : public Output_section_data Output_data_plt_x86_64(Layout* layout, uint64_t addralign, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative) - : Output_section_data(addralign), layout_(layout), tlsdesc_rel_(NULL), + : Output_section_data(addralign), tlsdesc_rel_(NULL), irelative_rel_(NULL), got_(got), got_plt_(got_plt), got_irelative_(got_irelative), count_(0), irelative_count_(0), tlsdesc_got_offset_(-1U), free_list_() @@ -72,12 +102,12 @@ class Output_data_plt_x86_64 : public Output_section_data Output_data_plt_x86_64(Layout* layout, uint64_t plt_entry_size, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative, unsigned int plt_count) : Output_section_data((plt_count + 1) * plt_entry_size, plt_entry_size, false), - layout_(layout), tlsdesc_rel_(NULL), irelative_rel_(NULL), got_(got), + tlsdesc_rel_(NULL), irelative_rel_(NULL), got_(got), got_plt_(got_plt), got_irelative_(got_irelative), count_(plt_count), irelative_count_(0), tlsdesc_got_offset_(-1U), free_list_() { @@ -269,9 +299,6 @@ class Output_data_plt_x86_64 : public Output_section_data void do_write(Output_file*); - // A pointer to the Layout class, so that we can find the .dynamic - // section when we write out the GOT PLT section. - Layout* layout_; // The reloc section. Reloc_section* rel_; // The TLSDESC relocs, if necessary. These must follow the regular @@ -283,7 +310,7 @@ class Output_data_plt_x86_64 : public Output_section_data // The .got section. Output_data_got<64, false>* got_; // The .got.plt section. - Output_data_space* got_plt_; + Output_data_got_plt_x86_64* got_plt_; // The part of the .got.plt section used for IRELATIVE relocs. Output_data_space* got_irelative_; // The number of PLT entries. @@ -304,7 +331,7 @@ class Output_data_plt_x86_64_standard : public Output_data_plt_x86_64<size> public: Output_data_plt_x86_64_standard(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative) : Output_data_plt_x86_64<size>(layout, plt_entry_size, got, got_plt, got_irelative) @@ -312,7 +339,7 @@ class Output_data_plt_x86_64_standard : public Output_data_plt_x86_64<size> Output_data_plt_x86_64_standard(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative, unsigned int plt_count) : Output_data_plt_x86_64<size>(layout, plt_entry_size, @@ -619,7 +646,7 @@ class Target_x86_64 : public Sized_target<size, false> Output_data_plt_x86_64<size>* make_data_plt(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative) { return this->do_make_data_plt(layout, got, got_plt, got_irelative); @@ -628,7 +655,7 @@ class Target_x86_64 : public Sized_target<size, false> Output_data_plt_x86_64<size>* make_data_plt(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative, unsigned int plt_count) { @@ -639,7 +666,7 @@ class Target_x86_64 : public Sized_target<size, false> virtual Output_data_plt_x86_64<size>* do_make_data_plt(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative) { return new Output_data_plt_x86_64_standard<size>(layout, got, got_plt, @@ -649,7 +676,7 @@ class Target_x86_64 : public Sized_target<size, false> virtual Output_data_plt_x86_64<size>* do_make_data_plt(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative, unsigned int plt_count) { @@ -848,7 +875,7 @@ class Target_x86_64 : public Sized_target<size, false> got_section(Symbol_table*, Layout*); // Get the GOT PLT section. - Output_data_space* + Output_data_got_plt_x86_64* got_plt_section() const { gold_assert(this->got_plt_ != NULL); @@ -959,7 +986,7 @@ class Target_x86_64 : public Sized_target<size, false> // The PLT section. Output_data_plt_x86_64<size>* plt_; // The GOT PLT section. - Output_data_space* got_plt_; + Output_data_got_plt_x86_64* got_plt_; // The GOT section for IRELATIVE relocations. Output_data_space* got_irelative_; // The GOT section for TLSDESC relocations. @@ -1075,7 +1102,7 @@ Target_x86_64<size>::got_section(Symbol_table* symtab, Layout* layout) | elfcpp::SHF_WRITE), this->got_, got_order, true); - this->got_plt_ = new Output_data_space(8, "** GOT PLT"); + this->got_plt_ = new Output_data_got_plt_x86_64(layout); layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS, (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), @@ -1164,6 +1191,27 @@ Target_x86_64<size>::rela_irelative_section(Layout* layout) return this->rela_irelative_; } +// Write the first three reserved words of the .got.plt section. +// The remainder of the section is written while writing the PLT +// in Output_data_plt_i386::do_write. + +void +Output_data_got_plt_x86_64::do_write(Output_file* of) +{ + // The first entry in the GOT is the address of the .dynamic section + // aka the PT_DYNAMIC segment. The next two entries are reserved. + // We saved space for them when we created the section in + // Target_x86_64::got_section. + const off_t got_file_offset = this->offset(); + gold_assert(this->data_size() >= 24); + unsigned char* const got_view = of->get_output_view(got_file_offset, 24); + Output_section* dynamic = this->layout_->dynamic_section(); + uint64_t dynamic_addr = dynamic == NULL ? 0 : dynamic->address(); + elfcpp::Swap<64, false>::writeval(got_view, dynamic_addr); + memset(got_view + 8, 0, 16); + of->write_output_view(got_file_offset, 24, got_view); +} + // Initialize the PLT section. template<int size> @@ -1199,7 +1247,7 @@ Output_data_plt_x86_64<size>::add_entry(Symbol_table* symtab, Layout* layout, unsigned int* pcount; unsigned int offset; unsigned int reserved; - Output_data_space* got; + Output_section_data_build* got; if (gsym->type() == elfcpp::STT_GNU_IFUNC && gsym->can_use_relative_reloc(false)) { @@ -1606,18 +1654,9 @@ Output_data_plt_x86_64<size>::do_write(Output_file* of) this->fill_first_plt_entry(pov, got_address, plt_address); pov += this->get_plt_entry_size(); - unsigned char* got_pov = got_view; - - // The first entry in the GOT is the address of the .dynamic section - // aka the PT_DYNAMIC segment. The next two entries are reserved. - // We saved space for them when we created the section in - // Target_x86_64::got_section. - Output_section* dynamic = this->layout_->dynamic_section(); - uint32_t dynamic_addr = dynamic == NULL ? 0 : dynamic->address(); - elfcpp::Swap<64, false>::writeval(got_pov, dynamic_addr); - got_pov += 8; - memset(got_pov, 0, 16); - got_pov += 16; + // The first three entries in the GOT are reserved, and are written + // by Output_data_got_plt_x86_64::do_write. + unsigned char* got_pov = got_view + 24; unsigned int plt_offset = this->get_plt_entry_size(); unsigned int got_offset = 24; @@ -1778,7 +1817,7 @@ Target_x86_64<size>::init_got_plt_for_update(Symbol_table* symtab, true); // Add the three reserved entries. - this->got_plt_ = new Output_data_space((plt_count + 3) * 8, 8, "** GOT PLT"); + this->got_plt_ = new Output_data_got_plt_x86_64(layout, (plt_count + 3) * 8); layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS, (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), @@ -2113,12 +2152,14 @@ Target_x86_64<size>::Scan::get_reference_flags(unsigned int r_type) case elfcpp::R_X86_64_PC64: case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: case elfcpp::R_X86_64_PC16: case elfcpp::R_X86_64_PC8: case elfcpp::R_X86_64_GOTOFF64: return Symbol::RELATIVE_REF; case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: case elfcpp::R_X86_64_PLTOFF64: return Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; @@ -2200,6 +2241,7 @@ Target_x86_64<size>::Scan::check_non_pic(Relobj* object, unsigned int r_type, // glibc supports these reloc types, but they can overflow. case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: // A PC relative reference is OK against a local symbol or if // the symbol is defined locally. if (gsym == NULL @@ -2219,12 +2261,28 @@ Target_x86_64<size>::Scan::check_non_pic(Relobj* object, unsigned int r_type, object->error(_("requires dynamic R_X86_64_32 reloc which may " "overflow at runtime; recompile with -fPIC")); else - object->error(_("requires dynamic %s reloc against '%s' which may " - "overflow at runtime; recompile with -fPIC"), - (r_type == elfcpp::R_X86_64_32 - ? "R_X86_64_32" - : "R_X86_64_PC32"), - gsym->name()); + { + const char *r_name; + switch (r_type) + { + case elfcpp::R_X86_64_32: + r_name = "R_X86_64_32"; + break; + case elfcpp::R_X86_64_PC32: + r_name = "R_X86_64_PC32"; + break; + case elfcpp::R_X86_64_PC32_BND: + r_name = "R_X86_64_PC32_BND"; + break; + default: + gold_unreachable(); + break; + } + object->error(_("requires dynamic %s reloc against '%s' " + "which may overflow at runtime; recompile " + "with -fPIC"), + r_name, gsym->name()); + } this->issued_non_pic_error_ = true; return; @@ -2368,11 +2426,13 @@ Target_x86_64<size>::Scan::local(Symbol_table* symtab, case elfcpp::R_X86_64_PC64: case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: case elfcpp::R_X86_64_PC16: case elfcpp::R_X86_64_PC8: break; case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: // Since we know this is a local symbol, we can handle this as a // PC32 reloc. break; @@ -2714,7 +2774,8 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab, // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (gsym->may_need_copy_reloc()) + if (!parameters->options().output_is_position_independent() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); @@ -2765,6 +2826,7 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab, case elfcpp::R_X86_64_PC64: case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: case elfcpp::R_X86_64_PC16: case elfcpp::R_X86_64_PC8: { @@ -2774,7 +2836,8 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab, // Make a dynamic relocation if necessary. if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type))) { - if (gsym->may_need_copy_reloc()) + if (parameters->options().output_is_executable() + && gsym->may_need_copy_reloc()) { target->copy_reloc(symtab, layout, object, data_shndx, output_section, gsym, reloc); @@ -2869,6 +2932,7 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab, break; case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: // If the symbol is fully resolved, this is just a PC32 reloc. // Otherwise we need a PLT entry. if (gsym->final_value_is_known()) @@ -3217,6 +3281,8 @@ Target_x86_64<size>::Relocate::relocate( if (this->skip_call_tls_get_addr_) { if ((r_type != elfcpp::R_X86_64_PLT32 + && r_type != elfcpp::R_X86_64_PLT32_BND + && r_type != elfcpp::R_X86_64_PC32_BND && r_type != elfcpp::R_X86_64_PC32) || gsym == NULL || strcmp(gsym->name(), "__tls_get_addr") != 0) @@ -3261,7 +3327,9 @@ Target_x86_64<size>::Relocate::relocate( // We need to subtract the size of the GOT section to get // the actual offset to use in the relocation. bool have_got_offset = false; - unsigned int got_offset = 0; + // Since the actual offset is always negative, we use signed int to + // support 64-bit GOT relocations. + int got_offset = 0; switch (r_type) { case elfcpp::R_X86_64_GOT32: @@ -3320,6 +3388,7 @@ Target_x86_64<size>::Relocate::relocate( break; case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: Relocate_functions<size, false>::pcrela32(view, object, psymval, addend, address); break; @@ -3343,6 +3412,7 @@ Target_x86_64<size>::Relocate::relocate( break; case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: gold_assert(gsym == NULL || gsym->has_plt_offset() || gsym->final_value_is_known() @@ -3362,10 +3432,12 @@ Target_x86_64<size>::Relocate::relocate( gold_assert(gsym->has_plt_offset() || gsym->final_value_is_known()); typename elfcpp::Elf_types<size>::Elf_Addr got_address; - got_address = target->got_section(NULL, NULL)->address(); + // This is the address of GLOBAL_OFFSET_TABLE. + got_address = target->got_plt_section()->address(); Relocate_functions<size, false>::rela64(view, object, psymval, addend - got_address); } + break; case elfcpp::R_X86_64_GOT32: gold_assert(have_got_offset); @@ -4151,7 +4223,9 @@ Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc( case elfcpp::R_X86_64_32: case elfcpp::R_X86_64_32S: case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: case elfcpp::R_X86_64_GOTPC32: case elfcpp::R_X86_64_GOT32: return 4; @@ -4471,7 +4545,7 @@ class Output_data_plt_x86_64_nacl : public Output_data_plt_x86_64<size> public: Output_data_plt_x86_64_nacl(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative) : Output_data_plt_x86_64<size>(layout, plt_entry_size, got, got_plt, got_irelative) @@ -4479,7 +4553,7 @@ class Output_data_plt_x86_64_nacl : public Output_data_plt_x86_64<size> Output_data_plt_x86_64_nacl(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative, unsigned int plt_count) : Output_data_plt_x86_64<size>(layout, plt_entry_size, @@ -4552,7 +4626,7 @@ class Target_x86_64_nacl : public Target_x86_64<size> virtual Output_data_plt_x86_64<size>* do_make_data_plt(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative) { return new Output_data_plt_x86_64_nacl<size>(layout, got, got_plt, @@ -4562,7 +4636,7 @@ class Target_x86_64_nacl : public Target_x86_64<size> virtual Output_data_plt_x86_64<size>* do_make_data_plt(Layout* layout, Output_data_got<64, false>* got, - Output_data_space* got_plt, + Output_data_got_plt_x86_64* got_plt, Output_data_space* got_irelative, unsigned int plt_count) { @@ -4649,7 +4723,7 @@ Output_data_plt_x86_64_nacl<size>::first_plt_entry[plt_entry_size] = 0x41, 0xff, 0xe3, // jmpq *%r11 // 9-byte nop sequence to pad out to the next 32-byte boundary. - 0x2e, 0x0f, 0x1f, 0x84, 0, 0, 0, 0, 0, // nopl %cs:0x0(%rax,%rax,1) + 0x66, 0x0f, 0x1f, 0x84, 0, 0, 0, 0, 0, // nopw 0x0(%rax,%rax,1) // 32 bytes of nop to pad out to the standard size 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, // excess data32 prefixes diff --git a/binutils-2.25/gold/yyscript.y b/binutils-2.25/gold/yyscript.y index 51c755b..37b2670 100644 --- a/binutils-2.25/gold/yyscript.y +++ b/binutils-2.25/gold/yyscript.y @@ -1,6 +1,6 @@ /* yyscript.y -- linker script grammar for gold. */ -/* Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2006-2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. This file is part of gold. |