[lld] r267613 - Return R_GOTREL for R_MIPS_GPREL*.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 26 15:00:04 PDT 2016
Author: rafael
Date: Tue Apr 26 17:00:04 2016
New Revision: 267613
URL: http://llvm.org/viewvc/llvm-project?rev=267613&view=rev
Log:
Return R_GOTREL for R_MIPS_GPREL*.
This lets Writer.cpp know that they are got relative, which will allow
further simplifications.
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=267613&r1=267612&r2=267613&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Apr 26 17:00:04 2016
@@ -1310,6 +1310,9 @@ RelExpr MipsTargetInfo<ELFT>::getRelExpr
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(u
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);
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=267613&r1=267612&r2=267613&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Apr 26 17:00:04 2016
@@ -706,10 +706,8 @@ void Writer<ELFT>::scanRelocs(InputSecti
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;
}
More information about the llvm-commits
mailing list