Commit Graph

49 Commits

Author SHA1 Message Date
Alan Modra b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Chenghua Xu 9108bc33b1 [MIPS] Add Loongson 2K1000 proccessor support.
bfd/
	* archures.c (bfd_architecture): New machine
	bfd_mach_mips_gs264e.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Handle
	E_MIPS_MACH_GS264E.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Map bfd_mach_mips_gs264e to
	bfd_mach_mips_gs464e extension.

binutils/
	* NEWS: Mention Loongson 2K1000 proccessor support.
	* readelf.c (get_machine_flags): Handle gs264e.

elfcpp/
	* mips.c (EF_MIPS_MACH): New E_MIPS_MACH_GS264E.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Exclude CPU_GS264E.
	(mips_cpu_info_table): Add gs264e descriptors.
	* doc/as.texi (march table): Add gs264e.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): New E_MIPS_MACH_GS264E.
	* opcode/mips.h (CPU_XXX): New CPU_GS264E.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Run good_combination
	gs264e and gs464e.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs264e descriptors.
2018-08-29 20:55:25 +08:00
Chenghua Xu bd782c07b9 [MIPS] Add Loongson 3A2000/3A3000 proccessor support.
bfd/
	* archures.c (bfd_architecture): New machine
	bfd_mach_mips_gs464e.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Handle
	E_MIPS_MACH_GS464E.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Map bfd_mach_mips_gs464e to
	bfd_mach_mips_gs464 extension.

binutils/
	* NEWS: Mention Loongson 3A2000/3A3000 proccessor support.
	* readelf.c (get_machine_flags): Handle gs464e.

elfcpp/
	* mips.c (EF_MIPS_MACH): New E_MIPS_MACH_GS464E.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Exclude CPU_GS464E.
	(mips_cpu_info_table): Add gs464e descriptors.
	* doc/as.texi (march table): Add gs464e.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): New E_MIPS_MACH_GS464E.
	* opcode/mips.h (CPU_XXX): New CPU_GS464E.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Run good_combination
	gs464e and gs464.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs464e descriptors.
2018-08-29 20:43:19 +08:00
Chenghua Xu ac8cb70f36 [MIPS] Add Loongson 3A1000 proccessor support.
bfd/
	* archures.c (bfd_architecture): Rename
	bfd_mach_mips_loongson_3a to bfd_mach_mips_gs464.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Likewise.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Likewise.
	(bfd_mips_isa_ext_mach): Likewise.
	(bfd_mips_isa_ext): Likewise.
	(print_mips_isa_ext): Delete AFL_EXT_LOONGSON_3A.

binutils/
	* NEWS: Mention Loongson 3A1000 proccessor support.
	* readelf.c (get_machine_flags): Rename loongson-3a to gs464.
	(print_mips_isa_ext): Delete AFL_EXT_LOONGSON_3A.

elfcpp/
	* mips.c (EF_MIPS_MACH): Rename E_MIPS_MACH_LS3A to
	E_MIPS_MACH_GS464.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Rename
	CPU_LOONGSON_3A to CPU_GS464.
	(mips_cpu_info_table): Add gs464 descriptors, Keep
	loongson3a as an alias of gs464 for compatibility.
	* doc/as.texi (march table): Rename loongson3a to gs464.
	* testsuite/gas/mips/loongson-3a-mmi.d: Set "ISA Extension"
	flag to None.

gold/
	* mips.cc (Mips_mach, add_machine_extensions, elf_mips_mach):
	Rename loongson3a to gs464.
	(mips_isa_ext_mach, mips_isa_ext): Delete loongson3a.
	(infer_abiflags): Use ases instead of isa_ext for infer ABI
flags.
	(elf_mips_mach_name): Rename loongson3a to gs464.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): Rename E_MIPS_MACH_LS3A to
	E_MIPS_MACH_GS464.
	(AFL_EXT_XXX): Delete AFL_EXT_LOONGSON_3A.
	* opcode/mips.h (INSN_XXX): Delete INSN_LOONGSON_3A.
	(CPU_XXX): Rename CPU_LOONGSON_3A to CPU_GS464.
	* opcode/mips.h (mips_isa_table): Delete CPU_LOONGSON_3A case.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Rename loongson3a
	to gs464.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs464 descriptors, Keep
	loongson3a as an alias of gs464 for compatibility.
	* mips-opc.c (mips_opcodes): Change Comments.
2018-08-29 20:32:30 +08:00
Cary Coutant 494e49c985 Revert previous patch and apply revised patch.
Revert:

2018-04-05  James Cowgill  <james.cowgill@mips.com>

	PR gold/22770
	* mips.cc (Mips_got_info::record_got_page_entry): Fetch existing
	page entries for the object's GOT.

Apply:

	PR gold/22770
	* mips.cc (Mips_got_info::record_got_page_entry): Don't insert
	Got_page_entry for object's GOT.
	(Mips_got_info::add_got_page_entries): Add all pages from from's GOT.
	Rename to add_got_page_count.
	(Got_page_entry): Remove num_pages.
2018-04-05 09:45:07 -07:00
James Cowgill 67faf1f4c2 MIPS: Fix GOT page counter in multi-got links
The record_got_page_entry function records and updates the maximum
number of GOT page entries which may be required by an object. In the
case where an existing GOT page entry was expanded, only the entry
belonging to output GOT would have its page count updated. This leaves
the entry belonging to the object GOT with the num_pages count of 1 it
was originally initialized with. Later on when GOTs are being merged in a
multi-got link, this causes the value of entry->num_pages in
add_got_page_entries to always be 1 and underestimates the number of pages
required for the new entry. This in turn leads to an assertion failure in
get_got_page_offset where we run out of pages.

Fix by obtaining the object's GOT entry unconditionally and not just
the first time it gets created. Now that entry2 is always valid, remove
the useless NULL checks.

gold/
	PR gold/22770
	* mips.cc (Mips_got_info::record_got_page_entry): Fetch existing
	page entries for the object's GOT.
2018-04-05 08:47:53 -07:00
Cary Coutant bce5a025d2 Fix problem where mixed section types can cause internal error during a -r link.
During a -r (or --emit-relocs) link, if two sections had the same name but
different section types, gold would put relocations for both sections into
the same relocation section even though the data sections remained separate.

For .eh_frame sections, when one section is PROGBITS and another is
X86_64_UNWIND, we really should be using the UNWIND section type and
combining the sections anyway.  For other sections, we should be
creating one relocation section for each output data section.

