Skip to content

Commit

Permalink
Fix finding R_NANOMIPS_PC10_S1 target
Browse files Browse the repository at this point in the history
  • Loading branch information
djolertrk committed Aug 15, 2023
1 parent bcb7f15 commit 5a7f170
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions gold/nanomips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1951,7 +1951,8 @@ class Target_nanomips : public Sized_target<size, big_endian>
generating_trampolines_(false), got_(NULL), stubs_(NULL),
rel_dyn_(NULL), copy_relocs_(elfcpp::R_NANOMIPS_COPY),
gp_(NULL), attributes_section_data_(NULL), abiflags_(NULL),
got_mod_index_offset_(-1U), has_abiflags_section_(false)
got_mod_index_offset_(-1U), has_abiflags_section_(false),
done_with_trampolines_(false)
{ }

// Make a new symbol table entry for the Nanomips target.
Expand Down Expand Up @@ -2503,6 +2504,9 @@ class Target_nanomips : public Sized_target<size, big_endian>
unsigned int got_mod_index_offset_;
// Whether there is an input .nanoMIPS.abiflags section.
bool has_abiflags_section_;
// Indicates that we are done with production of trampolines so we can do
// a final expand.
bool done_with_trampolines_;
};

template<int size, bool big_endian>
Expand Down Expand Up @@ -6040,7 +6044,7 @@ Target_nanomips<size, big_endian>::do_relax(
if (this->state_ == NO_TRANSFORM)
return false;

while (1)
while(1)
{
gold_debug(DEBUG_TARGET, "%d pass: %s", pass,
(this->state_ == RELAX ? "Relaxations" :
Expand All @@ -6062,15 +6066,21 @@ Target_nanomips<size, big_endian>::do_relax(
}

// Change the state to EXPAND if we are done with relaxations.
if (!again && (this->state_ == RELAX) && parameters->options().expand())
if (!again && (this->state_ == RELAX) &&
parameters->options().expand()){
this->state_ = EXPAND;
}
// Change the state to TRAMPOLINE.
else if (!again && this->state_ != TRAMPOLINE
&& !this->done_with_trampolines_
&& parameters->options().relax_balc_trampolines()
&& !parameters->options().insn32())
{
this->state_ = TRAMPOLINE;
}
else if (this->state_ == TRAMPOLINE
&& !this->generating_trampolines_)
&& !this->generating_trampolines_
&& !this->done_with_trampolines_)
{
gold_assert(!again);
std::map<Address, size_t> map;
Expand Down Expand Up @@ -6160,10 +6170,21 @@ Target_nanomips<size, big_endian>::do_relax(

this->generating_trampolines_ = true;
again = true;

break;
}
else if (this->state_ == TRAMPOLINE &&
!again && this->generating_trampolines_ == true)
{
this->state_ = EXPAND;
this->done_with_trampolines_ = true;
this->generating_trampolines_ = false;
again = true;
}
else
{
break;
}
}

for (Relaxed_sections::iterator p = new_relaxed_sections.begin();
Expand Down Expand Up @@ -8616,10 +8637,12 @@ Target_nanomips<size, big_endian>::Relocate::relocate(
break;
case elfcpp::R_NANOMIPS_PC10_S1:
{
auto t = target->find_balc_trampoline(address);
if (t != nullptr) {
value = t->target;
break;
if (target->is_generating_trampolines()) {
auto t = target->find_balc_trampoline(address);
if (t != nullptr) {
value = t->target;
break;
}
}
}
/* Fall through */
Expand Down

0 comments on commit 5a7f170

Please sign in to comment.