X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Fpowerpc.cc;h=c269ae03514bf7ef5ed89b2b8f407a9f8d9c7319;hb=7229b687db8c5fe9c1534b763dea6d1211ff3993;hp=b1c5aeaa5f53f48b522cc544b8e9821ebd4c3d7a;hpb=6f2750feaf2827ef8a1a0a5b2f90c1e9a6cabbd1;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/powerpc.cc b/gold/powerpc.cc index b1c5aeaa5f..c269ae0351 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -663,6 +663,21 @@ class Target_powerpc : 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); + // Emit relocations for a section. void relocate_relocs(const Relocate_info*, @@ -1105,19 +1120,6 @@ class Target_powerpc : public Sized_target } }; - // 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*) - { - gold_unreachable(); - return 0; - } - }; - // 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. @@ -2980,7 +2982,13 @@ Target_powerpc::do_relax(int pass, Stub_table* stub_table = static_cast*>( i->relaxed_input_section()); - off += stub_table->set_address_and_size(os, off); + Address stub_table_size = stub_table->set_address_and_size(os, off); + off += stub_table_size; + // After a few iterations, set current stub table size + // as min size threshold, so later stub tables can only + // grow in size. + if (pass >= 4) + stub_table->set_min_size_threshold(stub_table_size); } else off += i->data_size(); @@ -3632,8 +3640,8 @@ class Stub_table : public Output_relaxed_input_section targ_(targ), plt_call_stubs_(), long_branch_stubs_(), orig_data_size_(owner->current_data_size()), plt_size_(0), last_plt_size_(0), - branch_size_(0), last_branch_size_(0), eh_frame_added_(false), - need_save_res_(false) + branch_size_(0), last_branch_size_(0), min_size_threshold_(0), + eh_frame_added_(false), need_save_res_(false) { this->set_output_section(output_section); @@ -3724,6 +3732,11 @@ class Stub_table : public Output_relaxed_input_section off = align_address(off, this->stub_align()); // Include original section size and alignment padding in size my_size += off - start_off; + // Ensure new size is always larger than min size + // threshold. Alignment requirement is included in "my_size", so + // increase "my_size" does not invalidate alignment. + if (my_size < this->min_size_threshold_) + my_size = this->min_size_threshold_; this->reset_address_and_file_offset(); this->set_current_data_size(my_size); this->set_address_and_file_offset(os->address() + start_off, @@ -3749,6 +3762,9 @@ class Stub_table : public Output_relaxed_input_section plt_size() const { return this->plt_size_; } + void set_min_size_threshold(Address min_size) + { this->min_size_threshold_ = min_size; } + bool size_update() { @@ -4013,6 +4029,13 @@ class Stub_table : public Output_relaxed_input_section section_size_type orig_data_size_; // size of stubs section_size_type plt_size_, last_plt_size_, branch_size_, last_branch_size_; + // Some rare cases cause (PR/20529) fluctuation in stub table + // size, which leads to an endless relax loop. This is to be fixed + // by, after the first few iterations, allowing only increase of + // stub table size. This variable sets the minimal possible size of + // a stub table, it is zero for the first few iterations, then + // increases monotonically. + Address min_size_threshold_; // Whether .eh_frame info has been created for this stub section. bool eh_frame_added_; // Set if this stub group needs a copy of out-of-line register @@ -6430,7 +6453,9 @@ Target_powerpc::gc_process_relocs( const unsigned char* plocal_symbols) { typedef Target_powerpc Powerpc; - typedef typename Target_powerpc::Scan Scan; + typedef gold::Default_classify_reloc + Classify_reloc; + Powerpc_relobj* ppc_object = static_cast*>(object); if (size == 64) @@ -6460,8 +6485,7 @@ Target_powerpc::gc_process_relocs( return; } - gold::gc_process_relocs( + gold::gc_process_relocs( symtab, layout, this, @@ -6707,7 +6731,8 @@ Target_powerpc::scan_relocs( const unsigned char* plocal_symbols) { typedef Target_powerpc Powerpc; - typedef typename Target_powerpc::Scan Scan; + typedef gold::Default_classify_reloc + Classify_reloc; if (sh_type == elfcpp::SHT_REL) { @@ -6716,7 +6741,7 @@ Target_powerpc::scan_relocs( return; } - gold::scan_relocs( + gold::scan_relocs( symtab, layout, this, @@ -7723,6 +7748,7 @@ Target_powerpc::Relocate::relocate( && preloc != NULL && target->abiversion() >= 2 && !parameters->options().output_is_position_independent() + && rela.get_r_addend() == d_offset + 4 && gsym != NULL && strcmp(gsym->name(), ".TOC.") == 0) { @@ -8177,11 +8203,13 @@ Target_powerpc::relocate_section( typedef typename Target_powerpc::Relocate Powerpc_relocate; typedef typename Target_powerpc::Relocate_comdat_behavior Powerpc_comdat_behavior; + typedef gold::Default_classify_reloc + Classify_reloc; gold_assert(sh_type == elfcpp::SHT_RELA); - gold::relocate_section( + gold::relocate_section( relinfo, this, prelocs, @@ -8194,9 +8222,26 @@ Target_powerpc::relocate_section( reloc_symbol_changes); } +template class Powerpc_scan_relocatable_reloc { public: + typedef typename Reloc_types::Reloc + Reltype; + static const int reloc_size = + Reloc_types::reloc_size; + static const int sh_type = elfcpp::SHT_RELA; + + // Return the symbol referred to by the relocation. + static inline unsigned int + get_r_sym(const Reltype* reloc) + { return elfcpp::elf_r_sym(reloc->get_r_info()); } + + // Return the type of the relocation. + static inline unsigned int + get_r_type(const Reltype* reloc) + { return elfcpp::elf_r_type(reloc->get_r_info()); } + // Return the strategy to use for a local symbol which is not a // section symbol, given the relocation type. inline Relocatable_relocs::Reloc_strategy @@ -8244,10 +8289,11 @@ Target_powerpc::scan_relocatable_relocs( const unsigned char* plocal_symbols, Relocatable_relocs* rr) { + typedef Powerpc_scan_relocatable_reloc Scan_strategy; + gold_assert(sh_type == elfcpp::SHT_RELA); - gold::scan_relocatable_relocs( + gold::scan_relocatable_relocs( symtab, layout, object, @@ -8261,6 +8307,45 @@ Target_powerpc::scan_relocatable_relocs( rr); } +// Scan the relocs for --emit-relocs. + +template +void +Target_powerpc::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) +{ + typedef gold::Default_classify_reloc + Classify_reloc; + typedef gold::Default_emit_relocs_strategy + Emit_relocs_strategy; + + 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_syms, + rr); +} + // Emit relocations for a section. // This is a modified version of the function by the same name in // target-reloc.h. Using relocate_special_relocatable for