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

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 08:02:50 PDT 2016


Author: atanasyan
Date: Fri May  6 10:02:50 2016
New Revision: 268742

URL: http://llvm.org/viewvc/llvm-project?rev=268742&view=rev
Log:
[ELF][MIPS] Reduce all MIPS R_GOTREL addends by MipsGPOffset in the single place. NFC

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=268742&r1=268741&r2=268742&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Fri May  6 10:02:50 2016
@@ -1453,6 +1453,7 @@ void MipsTargetInfo<ELFT>::relocateOne(u
   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(u
   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;

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=268742&r1=268741&r2=268742&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri May  6 10:02:50 2016
@@ -746,8 +746,11 @@ void Writer<ELFT>::scanRelocs(InputSecti
     // 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;
     }




More information about the llvm-commits mailing list