<div dir="ltr">I've reverted this change as it introduced UBSan failures, like <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/37344">this</a> one.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 13, 2019 at 4:23 AM Alex Richardson via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Alex Richardson<br>
Date: 2019-12-13T12:19:55Z<br>
New Revision: 2bbd32f5e8f0f62d895966e2623d9bdb9778b50b<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/2bbd32f5e8f0f62d895966e2623d9bdb9778b50b" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/2bbd32f5e8f0f62d895966e2623d9bdb9778b50b</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/2bbd32f5e8f0f62d895966e2623d9bdb9778b50b.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/2bbd32f5e8f0f62d895966e2623d9bdb9778b50b.diff</a><br>
<br>
LOG: [ELF] Allow getErrPlace() to work before Out::bufferStart is set<br>
<br>
Summary:<br>
So far it seems like the only test affected by this change is the one I<br>
recently added for R_MIPS_JALR relocations since the other test cases that<br>
use this function early (unknown-relocation-*) do not have a valid input<br>
section for the relocation offset.<br>
<br>
Reviewers: ruiu, grimar, MaskRay, espindola<br>
<br>
Reviewed By: ruiu, MaskRay<br>
<br>
Subscribers: emaste, sdardis, jrtc27, atanasyan, llvm-commits<br>
<br>
Tags: #llvm<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D70659" rel="noreferrer" target="_blank">https://reviews.llvm.org/D70659</a><br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    lld/ELF/Target.cpp<br>
    lld/test/ELF/mips-jalr-non-functions.s<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp<br>
index e1e99556ec7b..3d1e8e8a7f5b 100644<br>
--- a/lld/ELF/Target.cpp<br>
+++ b/lld/ELF/Target.cpp<br>
@@ -91,15 +91,15 @@ TargetInfo *getTarget() {<br>
 }<br>
<br>
 template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *loc) {<br>
-  if (!Out::bufferStart)<br>
-    return {};<br>
-<br>
   for (InputSectionBase *d : inputSections) {<br>
     auto *isec = cast<InputSection>(d);<br>
     if (!isec->getParent())<br>
       continue;<br>
<br>
-    uint8_t *isecLoc = Out::bufferStart + isec->getParent()->offset + isec->outSecOff;<br>
+    const uint8_t *isecLoc =<br>
+        Out::bufferStart<br>
+            ? (Out::bufferStart + isec->getParent()->offset + isec->outSecOff)<br>
+            : isec->data().data();<br>
     if (isecLoc <= loc && loc < isecLoc + isec->getSize())<br>
       return {isec, isec->template getLocation<ELFT>(loc - isecLoc) + ": "};<br>
   }<br>
<br>
diff  --git a/lld/test/ELF/mips-jalr-non-functions.s b/lld/test/ELF/mips-jalr-non-functions.s<br>
index 410b742c3e6f..cdb60cd39e83 100644<br>
--- a/lld/test/ELF/mips-jalr-non-functions.s<br>
+++ b/lld/test/ELF/mips-jalr-non-functions.s<br>
@@ -15,13 +15,13 @@ test:<br>
 .Ltmp1:<br>
   jr  $t9<br>
   nop<br>
-# WARNING-MESSAGE: warning: found R_MIPS_JALR relocation against non-function symbol tls_obj. This is invalid and most likely a compiler bug.<br>
+# WARNING-MESSAGE: warning: {{.+}}.tmp.o:(.text+0x0): found R_MIPS_JALR relocation against non-function symbol tls_obj. This is invalid and most likely a compiler bug.<br>
<br>
   .reloc .Ltmp2, R_MIPS_JALR, reg_obj<br>
 .Ltmp2:<br>
   jr  $t9<br>
   nop<br>
-# WARNING-MESSAGE: warning: found R_MIPS_JALR relocation against non-function symbol reg_obj. This is invalid and most likely a compiler bug.<br>
+# WARNING-MESSAGE: warning: {{.+}}.tmp.o:(.text+0x8): found R_MIPS_JALR relocation against non-function symbol reg_obj. This is invalid and most likely a compiler bug.<br>
<br>
   .reloc .Ltmp3, R_MIPS_JALR, untyped<br>
 .Ltmp3:<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>