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.
This commit is contained in:
parent
cdf436294f
commit
3d0064a95d
2 changed files with 28 additions and 13 deletions
|
@ -1,3 +1,14 @@
|
||||||
|
2015-01-14 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
|
||||||
|
|
||||||
|
* 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-09 Cary Coutant <ccoutant@google.com>
|
2015-01-09 Cary Coutant <ccoutant@google.com>
|
||||||
|
|
||||||
* layout.cc (Layout::set_segment_offsets): Don't align start of segment
|
* layout.cc (Layout::set_segment_offsets): Don't align start of segment
|
||||||
|
|
30
gold/mips.cc
30
gold/mips.cc
|
@ -3761,11 +3761,11 @@ struct reloc_high
|
||||||
|
|
||||||
reloc_high(unsigned char* _view, const Mips_relobj<size, big_endian>* _object,
|
reloc_high(unsigned char* _view, const Mips_relobj<size, big_endian>* _object,
|
||||||
const Symbol_value<size>* _psymval, Mips_address _addend,
|
const Symbol_value<size>* _psymval, Mips_address _addend,
|
||||||
unsigned int _r_type, bool _extract_addend,
|
unsigned int _r_type, unsigned int _r_sym, bool _extract_addend,
|
||||||
Mips_address _address = 0, bool _gp_disp = false)
|
Mips_address _address = 0, bool _gp_disp = false)
|
||||||
: view(_view), object(_object), psymval(_psymval), addend(_addend),
|
: view(_view), object(_object), psymval(_psymval), addend(_addend),
|
||||||
r_type(_r_type), extract_addend(_extract_addend), address(_address),
|
r_type(_r_type), r_sym(_r_sym), extract_addend(_extract_addend),
|
||||||
gp_disp(_gp_disp)
|
address(_address), gp_disp(_gp_disp)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unsigned char* view;
|
unsigned char* view;
|
||||||
|
@ -3773,6 +3773,7 @@ struct reloc_high
|
||||||
const Symbol_value<size>* psymval;
|
const Symbol_value<size>* psymval;
|
||||||
Mips_address addend;
|
Mips_address addend;
|
||||||
unsigned int r_type;
|
unsigned int r_type;
|
||||||
|
unsigned int r_sym;
|
||||||
bool extract_addend;
|
bool extract_addend;
|
||||||
Mips_address address;
|
Mips_address address;
|
||||||
bool gp_disp;
|
bool gp_disp;
|
||||||
|
@ -4266,11 +4267,12 @@ class Mips_relocate_functions : public Relocate_functions<size, big_endian>
|
||||||
relhi16(unsigned char* view, const Mips_relobj<size, big_endian>* object,
|
relhi16(unsigned char* view, const Mips_relobj<size, big_endian>* object,
|
||||||
const Symbol_value<size>* psymval, Mips_address addend,
|
const Symbol_value<size>* psymval, Mips_address addend,
|
||||||
Mips_address address, bool gp_disp, unsigned int r_type,
|
Mips_address address, bool gp_disp, unsigned int r_type,
|
||||||
bool extract_addend)
|
unsigned int r_sym, bool extract_addend)
|
||||||
{
|
{
|
||||||
// Record the relocation. It will be resolved when we find lo16 part.
|
// Record the relocation. It will be resolved when we find lo16 part.
|
||||||
hi16_relocs.push_back(reloc_high<size, big_endian>(view, object, psymval,
|
hi16_relocs.push_back(reloc_high<size, big_endian>(view, object, psymval,
|
||||||
addend, r_type, extract_addend, address, gp_disp));
|
addend, r_type, r_sym, extract_addend, address,
|
||||||
|
gp_disp));
|
||||||
return This::STATUS_OKAY;
|
return This::STATUS_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4331,11 +4333,11 @@ class Mips_relocate_functions : public Relocate_functions<size, big_endian>
|
||||||
relgot16_local(unsigned char* view,
|
relgot16_local(unsigned char* view,
|
||||||
const Mips_relobj<size, big_endian>* object,
|
const Mips_relobj<size, big_endian>* object,
|
||||||
const Symbol_value<size>* psymval, Mips_address addend_a,
|
const Symbol_value<size>* psymval, Mips_address addend_a,
|
||||||
bool extract_addend, unsigned int r_type)
|
bool extract_addend, unsigned int r_type, unsigned int r_sym)
|
||||||
{
|
{
|
||||||
// Record the relocation. It will be resolved when we find lo16 part.
|
// Record the relocation. It will be resolved when we find lo16 part.
|
||||||
got16_relocs.push_back(reloc_high<size, big_endian>(view, object, psymval,
|
got16_relocs.push_back(reloc_high<size, big_endian>(view, object, psymval,
|
||||||
addend_a, r_type, extract_addend));
|
addend_a, r_type, r_sym, extract_addend));
|
||||||
return This::STATUS_OKAY;
|
return This::STATUS_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4377,7 +4379,7 @@ class Mips_relocate_functions : public Relocate_functions<size, big_endian>
|
||||||
const Mips_relobj<size, big_endian>* object,
|
const Mips_relobj<size, big_endian>* object,
|
||||||
const Symbol_value<size>* psymval, Mips_address addend_a,
|
const Symbol_value<size>* psymval, Mips_address addend_a,
|
||||||
bool extract_addend, Mips_address address, bool is_gp_disp,
|
bool extract_addend, Mips_address address, bool is_gp_disp,
|
||||||
unsigned int r_type)
|
unsigned int r_type, unsigned int r_sym)
|
||||||
{
|
{
|
||||||
mips_reloc_unshuffle(view, r_type, false);
|
mips_reloc_unshuffle(view, r_type, false);
|
||||||
Valtype32* wv = reinterpret_cast<Valtype32*>(view);
|
Valtype32* wv = reinterpret_cast<Valtype32*>(view);
|
||||||
|
@ -4392,7 +4394,8 @@ class Mips_relocate_functions : public Relocate_functions<size, big_endian>
|
||||||
while (it != hi16_relocs.end())
|
while (it != hi16_relocs.end())
|
||||||
{
|
{
|
||||||
reloc_high<size, big_endian> hi16 = *it;
|
reloc_high<size, big_endian> hi16 = *it;
|
||||||
if (hi16.psymval->value(hi16.object, 0) == psymval->value(object, 0))
|
if (hi16.r_sym == r_sym
|
||||||
|
&& is_matching_lo16_reloc(hi16.r_type, r_type))
|
||||||
{
|
{
|
||||||
if (do_relhi16(hi16.view, hi16.object, hi16.psymval, hi16.addend,
|
if (do_relhi16(hi16.view, hi16.object, hi16.psymval, hi16.addend,
|
||||||
hi16.address, hi16.gp_disp, hi16.r_type,
|
hi16.address, hi16.gp_disp, hi16.r_type,
|
||||||
|
@ -4411,7 +4414,8 @@ class Mips_relocate_functions : public Relocate_functions<size, big_endian>
|
||||||
while (it2 != got16_relocs.end())
|
while (it2 != got16_relocs.end())
|
||||||
{
|
{
|
||||||
reloc_high<size, big_endian> got16 = *it2;
|
reloc_high<size, big_endian> got16 = *it2;
|
||||||
if (got16.psymval->value(got16.object, 0) == psymval->value(object, 0))
|
if (got16.r_sym == r_sym
|
||||||
|
&& is_matching_lo16_reloc(got16.r_type, r_type))
|
||||||
{
|
{
|
||||||
if (do_relgot16_local(got16.view, got16.object, got16.psymval,
|
if (do_relgot16_local(got16.view, got16.object, got16.psymval,
|
||||||
got16.addend, got16.r_type,
|
got16.addend, got16.r_type,
|
||||||
|
@ -9908,7 +9912,7 @@ Target_mips<size, big_endian>::Relocate::relocate(
|
||||||
case elfcpp::R_MIPS16_HI16:
|
case elfcpp::R_MIPS16_HI16:
|
||||||
case elfcpp::R_MICROMIPS_HI16:
|
case elfcpp::R_MICROMIPS_HI16:
|
||||||
reloc_status = Reloc_funcs::relhi16(view, object, psymval, r_addend,
|
reloc_status = Reloc_funcs::relhi16(view, object, psymval, r_addend,
|
||||||
address, gp_disp, r_type,
|
address, gp_disp, r_type, r_sym,
|
||||||
extract_addend);
|
extract_addend);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -9918,7 +9922,7 @@ Target_mips<size, big_endian>::Relocate::relocate(
|
||||||
case elfcpp::R_MICROMIPS_HI0_LO16:
|
case elfcpp::R_MICROMIPS_HI0_LO16:
|
||||||
reloc_status = Reloc_funcs::rello16(target, view, object, psymval,
|
reloc_status = Reloc_funcs::rello16(target, view, object, psymval,
|
||||||
r_addend, extract_addend, address,
|
r_addend, extract_addend, address,
|
||||||
gp_disp, r_type);
|
gp_disp, r_type, r_sym);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case elfcpp::R_MIPS_LITERAL:
|
case elfcpp::R_MIPS_LITERAL:
|
||||||
|
@ -10033,7 +10037,7 @@ Target_mips<size, big_endian>::Relocate::relocate(
|
||||||
else
|
else
|
||||||
reloc_status = Reloc_funcs::relgot16_local(view, object, psymval,
|
reloc_status = Reloc_funcs::relgot16_local(view, object, psymval,
|
||||||
r_addend, extract_addend,
|
r_addend, extract_addend,
|
||||||
r_type);
|
r_type, r_sym);
|
||||||
update_got_entry = changed_symbol_value;
|
update_got_entry = changed_symbol_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue