[lld] dc884f0 - [ELF] Remove RelocationScanner::target. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 16 12:39:45 PDT 2022


Author: Fangrui Song
Date: 2022-10-16T12:39:37-07:00
New Revision: dc884f0f4354164e06cdcd30b56fd88dff2b382f

URL: https://github.com/llvm/llvm-project/commit/dc884f0f4354164e06cdcd30b56fd88dff2b382f
DIFF: https://github.com/llvm/llvm-project/commit/dc884f0f4354164e06cdcd30b56fd88dff2b382f.diff

LOG: [ELF] Remove RelocationScanner::target. NFC

Added: 
    

Modified: 
    lld/ELF/Relocations.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 8264e3728a55..8727e17c3f37 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -444,7 +444,6 @@ class RelocationScanner {
 private:
   InputSectionBase *sec;
   OffsetGetter getter;
-  const TargetInfo &target = *elf::target;
 
   // End of relocations, used by Mips/PPC64.
   const void *end = nullptr;
@@ -491,7 +490,7 @@ int64_t RelocationScanner::computeMipsAddend(const RelTy &rel, RelExpr expr,
   for (const RelTy *ri = &rel; ri != static_cast<const RelTy *>(end); ++ri)
     if (ri->getType(config->isMips64EL) == pairTy &&
         ri->getSymbol(config->isMips64EL) == symIndex)
-      return target.getImplicitAddend(buf + ri->r_offset, pairTy);
+      return target->getImplicitAddend(buf + ri->r_offset, pairTy);
 
   warn("can't find matching " + toString(pairTy) + " relocation for " +
        toString(type));
@@ -511,7 +510,7 @@ int64_t RelocationScanner::computeAddend(const RelTy &rel, RelExpr expr,
     addend = getAddend<ELFT>(rel);
   } else {
     const uint8_t *buf = sec->rawData.data();
-    addend = target.getImplicitAddend(buf + rel.r_offset, type);
+    addend = target->getImplicitAddend(buf + rel.r_offset, type);
   }
 
   if (config->emachine == EM_PPC64 && config->isPic && type == R_PPC64_TOC)
@@ -979,7 +978,7 @@ bool RelocationScanner::isStaticLinkTimeConstant(RelExpr e, RelType type,
   // These never do, except if the entire file is position dependent or if
   // only the low bits are used.
   if (e == R_GOT || e == R_PLT)
-    return target.usesOnlyLowPageBits(type) || !config->isPic;
+    return target->usesOnlyLowPageBits(type) || !config->isPic;
 
   if (sym.isPreemptible)
     return false;
@@ -999,7 +998,7 @@ bool RelocationScanner::isStaticLinkTimeConstant(RelExpr e, RelType type,
   if (!absVal && relE)
     return true;
   if (!absVal && !relE)
-    return target.usesOnlyLowPageBits(type);
+    return target->usesOnlyLowPageBits(type);
 
   assert(absVal && relE);
 
@@ -1058,13 +1057,13 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
 
   bool canWrite = (sec->flags & SHF_WRITE) || !config->zText;
   if (canWrite) {
-    RelType rel = target.getDynRel(type);
-    if (expr == R_GOT || (rel == target.symbolicRel && !sym.isPreemptible)) {
+    RelType rel = target->getDynRel(type);
+    if (expr == R_GOT || (rel == target->symbolicRel && !sym.isPreemptible)) {
       addRelativeReloc<true>(*sec, offset, sym, addend, expr, type);
       return;
     } else if (rel != 0) {
-      if (config->emachine == EM_MIPS && rel == target.symbolicRel)
-        rel = target.relativeRel;
+      if (config->emachine == EM_MIPS && rel == target->symbolicRel)
+        rel = target->relativeRel;
       std::lock_guard<std::mutex> lock(relocMutex);
       sec->getPartition().relaDyn->addSymbolReloc(rel, *sec, offset, sym,
                                                   addend, type);
@@ -1335,7 +1334,7 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
     return;
 
   const uint8_t *relocatedAddr = sec->rawData.begin() + offset;
-  RelExpr expr = target.getRelExpr(type, sym, relocatedAddr);
+  RelExpr expr = target->getRelExpr(type, sym, relocatedAddr);
 
   // Ignore R_*_NONE and other marker relocations.
   if (expr == R_NONE)
@@ -1423,7 +1422,7 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
             type == R_HEX_GD_PLT_B32_PCREL_X)))
       expr = fromPlt(expr);
     } else if (!isAbsoluteValue(sym)) {
-      expr = target.adjustGotPcExpr(type, addend, relocatedAddr);
+      expr = target->adjustGotPcExpr(type, addend, relocatedAddr);
     }
   }
 


        


More information about the llvm-commits mailing list