[lld] r266888 - Simplify mips gp0 handling.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 10:20:49 PDT 2016


Author: rafael
Date: Wed Apr 20 12:20:49 2016
New Revision: 266888

URL: http://llvm.org/viewvc/llvm-project?rev=266888&view=rev
Log:
Simplify mips gp0 handling.

In all currently supported cases this is a nop.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/InputSection.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=266888&r1=266887&r2=266888&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Apr 20 12:20:49 2016
@@ -206,11 +206,6 @@ getSymVA(uint32_t Type, typename ELFT::u
   case R_RELAX_TLS_IE_TO_LE:
   case R_RELAX_TLS_LD_TO_LE:
     return Body.getVA<ELFT>(A);
-  case R_MIPS_GP0:
-    // We need to adjust SymVA value in case of R_MIPS_GPREL16/32
-    // relocations because they use the following expression to calculate
-    // the relocation's result for local symbol: S + A + GP0 - G.
-    return Body.getVA<ELFT>(A) + File.getMipsGp0();
   case R_GOT_OFF:
     return Body.getGotOffset<ELFT>() + A;
   case R_MIPS_GOT_LOCAL:

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=266888&r1=266887&r2=266888&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Apr 20 12:20:49 2016
@@ -37,7 +37,6 @@ enum RelExpr {
   R_GOT_PC,
   R_MIPS_GOT,
   R_MIPS_GOT_LOCAL,
-  R_MIPS_GP0,
   R_NEG_TLS,
   R_PAGE_PC,
   R_PC,

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=266888&r1=266887&r2=266888&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Apr 20 12:20:49 2016
@@ -630,8 +630,10 @@ 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_MIPS_GP0;
+          (Type == R_MIPS_GPREL16 || Type == R_MIPS_GPREL32)) {
+        Expr = R_ABS;
+        Addend += File.getMipsGp0();
+      }
       C.Relocations.push_back({Expr, Type, Offset, Addend, &Body});
       continue;
     }




More information about the llvm-commits mailing list