gold/
	PR gold/23016
	* incremental.cc (can_incremental_update): Check for unwind section
	type.
	* layout.h (Layout::layout): Add sh_type parameter.
	* layout.cc (Layout::layout): Likewise.
	(Layout::layout_reloc): Create new output reloc section if data
	section does not already have one.
	(Layout::layout_eh_frame): Check for unwind section type.
	(Layout::make_eh_frame_section): Use unwind section type for .eh_frame
	and .eh_frame_hdr.
	* object.h (Sized_relobj_file::Shdr_write): New typedef.
	(Sized_relobj_file::layout_section): Add sh_type parameter.
	(Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type
	parameter.
	* object.cc (Sized_relobj_file::check_eh_frame_flags): Check for
	unwind section type.
	(Sized_relobj_file::layout_section): Add sh_type parameter; pass it
	to Layout::layout.
	(Sized_relobj_file::do_layout): Make local copy of sh_type.
	Force .eh_frame sections to unwind section type.
	Pass sh_type to layout_section.
	(Sized_relobj_file<size, big_endian>::do_layout_deferred_sections):
	Pass sh_type to layout_section.
	* output.cc (Output_section::Output_section): Initialize reloc_section_.
	* output.h (Output_section::reloc_section): New method.
	(Output_section::set_reloc_section): New method.
	(Output_section::reloc_section_): New data member.
	* target.h (Target::unwind_section_type): New method.
	(Target::Target_info::unwind_section_type): New data member.

	* aarch64.cc (aarch64_info): Add unwind_section_type.
	* arm.cc (arm_info, arm_nacl_info): Likewise.
	* i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise.
	* mips.cc (mips_info, mips_nacl_info): Likewise.
	* powerpc.cc (powerpc_info): Likewise.
	* s390.cc (s390_info): Likewise.
	* sparc.cc (sparc_info): Likewise.
	* tilegx.cc (tilegx_info): Likewise.
	* x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise.

	* testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/testfile.cc: Add unwind_section_type.
	* testsuite/pr23016_1.sh: New test script.
	* testsuite/pr23016_1a.s: New source file.
	* testsuite/pr23016_1b.s: New source file.
	* testsuite/pr23016_2.sh: New test script.
	* testsuite/pr23016_2a.s: New source file.
	* testsuite/pr23016_2b.s: New source file.
2018-04-02 19:07:04 -07:00
Alan Modra 219d1afa89 Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
H.J. Lu 104f0515d0 Gold: Fix mips.cc for GCC 4.2
GCC 4.2 fails to compile "(uint64_t) 0x800080008000" with

error: integer constant is too large for ‘long’ type

This patch adds "llu" suffix to 0x800080008000 for GCC 4.2.

	* mips.cc (Mips_relocate_functions): Add "llu" suffix to
	0x800080008000.
2017-07-26 10:43:36 -07:00
Vladimir Radosavljevic aab2c17756 Mips: Fix TLS LDM GOT entry.
gold/
	* mips.cc (Mips_got_entry::hash()): Shift addend to reduce
	possibility of collisions.
	(Mips_got_entry::equals): Fix case for GOT_TLS_LDM
	entries.
2017-03-15 16:51:35 -07:00
Vladimir Radosavljevic 4d78db49e6 Mips: Omit empty objects for merging processor-specific data.
gold/
	* mips.cc (Mips_relobj::merge_processor_specific_data_): New data
	member.
	(Mips_relobj::merge_processor_specific_data): New method.
	(Mips_relobj::do_read_symbols): Set merge_processor_specific_data_
	to false, only if the input file is a binary or if object has no
	contents except the section name string table and an empty symbol
	table with the undefined symbol.
	(Target_mips::do_finalize_sections): Refactor.  Skip empty object files
	for merging processor-specific data.
2017-03-15 16:51:35 -07:00
Vladimir Radosavljevic 152c92b261 Mips: Add support for resolving multiple consecutive relocations.
gold/
	* mips.cc (Target_mips::Relocate::calculated_value_): New data
	member.
	(Target_mips::Relocate::calculate_only_): Likewise.
	(Target_mips::Relocate::relocate): Handle multiple consecutive
	relocations with the same offset.
2017-03-15 16:51:35 -07:00
Vladimir Radosavljevic 1e1247c89c Remove redundant checks for relocatable link (MIPS).
gold/
	* mips.cc (Target_mips::Relocate::relocate): Remove redundant
	checks for relocatable link.
	(Mips_relocate_functions::reljalr): Likewise.
2017-03-15 16:51:35 -07:00
Vladimir Radosavljevic 1728969e93 Add support for .MIPS.options section.
gold/
        * mips.cc (class Mips_output_section_options): New class.
        (Target_mips::do_make_output_section): New method.
2017-03-15 16:51:35 -07:00
Vladimir Radosavljevic c3847462f8 Improve relocation overflow errors on MIPS.
gold/
        * mips.cc (Mips_relocate_functions::rel26): Don't print relocation
        overflow error message.
        (Target_mips::relocate_special_relocatable): Improve relocation
        overflow error message.
        (Target_mips::Relocate::relocate): Likewise.
2017-03-15 16:51:35 -07:00
Vladimir Radosavljevic 453018bf44 Correct the definition of _gp and _GLOBAL_OFFSET_TABLE_ symbols for MIPS.
gold/
        * mips.cc (symbol_refs_local): Return false if a symbol
        is from a dynamic object.
        (Target_mips::got_section): Make _GLOBAL_OFFSET_TABLE_ STV_HIDDEN.
        (Target_mips::set_gp): Refactor.  Make _gp STT_NOTYPE and
        STB_LOCAL.
        (Target_mips::do_finalize_sections): Set _gp after all the checks
        for creating .got are done.
        (Target_mips::Scan::global): Remove unused code.
2017-03-15 16:51:35 -07:00
Vladimir Radosavljevic f902956974 Don't give an internal error for unsupported relocations.
gold/
	* mips.cc (Target_mips::Scan::get_reference_flags): Remove
	gold_unreachable from default case.
2017-02-15 00:55:36 -08:00
Vladimir Radosavljevic e242ece1e8 Add support for R_MIPS_HIGHER/HIGHEST, R_MICROMIPS_HIGHER/HIGHEST relocations.
2017-02-15  Vladimir Radosavljevic  <Vladimir.Radosavljevic@imgtec.com>

        PR gold/21111
        * mips.cc (Mips_relocate_functions::relhigher): New method.
        (Mips_relocate_functions::relhighest): Likewise.
        (mips_get_size_for_reloc): Add support for relocs: R_MIPS_HIGHER and
        R_MIPS_HIGHEST.
        (Target_mips::Scan::local): Add support for relocs: R_MIPS_HIGHER,
        R_MIPS_HIGHEST, R_MICROMIPS_HIGHER and R_MICROMIPS_HIGHEST.
        (Target_mips::Scan::global): Likewise.
        (Target_mips::Scan::get_reference_flags): Likewise.
        (Target_mips::Relocate::relocate): Call static methods for resolving
        HIGHER and HIGHEST relocations.
2017-02-15 00:55:36 -08:00
Vladimir Radosavljevic 04bc2a2854 Make the sh_info field of .rel.plt point to .plt (MIPS).
gold/
	* mips.cc (Mips_output_data_plt::rel_plt): Remove const from return
	type.
	(Target_mips::make_plt_entry): Make the sh_info field of .rel.plt
	point to .plt.
2017-01-23 17:18:00 -08:00
Vladimir Radosavljevic c1f59f8ff9 Fix MIPS GOT when global symbols are forced to local visibility.
gold/
	PR gold/21054
	* mips.cc (Mips_got_info::record_global_got_symbol): Don't add symbol
	to the dynamic symbol table if it is forced to local visibility.
	(Target_mips::do_finalize_sections): Don't add __RLD_MAP symbol to the
	dynamic symbol table if it is forced to local visibility.
2017-01-23 17:12:10 -08:00
Alan Modra 2571583aed Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
Ambrogino Modigliani 5c3024d2c1 Fix spelling in comments in C source files (gold)
* aarch64.cc: Fix spelling in comments.
	* arm.cc: Fix spelling in comments.
	* icf.cc: Fix spelling in comments.
	* layout.cc: Fix spelling in comments.
	* layout.h: Fix spelling in comments.
	* mips.cc: Fix spelling in comments.
	* output.h: Fix spelling in comments.
	* plugin.h: Fix spelling in comments.
	* script-sections.h: Fix spelling in comments.
	* script.h: Fix spelling in comments.
	* stringpool.h: Fix spelling in comments.
	* tilegx.cc: Fix spelling in comments.
2016-11-27 15:03:06 +10:30
Alan Modra d8e9025191 [GOLD] -Wimplicit-fallthrough warning fixes
* aarch64.cc: Spell fall through comments as "// Fall through.".
	* arm.cc: Likewise.
	* mips.cc: Likewise.
	* powerpc.cc: Likewise.
	* s390.cc: Likewise.
	* sparc.cc: Likewise.
	* x86_64.cc: Likewise.
	* powerpc.cc (Target_powerpc::Relocate::relocate): Add missing
	fall through comments.
	* sparc.cc: (Target_sparc::Scan::global): Likewise.
	(Target_sparc::Relocate::relocate): Likewise.
	* tilegx.cc (Target_tilegx::Relocate::relocate): Likewise.
	* resolve.cc (symbol_to_bits): Add missing break.
2016-10-06 09:36:33 +10:30
Vladimir Radosavljevic a8ecc9fe61 Add support for MIPS .rld_map section.
Includes DT_MIPS_RLD_MAP and DT_MIPS_RLD_MAP_REL dynamic tags and
__RLD_MAP symbol.

2016-06-20  Vladimir Radosavljevic  <Vladimir.Radosavljevic@imgtec.com>

elfcpp/
        * elfcpp.h (DT_MIPS_RLD_MAP_REL): New enum constant.
gold/
        * mips.cc (Target_mips::Target_mips): Initialize rld_map_.
        (Target_mips::rld_map_): New data member.
        (Target_mips::do_finalize_sections): Add support for
        DT_MIPS_RLD_MAP and DT_MIPS_RLD_MAP_REL dynamic tags,
        .rld_map section, and __RLD_MAP symbol.
        (Target_mips::do_dynamic_tag_custom_value): Add support for
        DT_MIPS_RLD_MAP_REL dynamic tag.
        * output.cc (Output_data_dynamic::get_entry_offset): New method
        definition.
        * output.h (Output_data_dynamic::get_entry_offset): New method
        declaration.
2016-06-20 12:16:26 -07:00
Vladimir Radosavljevic beceef5043 Add unaligned check for R_MIPS_PC16.
gold/
        * mips.cc (Mips_relocate_functions::relpc16): Add unaligned check.
2016-06-20 12:06:56 -07:00
Vladimir Radosavljevic f5b117594f Add support for Mips32r6 and Mips64r6.
elfcpp/
	* mips.h (R_MIPS_PC21_S2, R_MIPS_PC26_S2, R_MIPS_PC18_S3,
	R_MIPS_PC19_S2, R_MIPS_PCHI16, R_MIPS_PCLO16): New enums for
	Mips32r6 and Mips64r6 relocations.
	(r6_isa): New function.
gold/
	* mips.cc (relocation_needs_la25_stub): Add support for relocs:
	R_MIPS_PC21_S2 and R_MIPS_PC26_S2.
	(hi16_reloc): Add support for R_MIPS_PCHI16 relocation.
	(is_matching_lo16_reloc): Likewise.
	(lo16_reloc): Add support for R_MIPS_PCLO16 relocation.
	(Mips_output_data_plt::plt_entry_r6): New static data member for
	R6 PLT entry.
	(Target_mips::is_output_r6): New method.
	(Target_mips::Mips_mach): Add new enum constants.
	(Mips_relocate_functions::Status): Likewise.
	(Mips_relocate_functions::pchi16_relocs): New static data member.
	(Mips_relocate_functions::relpc21): New method.
	(Mips_relocate_functions::relpc26): Likewise.
	(Mips_relocate_functions::relpc18): Likewise.
	(Mips_relocate_functions::relpc19): Likewise.
	(Mips_relocate_functions::relpchi16): Likewise.
	(Mips_relocate_functions::do_relpchi16): Likewise.
	(Mips_relocate_functions::relpclo16): Likewise.
	(Mips_output_data_plt::do_write): Add support for Mips r6 plt
	entry.
	(Target_mips::mips_32bit_flags): Add E_MIPS_ARCH_32R6 support.
	(Target_mips::elf_mips_mach): Add E_MIPS_ARCH_32R6 and
	E_MIPS_ARCH_64R6 support.
	(Target_mips::update_abiflags_isa): Likewise.
	(mips_get_size_for_reloc): Add support for relocs: R_MIPS_PCHI16,
	R_MIPS_PCLO16, R_MIPS_PC21_S2, R_MIPS_PC26_S2, R_MIPS_PC18_S3 and
	R_MIPS_PC19_S2.
	(Target_mips::Scan::local): Add support for relocs: R_MIPS_PCHI16
	and R_MIPS_PCLO16.
	(Target_mips::Scan::global): Add support for relocs:
	R_MIPS_PC21_S2 and R_MIPS_PC26_S2.
	(Target_mips::Relocate::relocate): Call functions for resolving
	Mips32r6 and Mips64r6 relocations, and print error message for
	STATUS_PCREL_UNALIGNED.
	(Target_mips::Scan::get_reference_flags): Add support for relocs:
	R_MIPS_PCHI16, R_MIPS_PCLO16, R_MIPS_PC21_S2, R_MIPS_PC26_S2,
	R_MIPS_PC18_S3 and R_MIPS_PC19_S2.
	(Target_mips::elf_mips_mach_name): Add E_MIPS_ARCH_32R6 and
	E_MIPS_ARCH_64R6 support.
2016-06-20 11:45:18 -07:00
Vladimir Radosavljevic b52717c0e1 Add support for .MIPS.abiflags and .gnu.attributes sections.
elfcpp/
	* elfcpp.h (SHT_MIPS_ABIFLAGS): New enum constant.
	* mips.h (EF_MIPS_FP64, EF_MIPS_NAN2008): New enum constants for
	processor-specific flags.
	(E_MIPS_MACH_5900): New enum constant for machine variant.
	(AFL_REG_NONE, AFL_REG_32, AFL_REG_64, AFL_REG_128): New enum
	constants.
	(AFL_ASE_DSP, AFL_ASE_DSPR2, AFL_ASE_EVA, AFL_ASE_MCU,
	AFL_ASE_MDMX, AFL_ASE_MIPS3D, AFL_ASE_MT, AFL_ASE_SMARTMIPS,
	AFL_ASE_VIRT, AFL_ASE_MSA, AFL_ASE_MIPS16, AFL_ASE_MICROMIPS,
	AFL_ASE_XPA): Likewise.
	(AFL_EXT_XLR, AFL_EXT_OCTEON2, AFL_EXT_OCTEONP,
	AFL_EXT_LOONGSON_3A, AFL_EXT_OCTEON, AFL_EXT_5900, AFL_EXT_4650,
	AFL_EXT_4010, AFL_EXT_4100, AFL_EXT_3900, AFL_EXT_10000,
	AFL_EXT_SB1, AFL_EXT_4111, AFL_EXT_4120, AFL_EXT_5400,
	AFL_EXT_5500, AFL_EXT_LOONGSON_2E, AFL_EXT_LOONGSON_2F,
	AFL_EXT_OCTEON3): Likewise.
	(Tag_GNU_MIPS_ABI_FP, Tag_GNU_MIPS_ABI_MSA): Likewise.
	(Val_GNU_MIPS_ABI_FP_ANY, Val_GNU_MIPS_ABI_FP_DOUBLE,
	Val_GNU_MIPS_ABI_FP_SINGLE, Val_GNU_MIPS_ABI_FP_SOFT,
	Val_GNU_MIPS_ABI_FP_OLD_64,Val_GNU_MIPS_ABI_FP_XX,
	Val_GNU_MIPS_ABI_FP_64, Val_GNU_MIPS_ABI_FP_64A,
	Val_GNU_MIPS_ABI_FP_NAN2008, Val_GNU_MIPS_ABI_MSA_ANY,
	Val_GNU_MIPS_ABI_MSA_128): Likewise.
	(AFL_FLAGS1_ODDSPREG): New enum constant.
gold/
	* mips.cc (struct Mips_abiflags): New struct.
	(Mips_relobj::Mips_relobj): Initialize attributes_section_data_
	and abiflags_.
	(Mips_relobj::~Mips_relobj): Delete object pointed by
	attributes_section_data_.
	(Mips_relobj::abiflags): New method.
	(Mips_relobj::attributes_section_data): Likewise.
	(Mips_relobj::attributes_section_data_): New data member.
	(Mips_relobj::abiflags_): Likewise.
	(class Mips_output_section_abiflags): New class.
	(Target_mips::Target_mips): Initialize attributes_section_data_,
	abiflags_ and has_abiflags_section_.
	(Target_mips::do_should_include_section): Don't emit input
	.MIPS.abiflags sections to output .MIPS.abiflags.
	(Target_mips::Mips_mach): Add new enum constants.
	(Target_mips::mips_isa_ext_mach): New method.
	(Target_mips::mips_isa_ext): Likewise.
	(Target_mips::update_abiflags_isa): Likewise.
	(Target_mips::infer_abiflags): Likewise.
	(Target_mips::create_abiflags): Likewise.
	(Target_mips::fp_abi_string): Likewise.
	(Target_mips::select_fp_abi): Likewise.
	(Target_mips::merge_obj_attributes): Likewise.
	(Target_mips::merge_obj_abiflags): Likewise.
	(Target_mips::level_rev): Likewise.
	(Target_mips::merge_obj_e_flags): Rename from
	merge_processor_specific_flags. Remove dyn_obj argument,
	call update_abiflags_isa when needed, compare NaN encodings and
	compare FP64 state.
	(Target_mips::add_machine_extensions): Add two machine extensions
	and fix one.
	(Target_mips::attributes_section_data_): New data member.
	(Target_mips::abiflags_): Likewise.
	(Target_mips::has_abiflags_section_): Likewise.
	(Mips_relobj::do_read_symbols): Read .gnu.attributes and
	.MIPS.abiflags sections if they exists.
	(Target_mips::elf_mips_mach): Add E_MIPS_MACH_5900 and
	E_MIPS_MACH_OCTEON3 support.
	(Target_mips::do_adjust_elf_header): Setup EI_ABIVERSION flag.
	(Target_mips::do_finalize_sections): Merge .gnu.attributes and
	.MIPS.abiflags sections from input. Create these sections if
	needed.
	(Target_mips::elf_mips_mach_name): Add E_MIPS_MACH_5900 and
	E_MIPS_MACH_OCTEON3 support, and change strings for
	E_MIPS_MACH_LS2E, E_MIPS_MACH_LS2F and E_MIPS_MACH_LS3A just
	to match bfd.
2016-06-11 10:09:59 -07:00
Vladimir Radosavljevic 82e498727a Fix problems emitting MIPS .reginfo section.
gold/
	* mips.cc (Mips_relobj::Mips_relobj): Initialize
	has_reginfo_section_.
	(Mips_relobj::has_reginfo_section_): New data member.
	(Mips_relobj::has_reginfo_section): New method.
	(class Mips_output_section_reginfo): Change base class to
	Output_section_data, and set masks of the output .reginfo section
	in constructor.
	(Mips_output_section_reginfo::as_mips_output_section_reginfo):
	Remove.
	(Mips_output_section_reginfo::set_masks): Likewise.
	(Mips_output_section_reginfo::set_final_data_size): Likewise.
	(Mips_output_section_reginfo::do_print_to_mapfile): New method.
	(Target_mips::do_make_output_section): Remove.
	(Mips_relobj::do_read_symbols): Set has_reginfo_section_ to true
	if the object contains a .reginfo section.
	(Target_mips::do_finalize_sections): Create a .reginfo output
	section if needed.
2016-06-10 15:37:19 -07:00
Artemiy Volkov a080d84da0 Fix compilation error in mips.cc with some versions of GCC.
gold/
	* mips.cc (Mips_output_data_got::do_write): Add missing template
	args via typedef.
2016-06-09 11:39:57 -07:00
Cary Coutant 6eeb0170bb Don't allow COPY relocations for protected symbols.
gold/
	PR gold/19823
	* copy-relocs.cc (Copy_relocs::make_copy_reloc): Add object
	parameter; check for protected symbol.
	* copy-relocs.h (Copy_relocs::make_copy_reloc): Add object parameter.
	* mips.cc (Mips_copy_relocs): Adjust call to make_copy_reloc.
	* symtab.cc (Symbol::init_fields): Initialize is_protected_.
	(Symbol_table::add_from_dynobj): Mark protected symbols.
	* symtab.h (Symbol::is_protected): New method.
	(Symbol::set_is_protected): New method.
	(Symbol::is_protected_): New data member.

	* testsuite/Makefile.am (copy_test_protected): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/copy_test.cc (main): Add legal reference to protected
	symbol.
	* testsuite/copy_test_v1.cc (main): Likewise.
	* testsuite/copy_test_2.cc (ip): Add protected symbol.
	* testsuite/copy_test_protected.cc: New test source file.
	* testsuite/copy_test_protected.sh: New test script.
2016-05-19 15:05:03 -07:00
Vladimir Radosavljevic 15eb1bebe1 Fix non-deterministic behavior when generating MIPS GOT.
* mips.cc (Mips_got_entry::Mips_got_entry): Remove object argument
	for global got symbols, and set addend to 0.
	(Mips_got_entry::hash): Change hash algorithm.
	(Mips_got_entry::equals): Refactor.
	(Mips_got_entry::object): Return input object for local got symbols
	from union d.
	(Mips_got_entry::addend): Change return of the relocation addend.
	(Mips_got_entry::addend_): Move from union d.
	(Mips_got_entry::object_): Move into union d.
	(class Mips_symbol_hash): New class.
	(Mips_got_info::Global_got_entry_set): New type.
	(Mips_got_info::global_got_symbols): Change return type to
	Global_got_entry_set.
	(Mips_got_info::global_got_symbols_): Change type to
	Global_got_entry_set.
	(Mips_symbol::hash): New method.
	(Mips_output_data_la25_stub::symbols_): Change type to std::vector.
	(Mips_output_data_mips_stubs::Mips_stubs_entry_set): New type.
	(Mips_output_data_mips_stubs::symbols_): Change type to
	Mips_stubs_entry_set.
	(Mips_got_info::record_global_got_symbol): Don't pass object
	argument when creating global got symbol.
	(Mips_got_info::record_got_entry): Remove find before inserting
	got entries.
	(Mips_got_info::add_reloc_only_entries): Change type of iterator
	to Global_got_entry_set.
	(Mips_got_info::count_got_symbols): Likewise.
	(Mips_output_data_la25_stub::create_la25_stub): Use push_back
	for adding entries to symbols_.
	(Mips_output_data_la25_stub::do_write): Change type of iterator
	to std::vector.
	(Mips_output_data_mips_stubs::set_lazy_stub_offsets): Change type
	of iterator to Mips_stubs_entry_set.
	(Mips_output_data_mips_stubs::set_needs_dynsym_value): Likewise.
	(Mips_output_data_mips_stubs::do_write): Likewise.
2016-05-19 15:04:51 -07:00
Vladimir Radosavljevic 01b84e2553 Remove is_n64_ data member from Mips_relobj class.
elfcpp/
	* mips.h (abi_64): Remove.

gold/
	* mips.cc (Mips_relobj::is_n64_): Remove.
	(Target_mips::ei_class_): Likewise.
	(Mips_relobj::is_newabi): Call methods.
	(Mips_relobj::is_n64): Change checking for N64 ABI.
	(Target_mips::is_output_n64): Likewise.
	(Target_mips::merge_processor_specific_flags): Remove ei_class
	argument, and remove comparing ei_class.
	(Target_mips::do_adjust_elf_header): Remove setting EI_CLASS field
	of the ELF header.
	(Target_mips::do_finalize_sections): Don't pass ei_class argument
	to merge_processor_specific_flags.
	(Target_mips::elf_mips_abi_name): Remove ei_class argument, and
	change checking for N64 ABI.
2016-03-18 14:54:35 -07:00
Vladimir Radosavljevic 47a9f4fcab Add MIPS-64 support.
gold/
	* mips.cc (enum Special_relocation_symbol): New enum type.
	(is_readonly_section): New function.
	(eh_reloc): Likewise.
	(Mips_got_entry::is_section_symbol_): New member.
	(Mips_got_entry::is_section_symbol): New method.
	(Mips_got_info::record_local_got_symbol): Add is_section_symbol
	argument.
	(Mips_relobj::mips_elf_options_section_name): New method.
	(Mips_output_data_got::record_local_got_symbol): Add
	is_section_symbol argument, and pass it to
	Mips_got_info::record_local_got_symbol.
	(Mips_output_data_got::got_offset): Add addend argument, and pass
	it to Relobj::local_got_offset.
	(struct Mips_output_reloc_writer): New type.
	(class Mips_output_data_reloc): New class.
	(Mips_output_data_plt::Reloc_section): Change type to
	Mips_output_data_reloc.
	(Target_mips::Reloc_section): Likewise.
	(Mips_reloc_types::get_r_addend): Remove unsigned from return type.
	(Mips_classify_reloc::get_r_type2): New method.
	(Mips_classify_reloc::get_r_type3): Likewise.
	(Mips_classify_reloc::get_r_ssym): Likewise.
	(Target_mips::Reloca_section): Remove.
	(Relocate::should_apply_static_reloc): Rename from
	should_apply_r_mips_32_reloc.
	(Target_mips::copy_reloc): Replace Reltype parameter with r_type
	and r_offset.
	(Mips_relocate_functions::Valtype): New type.
	(Mips_relocate_functions::Valtype64): New type.
	(Mips_relocate_functions::check_overflow): New method.
	(Mips_relocate_functions::mips_reloc_unshuffle): Move to public
	interface.
	(Mips_relocate_functions::mips_reloc_shuffle): Likewise.
	(Mips_relocate_functions::rel16): Add support for resolving
	relocations for Mips64.
	(Mips_relocate_functions::rel32): Likewise.
	(Mips_relocate_functions::reljalr): Likewise.
	(Mips_relocate_functions::relpc32): Likewise.
	(Mips_relocate_functions::rel26): Likewise.
	(Mips_relocate_functions::relpc16): Likewise.
	(Mips_relocate_functions::relmicromips_pc7_s1): Likewise.
	(Mips_relocate_functions::relmicromips_pc10_s1): Likewise.
	(Mips_relocate_functions::relmicromips_pc16_s1): Likewise.
	(Mips_relocate_functions::do_relhi16): Likewise.
	(Mips_relocate_functions::do_relgot16_local): Likewise.
	(Mips_relocate_functions::rello16): Likewise.
	(Mips_relocate_functions::relgot): Likewise.
	(Mips_relocate_functions::relgotpage): Likewise.
	(Mips_relocate_functions::relgotofst): Likewise.
	(Mips_relocate_functions::relgot_hi16): Likewise.
	(Mips_relocate_functions::relgot_lo16): Likewise.
	(Mips_relocate_functions::relgprel): Likewise.
	(Mips_relocate_functions::relgprel32): Likewise.
	(Mips_relocate_functions::tlsrelhi16): Likewise.
	(Mips_relocate_functions::tlsrello16): Likewise.
	(Mips_relocate_functions::tlsrel32): Likewise.
	(Mips_relocate_functions::relsub): Likewise.
	(Mips_relocate_functions::releh): New method.
	(Mips_relocate_functions::rel64): Likewise.
	(Mips_got_info::record_local_got_symbol): Add is_section_symbol and
	pass it to Mips_got_entry.
	(Mips_got_info::add_local_entries): Pass addend argument
	to code functions, and for STT_SECTION symbols call
	add_symbolless_local_addend.
	(Mips_got_info::add_tls_entries): Pass addend argument to code
	functions.
	(Mips_relobj::do_read_symbols): Read gp value that was used to
	create object.
	(Mips_output_data_plt::plt_entry): Remove opcode from l[wd]
	instruction. Opcode for instruction will be selected later.
	(Target_mips::gc_process_relocs): Add case for SHT_RELA.
	(Target_mips::scan_relocatable_relocs): Likewise.
	(Target_mips::emit_relocs_scan): Likewise.
	(Target_mips::relocate_relocs): Likewise.
	(Target_mips::do_finalize_sections): Skip objects for merging
	processor specific flags in which all input sections will be
	discarded.
	(mips_get_size_for_reloc): Add case for R_MIPS_EH.
	(Target_mips::Scan::get_reference_flags): Likewise.
	(Target_mips::relocate_special_relocatable): Call rel26 method with
	calculate_only and calculated_value arguments.
	(Target_mips::Scan::local): Add case for R_MIPS_EH. Don't create a
	dynamic relocation against a readonly sections, and pass
	is_section_symbol to Mips_got_info::record_local_got_symbol.
	(Target_mips::Scan::global): Add case for R_MIPS_EH. Don't create a
	dynamic relocation against a readonly sections, and pass r_type
	and r_offset to Target_mips::copy_reloc.
	(Target_mips::Relocate::relocate): Add support for resolving
	relocations for Mips64.
	(Target_mips::mips_info): Add case for Mips64 default dynamic
	linker name.
	(Target_selector_mips): Correct emulation names.
2016-03-17 15:07:49 -07:00
Vladimir Radosavljevic 1a08ae216c Add missing Mips_output_data_la25_stub::do_print_to_mapfile.
gold/
	* mips.cc (class Mips_output_data_la25_stub): Add
	do_print_to_mapfile function.
2016-03-17 14:27:48 -07:00
Vladimir Radosavljevic c2fa9cedff Fix problem with --emit-relocs for Mips-32.
gold/
	* mips.cc (Mips_classify_reloc::put_r_info): Call 32bit version of
	elf_r_info.
2016-03-17 14:26:50 -07:00
Cary Coutant dc1c8a16a3 Add support for STT_SPARC_REGISTER symbols.
gold/
	PR gold/19019
	* layout.h (Layout::add_target_specific_dynamic_tag): New function.
	* layout.cc (Layout::add_target_specific_dynamic_tag): New function.
	* mips.cc (Target_mips::make_symbol): Adjust function signature.
	* sparc.cc (Target_sparc::Target_sparc): Initialize register_syms_.
	(Target_sparc::do_is_defined_by_abi): Remove test for
	STT_SPARC_REGISTER.
	(Target_sparc::Register_symbol): New struct type.
	(Target_sparc::register_syms_): New data member.
	(Target_sparc<64, true>::sparc_info): Set has_make_symbol to true.
	(Target_sparc::make_symbol): New function.
	(Target_sparc::do_finalize_sections): Add register symbols and new
	dynamic table entries.
	* symtab.h (Sized_symbol::init_undefined): Add value parameter.
	(Symbol_table::add_target_global_symbol): New function.
	(Symbol_table::target_symbols_): New data member.
	* symtab.cc (Sized_symbol::init_undefined): Add value parameter.
	(Symbol_table::Symbol_table): Initialize target_symbols_.
	(Symbol_table::add_from_object): Pass additional parameters to
	Target::make_symbol.
	(Symbol_table::define_special_symbol): Likewise.
	(Symbol_table::add_undefined_symbol_from_command_line): Pass 0 for
	undefined symbol value.
	(Symbol_table::set_dynsym_indexes): Process target-specific symbols.
	(Symbol_table::sized_finalize): Likewise.
	(Symbol_table::sized_write_globals): Likewise.
	* target.h (Sized_target::make_symbol): Add name, st_type, object,
	st_shndx, and value parameters.
2016-03-03 18:19:53 -08:00
Cary Coutant 8a8880cb67 Fix breakage for SHT_REL targets where get_r_addend() gives internal error.
gold/
	* arm.cc (Target_arm::Classify_reloc::get_r_addend): New method.
	* i386.cc (Target_i386::Classify_reloc::get_r_addend): New method.
	* mips.cc (Target_arm::Mips_classify_reloc::get_r_addend): (Both
	specializations) New method.
2016-01-12 11:39:50 -08:00
Cary Coutant 4d625b70fc Refactor gold to enable support for MIPS-64 relocation format.
For MIPS-64, the r_info field in the relocation format is
replaced by several individual fields, including r_sym and
r_type. To enable support for this format, I've refactored
target-independent code to remove almost all uses of the r_info
field. (I've left alone a couple of routines used only for
incremental linking, which I can update if/when the MIPS target
adds support for incremental linking.)

For routines that are already templated on a Classify_reloc class
(namely, gc_process_relocs, relocate_section, and
relocate_relocs), I've extended the Classify_reloc interface to
include sh_type (which no longer needs to be a separate template
parameter) as well as get_r_sym() and get_r_type() methods for
extracting the r_sym and r_type fields. For
scan_relocatable_relocs, I've extended the
Default_scan_relocatable_relocs class by converting it to a class
template with Classify_reloc as a template parameter. For the
remaining routines that need to access r_sym, I've added a
virtual Target::get_r_sym() method with an override for the MIPS
target.

In elfcpp, I've added Mips64_rel, etc., accessor classes and
corresponding internal data structures. The MIPS target uses
these new classes within its own Mips_classify_reloc class.
The Mips64_ accessor classes also expose the r_ssym, r_type2,
and r_type3 fields from the relocation.

These changes should be functionally the same for all but the
MIPS target.

elfcpp/
	* elfcpp.h (Mips64_rel, Mips64_rel_write): New classes.
	(Mips64_rela, Mips64_rela_write): New classes.
	* elfcpp_internal.h (Mips64_rel_data, Mips64_rela_data): New structs.

gold/
	* gc.h (get_embedded_addend_size): Remove sh_type parameter.
	(gc_process_relocs): Remove sh_type template parameter.
	Use Classify_reloc to access r_sym, r_type, and r_addend fields.
	* object.h (Sized_relobj_file::split_stack_adjust): Add target
	parameter.
	(Sized_relobj_file::split_stack_adjust_reltype): Likewise.
	* reloc-types.h (Reloc_types::copy_reloc_addend): (SHT_REL and SHT_RELA
	specializations) Remove.
	* reloc.cc (Emit_relocs_strategy): Rename and move to target-reloc.h.
	(Sized_relobj_file::emit_relocs_scan): Call Target::emit_relocs_scan().
	(Sized_relobj_file::emit_relocs_scan_reltype): Remove.
	(Sized_relobj_file::split_stack_adjust): Add target parameter.
	Adjust all callers.
	(Sized_relobj_file::split_stack_adjust_reltype): Likewise. Call
	Target::get_r_sym() to get r_sym field from relocations.
	(Track_relocs::next_symndx): Call Target::get_r_sym().
	* target-reloc.h (scan_relocs): Remove sh_type template parameter;
	add Classify_reloc template parameter.  Use for accessing r_sym and
	r_type.
	(relocate_section): Likewise.
	(Default_classify_reloc): New class (renamed and moved from reloc.cc).
	(Default_scan_relocatable_relocs): Remove sh_type template parameter.
	(Default_scan_relocatable_relocs::Reltype): New typedef.
	(Default_scan_relocatable_relocs::reloc_size): New const.
	(Default_scan_relocatable_relocs::sh_type): New const.
	(Default_scan_relocatable_relocs::get_r_sym): New method.
	(Default_scan_relocatable_relocs::get_r_type): New method.
	(Default_emit_relocs_strategy): New class.
	(scan_relocatable_relocs): Replace sh_type template parameter with
	Scan_relocatable_relocs class.  Use it to access r_sym and r_type
	fields.
	(relocate_relocs): Replace sh_type template parameter with
	Classify_reloc class.  Use it to access r_sym and r_type fields.
	* target.h (Target::is_call_to_non_split): Replace r_type parameter
	with pointer to relocation. Adjust all callers.
	(Target::do_is_call_to_non_split): Likewise.
	(Target::emit_relocs_scan): New virtual method.
	(Sized_target::get_r_sym): New virtual method.
	* target.cc (Target::do_is_call_to_non_split): Replace r_type parameter
	with pointer to relocation.

	* aarch64.cc (Target_aarch64::emit_relocs_scan): New method.
	(Target_aarch64::Relocatable_size_for_reloc): Remove.
	(Target_aarch64::gc_process_relocs): Use Default_classify_reloc.
	(Target_aarch64::scan_relocs): Likewise.
	(Target_aarch64::relocate_section): Likewise.
	(Target_aarch64::Relocatable_size_for_reloc::get_size_for_reloc):
	Remove.
	(Target_aarch64::scan_relocatable_relocs): Use Default_classify_reloc.
	(Target_aarch64::relocate_relocs): Use Default_classify_reloc.
	* arm.cc (Target_arm::Arm_scan_relocatable_relocs): Remove sh_type
	template parameter.
	(Target_arm::emit_relocs_scan): New method.
	(Target_arm::Relocatable_size_for_reloc): Replace with...
	(Target_arm::Classify_reloc): ...this.
	(Target_arm::gc_process_relocs): Use Classify_reloc.
	(Target_arm::scan_relocs): Likewise.
	(Target_arm::relocate_section): Likewise.
	(Target_arm::scan_relocatable_relocs): Likewise.
	(Target_arm::relocate_relocs): Likewise.
	* i386.cc (Target_i386::emit_relocs_scan): New method.
	(Target_i386::Relocatable_size_for_reloc): Replace with...
	(Target_i386::Classify_reloc): ...this.
	(Target_i386::gc_process_relocs): Use Classify_reloc.
	(Target_i386::scan_relocs): Likewise.
	(Target_i386::relocate_section): Likewise.
	(Target_i386::scan_relocatable_relocs): Likewise.
	(Target_i386::relocate_relocs): Likewise.
	* mips.cc (Mips_scan_relocatable_relocs): Remove sh_type template
	parameter.
	(Mips_reloc_types): New class template.
	(Mips_classify_reloc): New class template.
	(Target_mips::Reltype): New typedef.
	(Target_mips::Relatype): New typedef.
	(Target_mips::emit_relocs_scan): New method.
	(Target_mips::get_r_sym): New method.
	(Target_mips::Relocatable_size_for_reloc): Replace with
	Mips_classify_reloc.
	(Target_mips::copy_reloc): Use Mips_classify_reloc.
	(Target_mips::gc_process_relocs): Likewise.
	(Target_mips::scan_relocs): Likewise.
	(Target_mips::relocate_section): Likewise.
	(Target_mips::scan_relocatable_relocs): Likewise.
	(Target_mips::relocate_relocs): Likewise.
	(mips_get_size_for_reloc): New function, factored out from
	Relocatable_size_for_reloc::get_size_for_reloc.
	(Target_mips::Scan::local): Use Mips_classify_reloc.
	(Target_mips::Scan::global): Likewise.
	(Target_mips::Relocate::relocate): Likewise.
	* powerpc.cc (Target_powerpc::emit_relocs_scan): New method.
	(Target_powerpc::Relocatable_size_for_reloc): Remove.
	(Target_powerpc::gc_process_relocs): Use Default_classify_reloc.
	(Target_powerpc::scan_relocs): Likewise.
	(Target_powerpc::relocate_section): Likewise.
	(Powerpc_scan_relocatable_reloc): Convert to class template.
	(Powerpc_scan_relocatable_reloc::Reltype): New typedef.
	(Powerpc_scan_relocatable_reloc::reloc_size): New const.
	(Powerpc_scan_relocatable_reloc::sh_type): New const.
	(Powerpc_scan_relocatable_reloc::get_r_sym): New method.
	(Powerpc_scan_relocatable_reloc::get_r_type): New method.
	(Target_powerpc::scan_relocatable_relocs): Use
	Powerpc_scan_relocatable_reloc.
	(Target_powerpc::relocate_relocs): Use Default_classify_reloc.
	* s390.cc (Target_s390::emit_relocs_scan): New method.
	(Target_s390::Relocatable_size_for_reloc): Remove.
	(Target_s390::gc_process_relocs): Use Default_classify_reloc.
	(Target_s390::scan_relocs): Likewise.
	(Target_s390::relocate_section): Likewise.
	(Target_s390::Relocatable_size_for_reloc::get_size_for_reloc):
	Remove.
	(Target_s390::scan_relocatable_relocs): Use Default_classify_reloc.
	(Target_s390::relocate_relocs): Use Default_classify_reloc.
	* sparc.cc (Target_sparc::emit_relocs_scan): New method.
	(Target_sparc::Relocatable_size_for_reloc): Remove.
	(Target_sparc::gc_process_relocs): Use Default_classify_reloc.
	(Target_sparc::scan_relocs): Likewise.
	(Target_sparc::relocate_section): Likewise.
	(Target_sparc::Relocatable_size_for_reloc::get_size_for_reloc):
	Remove.
	(Target_sparc::scan_relocatable_relocs): Use Default_classify_reloc.
	(Target_sparc::relocate_relocs): Use Default_classify_reloc.
	* tilegx.cc (Target_tilegx::emit_relocs_scan): New method.
	(Target_tilegx::Relocatable_size_for_reloc): Remove.
	(Target_tilegx::gc_process_relocs): Use Default_classify_reloc.
	(Target_tilegx::scan_relocs): Likewise.
	(Target_tilegx::relocate_section): Likewise.
	(Target_tilegx::Relocatable_size_for_reloc::get_size_for_reloc):
	Remove.
	(Target_tilegx::scan_relocatable_relocs): Use Default_classify_reloc.
	(Target_tilegx::relocate_relocs): Use Default_classify_reloc.
	* x86_64.cc (Target_x86_64::emit_relocs_scan): New method.
	(Target_x86_64::Relocatable_size_for_reloc): Remove.
	(Target_x86_64::gc_process_relocs): Use Default_classify_reloc.
	(Target_x86_64::scan_relocs): Likewise.
	(Target_x86_64::relocate_section): Likewise.
	(Target_x86_64::Relocatable_size_for_reloc::get_size_for_reloc):
	Remove.
	(Target_x86_64::scan_relocatable_relocs): Use Default_classify_reloc.
	(Target_x86_64::relocate_relocs): Use Default_classify_reloc.

	* testsuite/testfile.cc (Target_test::emit_relocs_scan): New method.
2016-01-11 18:51:18 -08:00
Alan Modra 6f2750feaf Copyright update for binutils 2016-01-01 23:00:01 +10:30
Alan Modra 91a65d2fe8 [GOLD] Relocate::relocate() params
Some linker code editing needs to change multiple insns.  In some
cases multiple relocations are involved and it is not sufficient to
make the changes independently as relocations are processed, because
doing so might lead to a partial edit.  So in order to safely edit we
need all the relocations available in relocate().  Also, to emit
edited relocs corresponding to the edited code sequence we need some
way to pass information from relocate() to relocate_relocs(),
particularly if the edit depends on insns.  We can't modify input
relocs in relocate() as they are mmapped PROT_READ, nor it is
particularly clean to write relocs to the output at that stage.  So
add a Relocatable_relocs* field to relinfo to mark edited relocs.

Given that relocate is passed the raw reloc pointer, it makes sense to
remove the rel/rela parameter and r_type too.  However, that means the
mips relocate() needs to know whether SHT_REL or SHT_RELA relocs are
being processed.  So add a rel_type for mips, which also has the
benefit of removing relocate() overloading there.

This patch adds the infrastructure without making use of it.

Note that relinfo->rr will be NULL if not outputting relocations.

	* object.h (struct Relocate_info): Add "rr".
	* reloc.h (Relocatable_relocs::set_strategy): New accessor.
	* reloc.cc (Sized_relobj_file::do_relocate_sections): Init
	relinfo.rr for relocate_section and relocate_relocs.
	* powerpc.cc (relocate): Add rel_type and preloc parameters.
	Delete rela and r_type params, instead recalculate these from
	preloc.
	(relocate_relocs): Delete Relocatable_relocs* param, instead
	use relinfo->rr.
	* aarch64.cc: Likewise.
	* arm.cc: Likewise.
	* i386.cc: Likewise.
	* mips.cc: Likewise.
	* s390.cc: Likewise.
	* sparc.cc: Likewise.
	* target.h: Likewise.
	* tilegx.cc: Likewise.
	* x86_64.cc: Likewise.
	* testsuite/testfile.cc: Likewise.
	* target-reloc.h (relocate_section): Adjust to suit.
	(apply_relocation, relocate_relocs): Likewise.
2015-12-09 10:36:43 +10:30
Cary Coutant 859d79870d Remove unnecessary target dependencies on relocation format.
2015-11-09  Cary Coutant  <ccoutant@gmail.com>
	    Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com>

gold/
	* copy-relocs.h (Copy_relocs::copy_reloc): Replace reloc parameter
	with type, offset, addend.
	(Copy_relocs::save): Likewise.
	* copy-relocs.cc (Copy_relocs::copy_reloc): Likewise.
	(Copy_relocs::save): Likewise.
	* aarch64.cc (Target_aarch64::copy_reloc): Pass r_type, r_offset,
	and r_addend to Copy_relocs::copy_reloc.
	* arm.cc (Target_arm::copy_reloc): Likewise.
	* i386.cc (Target_i386::copy_reloc): Likewise.
	* mips.cc (Target_mips::copy_reloc): Likewise.
	* powerpc.cc (Target_powerpc::copy_reloc): Likewise.
	* s390.cc (Target_s390::copy_reloc): Likewise.
	* sparc.cc (Target_sparc::copy_reloc): Likewise.
	* tilegx.cc (Target_tilegx::copy_reloc): Likewise.
	* x86_64.cc (Target_x86_64::copy_reloc): Likewise.
2015-11-09 10:33:37 -08:00
Marcin Kościelnicki 8d9743bd43 Support 64-bit entry size in SHT_HASH (for s390).
gold/
	* dynobj.cc (Dynobj::create_elf_hash_table): Create hash table with
	target-specific entry size.
	(Dynobj::sized_create_elf_hash_table): Add size template parameter.
	* dynobj.h (Dynobj::sized_create_elf_hash_table): Likewise.
	* layout.cc (Layout::create_dynamic_symtab): Set entsize to
	hash_entry_size.
	* target.h (Target::hash_entry_size): New method.
	(Target::Target_info::hash_entry_size): New data member.

	* aarch64.cc (Target_aarch64::aarch64_info): Add hash_entry_size.
	* arm.cc (Target_arm::arm_info): Likewise.
	(Target_arm_nacl::arm_nacl_info): Likewise.
	* i386.cc (Target_i386::i386_info): Likewise.
	(Target_i386_nacl::i386_nacl_info): Likewise.
	(Target_iamcu::iamcu_info): Likewise.
	* mips.cc (Target_mips::mips_info): Likewise.
	(Target_mips_nacl::mips_nacl_info): Likewise.
	* powerpc.cc (Target_powerpc::powerpc_info): Likewise.
	* sparc.cc (Target_sparc::sparc_info): Likewise.
	* tilegx.cc (Target_tilegx::tilegx_info): Likewise.
	* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
	(Target_x86_64_nacl::x86_64_nacl_info): Likewise.
	* testsuite/testfile.cc (Target_test::test_target_info): Likewise.
2015-10-28 16:45:37 -07:00
Simon Dardis 40fc1451c6 [MIPS] Map 'move' to 'or'.
The MIPS assembly idiom 'move' now maps to the 'or' machine instruction. This
change affects microMIPS, MIPS32, MIPS64.

2015-08-12  Simon Dardis  <simon.dardis@imgtec.com>

opcodes/

	* micromips-opc.c (micromips_opcodes): Re-order table so that move
	based on 'or' is first.
	* mips-opc.c (mips_builtin_opcodes): Ditto.

bfd/

	* elfxx-mips.c (STUB_MOVE): Change to use 'or' only.
	(mips_o32_exec_plt0_entry, mips_n32_exec_plt0_entry,
	mips_n64_exec_plt0_entry, micromips_insn32_o32_exec_plt0_entry):
	Update to use 'or' instead of 'addu/daddu'.
	(_bfd_mips_elf_finish_dynamic_symbol): Update usage of STUB_MOVE.
	(move_insns_32): Reorder table.

gas/

	* config/tc-mips.c (move_register): Change to use 'or' only.
	(s_cpload, s_cpsetup, s_cprestore, s_cpreturn): Update to
	use or for move.

gas/testsuite/

	* gas/mips/elf-rel23.d: Update test.
	* gas/mips/elf-rel23.d: Ditto.
	* gas/mips/elf-rel23a.d: Ditto.
	* gas/mips/elf-rel23b.d: Ditto.
	* gas/mips/elf_e_flags1.d: Ditto.
	* gas/mips/elf_e_flags2.d: Ditto.
	* gas/mips/elf_e_flags3.d: Ditto.
	* gas/mips/elf_e_flags4.d: Ditto.
	* gas/mips/loc-swap-dis.d: Ditto.
	* gas/mips/micromips-insn32.d: Ditto.
	* gas/mips/micromips-noinsn32.d: Ditto.
	* gas/mips/micromips-trap.d: Ditto.
	* gas/mips/micromips.d: Ditto.
	* gas/mips/mips-abi32-pic.d: Ditto.
	* gas/mips/mips-abi32.d: Ditto.
	* gas/mips/mips-gp32-fp32-pic.d: Ditto.
	* gas/mips/mips-gp32-fp32.d: Ditto.
	* gas/mips/mips-gp32-fp64-pic.d: Ditto.
	* gas/mips/mips-gp32-fp64.d: Ditto.
	* gas/mips/mips-gp64-fp32-pic.d: Ditto.
	* gas/mips/mips-gp64-fp32.d: Ditto.
	* gas/mips/mips-gp64-fp64-pic.d: Ditto.
	* gas/mips/mips-gp64-fp64.d: Ditto.
	* gas/mips/mipsr6@loc-swap-dis.d: Ditto.
	* gas/mips/tls-o32.d: Ditto.
	* gas/mips/uld2-eb.d: Ditto.
	* gas/mips/uld2-el.d: Ditto.
	* gas/mips/ulw2-eb-ilocks.d: Ditto.
	* gas/mips/ulw2-eb.d: Ditto.
	* gas/mips/ulw2-el-ilocks.d: Ditto.
	* gas/mips/ulw2-el.d: Ditto.
	* gas/mips/move.d: New test.
	* gas/mips/move.s: Ditto.
	* gas/mips/micromips32-move.d: Ditto.
	* gas/mips/micromips32-move.s: Ditto.
	* gas/mips/mips.exp: Run the new tests.

gold/

	* mips.cc (plt0_entry_o32, plt0_entry_n32, plt0_entry_n64,
	lazy_stub_normal_1, lazy_stub_normal_1_n64,
	lazy_stub_normal_2, lazy_stub_normal_2_n64, lazy_stub_big,
	lazy_stub_big_n64, lazy_stub_micromips32_normal_1_n64,
	lazy_stub_micromips32_normal_2_n64, lazy_stub_micromips32_big,
	lazy_stub_micromips32_big_n64): Update to use 'or' for move instead
	of 'addu/daddu'.

ld/testsuite/

	* ld-mips-elf/compressed-plt-1-n32-mips16.od: Update test.
	* ld-mips-elf/compressed-plt-1-n32-umips.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-got.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-only.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-word.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-se.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips-got.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips-word.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips.od: Ditto.
	* ld-mips-elf/jalx-2.dd: Ditto.
	* ld-mips-elf/mips16-pic-3.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-3a.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-3b.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-5b.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-6-n32.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-6-o32.dd: Ditto.
	* ld-mips-elf/stub-dynsym-1-10000.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-2fe80.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-7fff.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-8000.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-fff0.d: Ditto.
	* ld-mips-elf/tlsbin-o32.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-1.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-2.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-3.d: Ditto.
	* ld-mips-elf/tlsdyn-o32.d: Ditto.
	* ld-mips-elf/tlslib-o32.d: Ditto.
2015-08-12 17:10:22 +01:00
Cary Coutant 3d0064a95d Fix a bug in resolving HI16/LO16 relocation pairs for MIPS.
2015-01-14  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
	* mips.cc (reloc_high): Add r_sym.
	(Mips_relocate_functions::relhi16): Add r_sym parameter. Pass r_sym to
	reloc_high constructor.
	(Mips_relocate_functions::relgot16_local): Likewise.
	(Mips_relocate_functions::rello16): Add r_sym parameter. Use r_sym and
	r_type to decide whether LO16 matches HI16.
	(Target_mips::Relocate::relocate): Pass r_sym to calls to relhi16,
	rello16 and relgot16_local.
2015-01-14 10:30:14 -08:00
Alan Modra b90efa5b79 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
Sasa Stankovic 62661c935d Add NaCl (NativeClient) specific classes Target_mips_nacl and
Target_selector_mips_nacl.

gold/
	* 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-03 09:44:11 -07:00
Cary Coutant f35c4853cc Fix internal error with LTO on ARM.
This prevents the target-specific do_read_symbols methods from being called
twice when do_layout_deferred_sections needs to layout an .eh_frame section.

gold/
	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-08 10:44:09 -07:00
Sasa Stankovic 9810d34d76 gold/
* 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-23 12:02:10 -07:00