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.
This commit is contained in:
Vladimir Radosavljevic 2017-03-15 15:52:12 -07:00 committed by Cary Coutant
parent 1728969e93
commit 1e1247c89c
2 changed files with 25 additions and 24 deletions

View File

@ -1,26 +1,32 @@
2017-03-15 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com> 2017-03-15 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com>
* mips.cc (class Mips_output_section_options): New class. * mips.cc (Target_mips::Relocate::relocate): Remove redundant
(Target_mips::do_make_output_section): New method. checks for relocatable link.
(Mips_relocate_functions::reljalr): Likewise.
2017-03-15 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com> 2017-03-15 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com>
* mips.cc (Mips_relocate_functions::rel26): Don't print relocation * mips.cc (class Mips_output_section_options): New class.
overflow error message. (Target_mips::do_make_output_section): New method.
(Target_mips::relocate_special_relocatable): Improve relocation
overflow error message.
(Target_mips::Relocate::relocate): Likewise.
2017-03-15 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com> 2017-03-15 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com>
* mips.cc (symbol_refs_local): Return false if a symbol * mips.cc (Mips_relocate_functions::rel26): Don't print relocation
is from a dynamic object. overflow error message.
(Target_mips::got_section): Make _GLOBAL_OFFSET_TABLE_ STV_HIDDEN. (Target_mips::relocate_special_relocatable): Improve relocation
(Target_mips::set_gp): Refactor. Make _gp STT_NOTYPE and overflow error message.
STB_LOCAL. (Target_mips::Relocate::relocate): Likewise.
(Target_mips::do_finalize_sections): Set _gp after all the checks
for creating .got are done. 2017-03-15 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com>
(Target_mips::Scan::global): Remove unused code.
* 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-02-22 Alan Modra <amodra@gmail.com> 2017-02-22 Alan Modra <amodra@gmail.com>

View File

@ -4539,8 +4539,7 @@ class Mips_relocate_functions : public Relocate_functions<size, big_endian>
Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv); Valtype32 val = elfcpp::Swap<32, big_endian>::readval(wv);
// Try converting J(AL)R to B(AL), if the target is in range. // Try converting J(AL)R to B(AL), if the target is in range.
if (!parameters->options().relocatable() if (r_type == elfcpp::R_MIPS_JALR
&& r_type == elfcpp::R_MIPS_JALR
&& !cross_mode_jump && !cross_mode_jump
&& ((jalr_to_bal && val == 0x0320f809) // jalr t9 && ((jalr_to_bal && val == 0x0320f809) // jalr t9
|| (jr_to_b && val == 0x03200008))) // jr t9 || (jr_to_b && val == 0x03200008))) // jr t9
@ -11570,7 +11569,6 @@ Target_mips<size, big_endian>::Relocate::relocate(
// //
// (c) the section allows direct references to MIPS16 functions. // (c) the section allows direct references to MIPS16 functions.
if (r_type != elfcpp::R_MIPS16_26 if (r_type != elfcpp::R_MIPS16_26
&& !parameters->options().relocatable()
&& ((mips_sym != NULL && ((mips_sym != NULL
&& mips_sym->has_mips16_fn_stub() && mips_sym->has_mips16_fn_stub()
&& (r_type != elfcpp::R_MIPS16_CALL16 || mips_sym->need_fn_stub())) && (r_type != elfcpp::R_MIPS16_CALL16 || mips_sym->need_fn_stub()))
@ -11606,7 +11604,7 @@ Target_mips<size, big_endian>::Relocate::relocate(
// to a standard MIPS function, we need to redirect the call to the stub. // 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; // Note that we specifically exclude R_MIPS16_CALL16 from this behavior;
// indirect calls should use an indirect stub instead. // indirect calls should use an indirect stub instead.
else if (r_type == elfcpp::R_MIPS16_26 && !parameters->options().relocatable() else if (r_type == elfcpp::R_MIPS16_26
&& ((mips_sym != NULL && ((mips_sym != NULL
&& (mips_sym->has_mips16_call_stub() && (mips_sym->has_mips16_call_stub()
|| mips_sym->has_mips16_call_fp_stub())) || mips_sym->has_mips16_call_fp_stub()))
@ -11668,7 +11666,6 @@ Target_mips<size, big_endian>::Relocate::relocate(
// entry is used if a standard PLT entry has also been made. // entry is used if a standard PLT entry has also been made.
else if ((r_type == elfcpp::R_MIPS16_26 else if ((r_type == elfcpp::R_MIPS16_26
|| r_type == elfcpp::R_MICROMIPS_26_S1) || r_type == elfcpp::R_MICROMIPS_26_S1)
&& !parameters->options().relocatable()
&& mips_sym != NULL && mips_sym != NULL
&& mips_sym->has_plt_offset() && mips_sym->has_plt_offset()
&& mips_sym->has_comp_plt_offset() && mips_sym->has_comp_plt_offset()
@ -11697,8 +11694,7 @@ Target_mips<size, big_endian>::Relocate::relocate(
// symbol would be 16-bit code, and that direct jumps were therefore // symbol would be 16-bit code, and that direct jumps were therefore
// acceptable. // acceptable.
cross_mode_jump = cross_mode_jump =
(!parameters->options().relocatable() (!(gsym != NULL && gsym->is_weak_undefined())
&& !(gsym != NULL && gsym->is_weak_undefined())
&& ((r_type == elfcpp::R_MIPS16_26 && !target_is_16_bit_code) && ((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_MICROMIPS_26_S1 && !target_is_micromips_code)
|| ((r_type == elfcpp::R_MIPS_26 || r_type == elfcpp::R_MIPS_JALR) || ((r_type == elfcpp::R_MIPS_26 || r_type == elfcpp::R_MIPS_JALR)
@ -12252,8 +12248,7 @@ Target_mips<size, big_endian>::Relocate::relocate(
r_addend = calculated_value; r_addend = calculated_value;
} }
bool jal_shuffle = jal_reloc(r_type) ? !parameters->options().relocatable() bool jal_shuffle = jal_reloc(r_type);
: false;
Reloc_funcs::mips_reloc_shuffle(view, r_type, jal_shuffle); Reloc_funcs::mips_reloc_shuffle(view, r_type, jal_shuffle);
// Report any errors. // Report any errors.