X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Ftilegx.cc;h=03b1a509c5a8b48f2da78163a2e8ff97c82984f6;hb=128e85e3ab36b8e30f6612fb50de3cbb4ede6824;hp=c1945872d601112e6849b618060fb54ff025ab0f;hpb=4b95cf5c0c75d6efc1b2f96af72317aecca079f1;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/tilegx.cc b/gold/tilegx.cc index c1945872d6..03b1a509c5 100644 --- a/gold/tilegx.cc +++ b/gold/tilegx.cc @@ -1,6 +1,6 @@ // tilegx.cc -- tilegx target support for gold. -// Copyright (C) 2012-2014 Free Software Foundation, Inc. +// Copyright (C) 2012-2016 Free Software Foundation, Inc. // Written by Jiong Wang (jiwang@tilera.com) // This file is part of gold. @@ -308,6 +308,21 @@ class Target_tilegx : public Sized_target const unsigned char* plocal_symbols, Relocatable_relocs*); + // Scan the relocs for --emit-relocs. + void + emit_relocs_scan(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file* 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_syms, + Relocatable_relocs* rr); + // Relocate a section during a relocatable link. void relocate_relocs( @@ -317,7 +332,6 @@ class Target_tilegx : public Sized_target size_t reloc_count, Output_section* output_section, typename elfcpp::Elf_types::Elf_Off offset_in_output_section, - const Relocatable_relocs*, unsigned char* view, typename elfcpp::Elf_types::Elf_Addr view_address, section_size_type view_size, @@ -517,22 +531,11 @@ class Target_tilegx : public Sized_target // Do a relocation. Return false if the caller should not issue // any warnings about this relocation. inline bool - relocate(const Relocate_info*, Target_tilegx*, - Output_section*, - size_t relnum, const elfcpp::Rela&, - unsigned int r_type, const Sized_symbol*, - const Symbol_value*, - unsigned char*, typename elfcpp::Elf_types::Elf_Addr, - 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*); + relocate(const Relocate_info*, unsigned int, + Target_tilegx*, Output_section*, size_t, const unsigned char*, + const Sized_symbol*, const Symbol_value*, + unsigned char*, typename elfcpp::Elf_types::Elf_Addr, + section_size_type); }; // Adjust TLS relocation type based on the options and whether this @@ -594,10 +597,13 @@ class Target_tilegx : public Sized_target unsigned int shndx, Output_section* output_section, Symbol* sym, const elfcpp::Rela& reloc) { + unsigned int r_type = elfcpp::elf_r_type(reloc.get_r_info()); this->copy_relocs_.copy_reloc(symtab, layout, symtab->get_sized_symbol(sym), object, shndx, output_section, - reloc, this->rela_dyn_section(layout)); + r_type, reloc.get_r_offset(), + reloc.get_r_addend(), + this->rela_dyn_section(layout)); } // Information about this specific target which we pass to the @@ -680,7 +686,8 @@ const Target::Target_info Target_tilegx<64, false>::tilegx_info = 0, // large_common_section_flags NULL, // attributes_section NULL, // attributes_vendor - "_start" // entry_symbol_name + "_start", // entry_symbol_name + 32, // hash_entry_size }; template<> @@ -707,7 +714,8 @@ const Target::Target_info Target_tilegx<32, false>::tilegx_info = 0, // large_common_section_flags NULL, // attributes_section NULL, // attributes_vendor - "_start" // entry_symbol_name + "_start", // entry_symbol_name + 32, // hash_entry_size }; template<> @@ -734,7 +742,8 @@ const Target::Target_info Target_tilegx<64, true>::tilegx_info = 0, // large_common_section_flags NULL, // attributes_section NULL, // attributes_vendor - "_start" // entry_symbol_name + "_start", // entry_symbol_name + 32, // hash_entry_size }; template<> @@ -761,7 +770,8 @@ const Target::Target_info Target_tilegx<32, true>::tilegx_info = 0, // large_common_section_flags NULL, // attributes_section NULL, // attributes_vendor - "_start" // entry_symbol_name + "_start", // entry_symbol_name + 32, // hash_entry_size }; // tilegx relocation handlers @@ -3758,7 +3768,8 @@ Target_tilegx::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 +3843,8 @@ Target_tilegx::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); @@ -4148,26 +4160,26 @@ Target_tilegx::gc_process_relocs(Symbol_table* symtab, { typedef Target_tilegx Tilegx; typedef typename Target_tilegx::Scan Scan; + typedef gold::Default_classify_reloc + Classify_reloc; if (sh_type == elfcpp::SHT_REL) { return; } - gold::gc_process_relocs::Relocatable_size_for_reloc>( - symtab, - layout, - this, - object, - data_shndx, - prelocs, - reloc_count, - output_section, - needs_special_offset_handling, - local_symbol_count, - plocal_symbols); + gold::gc_process_relocs( + 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. @@ -4187,6 +4199,8 @@ Target_tilegx::scan_relocs(Symbol_table* symtab, { typedef Target_tilegx Tilegx; typedef typename Target_tilegx::Scan Scan; + typedef gold::Default_classify_reloc + Classify_reloc; if (sh_type == elfcpp::SHT_REL) { @@ -4195,7 +4209,7 @@ Target_tilegx::scan_relocs(Symbol_table* symtab, return; } - gold::scan_relocs( + gold::scan_relocs( symtab, layout, this, @@ -4318,11 +4332,11 @@ template inline bool Target_tilegx::Relocate::relocate( const Relocate_info* relinfo, + unsigned int, Target_tilegx* target, Output_section*, size_t relnum, - const elfcpp::Rela& rela, - unsigned int r_type, + const unsigned char* preloc, const Sized_symbol* gsym, const Symbol_value* psymval, unsigned char* view, @@ -4335,6 +4349,8 @@ Target_tilegx::Relocate::relocate( typedef Tilegx_relocate_functions TilegxReloc; typename TilegxReloc::Tilegx_howto r_howto; + const elfcpp::Rela rela(preloc); + unsigned int r_type = elfcpp::elf_r_type(rela.get_r_info()); const Sized_relobj_file* object = relinfo->object; // Pick the value to use for symbols defined in the PLT. @@ -4412,6 +4428,7 @@ Target_tilegx::Relocate::relocate( psymval = &symval; always_apply_relocation = true; addend = 0; + // Fall through. // when under PIC mode, these relocations are deferred to rtld case elfcpp::R_TILEGX_IMM16_X0_HW0: @@ -4602,6 +4619,7 @@ Target_tilegx::Relocate::relocate( got_type = GOT_TYPE_TLS_OFFSET; have_got_offset = true; } + // Fall through. do_update_value: if (have_got_offset) { if (gsym != NULL) { @@ -4631,10 +4649,8 @@ Target_tilegx::Relocate::relocate( } // else if (opt_t == tls::TLSOPT_TO_LE) // both GD/IE are turned into LE, which // is absolute relocation. - // - // | go through - // | - // V + // Fall through. + // LE // // tp @@ -4735,11 +4751,13 @@ Target_tilegx::relocate_section( { typedef Target_tilegx Tilegx; typedef typename Target_tilegx::Relocate Tilegx_relocate; + typedef gold::Default_classify_reloc + Classify_reloc; gold_assert(sh_type == elfcpp::SHT_RELA); - gold::relocate_section( + gold::relocate_section( relinfo, this, prelocs, @@ -4780,24 +4798,50 @@ Target_tilegx::apply_relocation( view_size); } -// Return the size of a relocation while scanning during a relocatable -// link. +// Scan the relocs during a relocatable link. template -unsigned int -Target_tilegx::Relocatable_size_for_reloc::get_size_for_reloc( - unsigned int, Relobj*) +void +Target_tilegx::scan_relocatable_relocs( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file* 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) { - // We are always SHT_RELA, so we should never get here. - gold_unreachable(); - return 0; + typedef gold::Default_classify_reloc + Classify_reloc; + typedef gold::Default_scan_relocatable_relocs + Scan_relocatable_relocs; + + gold_assert(sh_type == elfcpp::SHT_RELA); + + gold::scan_relocatable_relocs( + symtab, + layout, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols, + rr); } -// Scan the relocs during a relocatable link. +// Scan the relocs for --emit-relocs. template void -Target_tilegx::scan_relocatable_relocs( +Target_tilegx::emit_relocs_scan( Symbol_table* symtab, Layout* layout, Sized_relobj_file* object, @@ -4808,16 +4852,17 @@ Target_tilegx::scan_relocatable_relocs( Output_section* output_section, bool needs_special_offset_handling, size_t local_symbol_count, - const unsigned char* plocal_symbols, + const unsigned char* plocal_syms, Relocatable_relocs* rr) { - gold_assert(sh_type == elfcpp::SHT_RELA); + typedef gold::Default_classify_reloc + Classify_reloc; + typedef gold::Default_emit_relocs_strategy + Emit_relocs_strategy; - typedef gold::Default_scan_relocatable_relocs Scan_relocatable_relocs; + gold_assert(sh_type == elfcpp::SHT_RELA); - gold::scan_relocatable_relocs( + gold::scan_relocatable_relocs( symtab, layout, object, @@ -4827,7 +4872,7 @@ Target_tilegx::scan_relocatable_relocs( output_section, needs_special_offset_handling, local_symbol_count, - plocal_symbols, + plocal_syms, rr); } @@ -4842,22 +4887,23 @@ Target_tilegx::relocate_relocs( size_t reloc_count, Output_section* output_section, typename elfcpp::Elf_types::Elf_Off offset_in_output_section, - const Relocatable_relocs* rr, unsigned char* view, typename elfcpp::Elf_types::Elf_Addr view_address, section_size_type view_size, unsigned char* reloc_view, section_size_type reloc_view_size) { + typedef gold::Default_classify_reloc + Classify_reloc; + gold_assert(sh_type == elfcpp::SHT_RELA); - gold::relocate_relocs( + gold::relocate_relocs( relinfo, prelocs, reloc_count, output_section, offset_in_output_section, - rr, view, view_address, view_size,