[lld] r250730 - Simplify by computing on relocation field at a time.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 19 12:58:19 PDT 2015


Author: rafael
Date: Mon Oct 19 14:58:18 2015
New Revision: 250730

URL: http://llvm.org/viewvc/llvm-project?rev=250730&view=rev
Log:
Simplify by computing on relocation field at a time.

Modified:
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250730&r1=250729&r2=250730&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Oct 19 14:58:18 2015
@@ -116,32 +116,34 @@ template <class ELFT> void RelocationSec
       Body = Body->repl();
 
     uint32_t Type = RI.getType(Config->Mips64EL);
-
     bool NeedsGot = Body && Target->relocNeedsGot(Type, *Body);
     bool CanBePreempted = canBePreempted(Body, NeedsGot);
-    uintX_t Addend = 0;
-    if (!CanBePreempted) {
-      if (IsRela) {
-        if (Body)
-          Addend += getSymVA<ELFT>(cast<ELFSymbolBody<ELFT>>(*Body));
-        else
-          Addend += getLocalRelTarget(File, RI);
-      }
-      P->setSymbolAndType(0, Target->getRelativeReloc(), Config->Mips64EL);
-    }
 
-    if (NeedsGot) {
-      P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);
-      if (CanBePreempted)
+    if (CanBePreempted) {
+      if (NeedsGot)
         P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
                             Target->getGotReloc(), Config->Mips64EL);
-    } else {
-      if (IsRela)
-        Addend += static_cast<const Elf_Rela &>(RI).r_addend;
-      P->r_offset = RI.r_offset + C.OutSec->getVA() + C.OutSecOff;
-      if (CanBePreempted)
+      else
         P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type,
                             Config->Mips64EL);
+    } else {
+      P->setSymbolAndType(0, Target->getRelativeReloc(), Config->Mips64EL);
+    }
+
+    if (NeedsGot)
+      P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);
+    else
+      P->r_offset = RI.r_offset + C.OutSec->getVA() + C.OutSecOff;
+
+    uintX_t Addend = 0;
+    if (IsRela && !NeedsGot)
+      Addend = static_cast<const Elf_Rela &>(RI).r_addend;
+
+    if (!CanBePreempted) {
+      if (Body)
+        Addend += getSymVA<ELFT>(cast<ELFSymbolBody<ELFT>>(*Body));
+      else
+        Addend += getLocalRelTarget(File, RI);
     }
 
     if (IsRela)




More information about the llvm-commits mailing list