[lld] r321736 - Refactor duplicated expression.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 08:38:46 PST 2018


Author: rafael
Date: Wed Jan  3 08:38:46 2018
New Revision: 321736

URL: http://llvm.org/viewvc/llvm-project?rev=321736&view=rev
Log:
Refactor duplicated expression.

Modified:
    lld/trunk/ELF/Relocations.cpp

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=321736&r1=321735&r2=321736&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Jan  3 08:38:46 2018
@@ -884,8 +884,8 @@ static void scanRelocs(InputSectionBase
     if (maybeReportUndefined(Sym, Sec, Rel.r_offset))
       continue;
 
-    RelExpr Expr =
-        Target->getRelExpr(Type, Sym, Sec.Data.begin() + Rel.r_offset);
+    const uint8_t *RelocatedAddr = Sec.Data.begin() + Rel.r_offset;
+    RelExpr Expr = Target->getRelExpr(Type, Sym, RelocatedAddr);
 
     // Ignore "hint" relocations because they are only markers for relaxation.
     if (isRelExprOneOf<R_HINT, R_NONE>(Expr))
@@ -919,8 +919,7 @@ static void scanRelocs(InputSectionBase
     if (Sym.isGnuIFunc())
       Expr = toPlt(Expr);
     else if (!Preemptible && Expr == R_GOT_PC && !isAbsoluteValue(Sym))
-      Expr =
-          Target->adjustRelaxExpr(Type, Sec.Data.data() + Rel.r_offset, Expr);
+      Expr = Target->adjustRelaxExpr(Type, RelocatedAddr, Expr);
     else if (!Preemptible)
       Expr = fromPlt(Expr);
 




More information about the llvm-commits mailing list