[ELF][MIPS] Reduce all MIPS R_GOTREL addends by MipsGPOffset in the single place. NFC

llvm-svn: 268742
This commit is contained in:
Simon Atanasyan 2016-05-06 15:02:50 +00:00
parent 1a728fdf5c
commit 9ac819860f
2 changed files with 7 additions and 11 deletions

View File

@ -1453,6 +1453,7 @@ void MipsTargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type,
const uint32_t DTPOffset = 0x8000;
switch (Type) {
case R_MIPS_32:
case R_MIPS_GPREL32:
write32<E>(Loc, Val);
break;
case R_MIPS_64:
@ -1466,21 +1467,13 @@ void MipsTargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type,
case R_MIPS_GOT_DISP:
case R_MIPS_GOT_PAGE:
case R_MIPS_GOT16:
case R_MIPS_GPREL16:
checkInt<16>(Val, Type);
// fallthrough
case R_MIPS_CALL16:
case R_MIPS_GOT_OFST:
writeMipsLo16<E>(Loc, Val);
break;
case R_MIPS_GPREL16: {
int64_t V = Val - MipsGPOffset;
checkInt<16>(V, Type);
writeMipsLo16<E>(Loc, V);
break;
}
case R_MIPS_GPREL32:
write32<E>(Loc, Val - MipsGPOffset);
break;
case R_MIPS_HI16:
writeMipsHi16<E>(Loc, Val);
break;

View File

@ -746,8 +746,11 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
// can process some of it and and just ask the dynamic linker to add the
// load address.
if (!Config->Pic || isStaticLinkTimeConstant<ELFT>(Expr, Type, Body)) {
if (Config->EMachine == EM_MIPS && Body.isLocal() && Expr == R_GOTREL)
Addend += File.getMipsGp0();
if (Config->EMachine == EM_MIPS && Expr == R_GOTREL) {
Addend -= MipsGPOffset;
if (Body.isLocal())
Addend += File.getMipsGp0();
}
C.Relocations.push_back({Expr, Type, Offset, Addend, &Body});
continue;
}