<div dir="auto">what does "non-interruptable" mean in this context? in the same segment?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 25, 2017 9:32 PM, "Rui Ueyama via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Sat Mar 25 22:20:30 2017<br>
New Revision: 298792<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=298792&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=298792&view=rev</a><br>
Log:<br>
Add comments and return early.<br>
<br>
Modified:<br>
    lld/trunk/ELF/Relocations.cpp<br>
<br>
Modified: lld/trunk/ELF/Relocations.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=298792&r1=298791&r2=298792&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>Relocations.cpp?rev=298792&r1=<wbr>298791&r2=298792&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Relocations.cpp (original)<br>
+++ lld/trunk/ELF/Relocations.cpp Sat Mar 25 22:20:30 2017<br>
@@ -312,6 +312,15 @@ static bool isRelExpr(RelExpr Expr) {<br>
                         R_PAGE_PC, R_RELAX_GOT_PC>(Expr);<br>
 }<br>
<br>
+// Returns true if a given relocation can be computed at link-time.<br>
+//<br>
+// For instance, we know the offset from a relocation to its target at<br>
+// link-time if the relocation is PC-relative and refers a<br>
+// (non-interruptible) function in the same executable. This function<br>
+// will return true for such relocation.<br>
+//<br>
+// If this function returns false, that means we need to emit a<br>
+// dynamic relocation so that the relocation will be fixed at load-time.<br>
 template <class ELFT><br>
 static bool<br>
 isStaticLinkTimeConstant(<wbr>RelExpr E, uint32_t Type, const SymbolBody &Body,<br>
@@ -331,16 +340,19 @@ isStaticLinkTimeConstant(<wbr>RelExpr E, uint<br>
<br>
   if (isPreemptible(Body, Type))<br>
     return false;<br>
-<br>
   if (!Config->Pic)<br>
     return true;<br>
<br>
+  // For the target and the relocation, we want to know if they are<br>
+  // absolute or relative.<br>
   bool AbsVal = isAbsoluteValue<ELFT>(Body);<br>
   bool RelE = isRelExpr(E);<br>
   if (AbsVal && !RelE)<br>
     return true;<br>
   if (!AbsVal && RelE)<br>
     return true;<br>
+  if (!AbsVal && !RelE)<br>
+    return Target->usesOnlyLowPageBits(<wbr>Type);<br>
<br>
   // Relative relocation to an absolute value. This is normally unrepresentable,<br>
   // but if the relocation refers to a weak undefined symbol, we allow it to<br>
@@ -350,16 +362,14 @@ isStaticLinkTimeConstant(<wbr>RelExpr E, uint<br>
   // Another special case is MIPS _gp_disp symbol which represents offset<br>
   // between start of a function and '_gp' value and defined as absolute just<br>
   // to simplify the code.<br>
-  if (AbsVal && RelE) {<br>
-    if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak())<br>
-      return true;<br>
-    error(S.getLocation<ELFT>(<wbr>RelOff) + ": relocation " + toString(Type) +<br>
-          " cannot refer to absolute symbol '" + toString(Body) +<br>
-          "' defined in " + toString(Body.File));<br>
+  assert(AbsVal && RelE);<br>
+  if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak())<br>
     return true;<br>
-  }<br>
<br>
-  return Target->usesOnlyLowPageBits(<wbr>Type);<br>
+  error(S.getLocation<ELFT>(<wbr>RelOff) + ": relocation " + toString(Type) +<br>
+        " cannot refer to absolute symbol '" + toString(Body) +<br>
+        "' defined in " + toString(Body.File));<br>
+  return true;<br>
 }<br>
<br>
 static RelExpr toPlt(RelExpr Expr) {<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>