[lld] r270555 - Simplify. Thanks to Rui for the suggestion.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 05:17:16 PDT 2016


Author: rafael
Date: Tue May 24 07:17:11 2016
New Revision: 270555

URL: http://llvm.org/viewvc/llvm-project?rev=270555&view=rev
Log:
Simplify. Thanks to Rui for the suggestion.

Modified:
    lld/trunk/ELF/InputSection.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=270555&r1=270554&r2=270555&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue May 24 07:17:11 2016
@@ -317,12 +317,6 @@ void InputSectionBase<ELFT>::relocate(ui
     uint64_t SymVA = SignExtend64<Bits>(
         getSymVA<ELFT>(Type, A, AddrLoc, *Rel.Sym, BufLoc, *File, Expr));
 
-    if (Expr == R_PPC_PLT_OPD) {
-      uint32_t Nop = 0x60000000;
-      if (BufLoc + 8 <= BufEnd && read32be(BufLoc + 4) == Nop)
-        write32be(BufLoc + 4, 0xe8410028); // ld %r2, 40(%r1)
-    }
-
     switch (Expr) {
     case R_RELAX_TLS_IE_TO_LE:
       Target->relaxTlsIeToLe(BufLoc, Type, SymVA);
@@ -336,6 +330,11 @@ void InputSectionBase<ELFT>::relocate(ui
     case R_RELAX_TLS_GD_TO_IE:
       Target->relaxTlsGdToIe(BufLoc, Type, SymVA);
       break;
+    case R_PPC_PLT_OPD:
+      // Patch a nop (0x60000000) to a ld.
+      if (BufLoc + 8 <= BufEnd && read32be(BufLoc + 4) == 0x60000000)
+        write32be(BufLoc + 4, 0xe8410028); // ld %r2, 40(%r1)
+      // fallthrough
     default:
       Target->relocateOne(BufLoc, Type, SymVA);
       break;




More information about the llvm-commits mailing list