Return R_GOTREL for R_MIPS_GPREL*.

This lets Writer.cpp know that they are got relative, which will allow
further simplifications.

llvm-svn: 267613
This commit is contained in:
Rafael Espindola 2016-04-26 22:00:04 +00:00
parent 90931c4853
commit 1763dc44b9
2 changed files with 6 additions and 5 deletions

View File

@ -1310,6 +1310,9 @@ RelExpr MipsTargetInfo<ELFT>::getRelExpr(uint32_t Type,
switch (Type) {
default:
return R_ABS;
case R_MIPS_GPREL16:
case R_MIPS_GPREL32:
return R_GOTREL;
case R_MIPS_26:
return R_PLT;
case R_MIPS_HI16:
@ -1520,13 +1523,13 @@ void MipsTargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type,
writeMipsLo16<E>(Loc, Val);
break;
case R_MIPS_GPREL16: {
int64_t V = Val - getMipsGpAddr<ELFT>();
int64_t V = Val - MipsGPOffset;
checkInt<16>(V, Type);
writeMipsLo16<E>(Loc, V);
break;
}
case R_MIPS_GPREL32:
write32<E>(Loc, Val - getMipsGpAddr<ELFT>());
write32<E>(Loc, Val - MipsGPOffset);
break;
case R_MIPS_HI16:
writeMipsHi16<E>(Loc, Val);

View File

@ -706,10 +706,8 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
if (!Config->Pic || Target->isRelRelative(Type) || Expr == R_PC ||
Expr == R_SIZE || isAbsolute<ELFT>(Body)) {
if (Config->EMachine == EM_MIPS && Body.isLocal() &&
(Type == R_MIPS_GPREL16 || Type == R_MIPS_GPREL32)) {
Expr = R_ABS;
(Type == R_MIPS_GPREL16 || Type == R_MIPS_GPREL32))
Addend += File.getMipsGp0();
}
C.Relocations.push_back({Expr, Type, Offset, Addend, &Body});
continue;
}