[lld] r265150 - Bring r264761 back with an extra fix.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 10:00:37 PDT 2016


Author: rafael
Date: Fri Apr  1 12:00:36 2016
New Revision: 265150

URL: http://llvm.org/viewvc/llvm-project?rev=265150&view=rev
Log:
Bring r264761 back with an extra fix.

The extra fix is to note that it still requires copy relocations.

Original message:

Change how we handle R_MIPS_LO16.

Mips aligns PT_LOAD to 16 bits (0x10000). That means that the lower 16
bits are always the same, so we can, effectively, say that the
relocation is relative.

P.S.: Suggestions for a better name for the predicate are welcome :-)

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=265150&r1=265149&r2=265150&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Fri Apr  1 12:00:36 2016
@@ -1722,7 +1722,7 @@ void MipsTargetInfo<ELFT>::writeThunk(ui
 
 template <class ELFT>
 bool MipsTargetInfo<ELFT>::needsCopyRelImpl(uint32_t Type) const {
-  return !isRelRelative(Type);
+  return !isRelRelative(Type) || Type == R_MIPS_LO16;
 }
 
 template <class ELFT>
@@ -1897,7 +1897,6 @@ bool MipsTargetInfo<ELFT>::isRelRelative
   case R_MIPS_32:
   case R_MIPS_64:
   case R_MIPS_HI16:
-  case R_MIPS_LO16:
   case R_MIPS_TLS_DTPREL_HI16:
   case R_MIPS_TLS_DTPREL_LO16:
   case R_MIPS_TLS_TPREL_HI16:

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=265150&r1=265149&r2=265150&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Apr  1 12:00:36 2016
@@ -445,15 +445,6 @@ void Writer<ELFT>::scanRelocs(InputSecti
     }
 
     if (Config->EMachine == EM_MIPS) {
-      if (Type == R_MIPS_LO16)
-        // Ignore R_MIPS_LO16 relocation. If it is a pair for R_MIPS_GOT16 we
-        // already completed all required action (GOT entry allocation) when
-        // handle R_MIPS_GOT16. If it is a pair for R_MIPS_HI16 against
-        // _gp_disp it does not require dynamic relocation. If its a pair for
-        // R_MIPS_HI16 against a regular symbol it does not require dynamic
-        // relocation too because that case is possible for executable file
-        // linking only.
-        continue;
       if (&Body == Config->MipsGpDisp || &Body == Config->MipsLocalGp)
         // MIPS _gp_disp designates offset between start of function and 'gp'
         // pointer into GOT. __gnu_local_gp is equal to the current value of




More information about the llvm-commits mailing list