From: Rafael Espindola Date: Tue, 26 Apr 2016 22:00:04 +0000 (+0000) Subject: Return R_GOTREL for R_MIPS_GPREL*. X-Git-Tag: llvmorg-3.9.0-rc1~7870 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1763dc44b9a450c42236e84cc9b919d0445860c8;p=platform%2Fupstream%2Fllvm.git 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 --- diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index bc846a0..0bf86c2 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -1310,6 +1310,9 @@ RelExpr MipsTargetInfo::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::relocateOne(uint8_t *Loc, uint32_t Type, writeMipsLo16(Loc, Val); break; case R_MIPS_GPREL16: { - int64_t V = Val - getMipsGpAddr(); + int64_t V = Val - MipsGPOffset; checkInt<16>(V, Type); writeMipsLo16(Loc, V); break; } case R_MIPS_GPREL32: - write32(Loc, Val - getMipsGpAddr()); + write32(Loc, Val - MipsGPOffset); break; case R_MIPS_HI16: writeMipsHi16(Loc, Val); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index eec0536..fbf173c 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -706,10 +706,8 @@ void Writer::scanRelocs(InputSectionBase &C, ArrayRef Rels) { if (!Config->Pic || Target->isRelRelative(Type) || Expr == R_PC || Expr == R_SIZE || isAbsolute(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; }