<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 21, 2016 at 2:21 AM, George Rimar via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: grimar<br>
Date: Wed Dec 21 02:21:34 2016<br>
New Revision: 290239<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=290239&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=290239&view=rev</a><br>
Log:<br>
[ELF] - Do not call fatal() in Target.cpp, call error() instead.<br>
<br>
We probably would want to avoid fatal() if we can in context of librarification,<br>
but for me reason of that patch is to help D27900 go.<br>
<br>
D27900 changes errors reporting to something like<br>
error: text1<br>
note: text2<br>
note: text3<br>
<br>
where hint used to provide additional information about location. In that case<br>
I can't just call fatal() because user will not see notes after that what adds additional complication to handle.<br>
So It is good to switch fatal() to error() where it is possible.<br>
<br>
Also it adds testcase with broken relocation number.<br>
Previously we did not have any, It checks that error() instead of fatal() works fine.<br>
<br>
Differential revision: <a href="https://reviews.llvm.org/D27973" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D27973</a><br>
<br>
Added:<br>
    lld/trunk/test/ELF/invalid/<wbr>Inputs/invalid-relocation-x64.<wbr>elf   (with props)<br>
    lld/trunk/test/ELF/invalid/<wbr>invalid-relocation-x64.s<br>
Modified:<br>
    lld/trunk/ELF/Target.cpp<br>
<br>
Modified: lld/trunk/ELF/Target.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=290239&r1=290238&r2=290239&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Target.<wbr>cpp?rev=290239&r1=290238&r2=<wbr>290239&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Target.cpp (original)<br>
+++ lld/trunk/ELF/Target.cpp Wed Dec 21 02:21:34 2016<br>
@@ -870,7 +870,7 @@ void X86_64TargetInfo<ELFT>::<wbr>relocateOne<br>
     write64le(Loc, Val);<br>
     break;<br>
   default:<br>
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
   }<br>
 }<br>
<br>
@@ -1039,7 +1039,7 @@ void PPCTargetInfo::relocateOne(<wbr>uint8_t<br>
     or32be(Loc, Val & 0x3FFFFFC);<br>
     break;<br>
   default:<br>
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
   }<br>
 }<br>
<br>
@@ -1217,7 +1217,7 @@ void PPC64TargetInfo::relocateOne(<wbr>uint8_<br>
     break;<br>
   }<br>
   default:<br>
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
   }<br>
 }<br>
<br>
@@ -1468,7 +1468,7 @@ void AArch64TargetInfo::<wbr>relocateOne(uint<br>
     or32AArch64Imm(Loc, Val);<br>
     break;<br>
   default:<br>
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
   }<br>
 }<br>
<br>
@@ -1578,7 +1578,7 @@ void AMDGPUTargetInfo::relocateOne(<wbr>uint8<br>
     write32le(Loc, Val >> 32);<br>
     break;<br>
   default:<br>
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
   }<br>
 }<br>
<br>
@@ -1888,7 +1888,7 @@ void ARMTargetInfo::relocateOne(<wbr>uint8_t<br>
                   (Val & 0x00ff));           // imm8<br>
     break;<br>
   default:<br>
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
   }<br>
 }<br>
<br>
@@ -2336,7 +2336,7 @@ void MipsTargetInfo<ELFT>::<wbr>relocateOne(u<br>
     applyMipsPcReloc<E, 32, 0>(Loc, Type, Val);<br>
     break;<br>
   default:<br>
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));<br>
   }<br>
 }<br>
<br>
<br>
Added: lld/trunk/test/ELF/invalid/<wbr>Inputs/invalid-relocation-x64.<wbr>elf<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/Inputs/invalid-relocation-x64.elf?rev=290239&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/test/ELF/<wbr>invalid/Inputs/invalid-<wbr>relocation-x64.elf?rev=290239&<wbr>view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
Binary file - no diff available.<br>
<br>
Propchange: lld/trunk/test/ELF/invalid/<wbr>Inputs/invalid-relocation-x64.<wbr>elf<br>
------------------------------<wbr>------------------------------<wbr>------------------<br>
    svn:mime-type = application/octet-stream<br>
<br>
Added: lld/trunk/test/ELF/invalid/<wbr>invalid-relocation-x64.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-relocation-x64.s?rev=290239&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/test/ELF/<wbr>invalid/invalid-relocation-<wbr>x64.s?rev=290239&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/test/ELF/invalid/<wbr>invalid-relocation-x64.s (added)<br>
+++ lld/trunk/test/ELF/invalid/<wbr>invalid-relocation-x64.s Wed Dec 21 02:21:34 2016<br>
@@ -0,0 +1,31 @@<br>
+## invalid-relocation-x64.elf contains relocations with invalid relocation number.<br>
+## Next yaml code was used to create initial binary. After that it<br>
+## was modified with hex-editor to replace known relocations with fake ones,<br>
+## that have 0x98 and 0x98 numbers.<br>
+!ELF<br>
+FileHeader:<br>
+  Class:           ELFCLASS64<br>
+  Data:            ELFDATA2LSB<br>
+  OSABI:           ELFOSABI_FREEBSD<br>
+  Type:            ET_REL<br>
+  Machine:         EM_X86_64<br>
+Sections:<br>
+  - Name:            .text<br>
+    Type:            SHT_PROGBITS<br>
+    Flags:           [ SHF_ALLOC ]<br>
+  - Name:            .rela.text<br>
+    Type:            SHT_RELA<br>
+    Link:            .symtab<br>
+    Info:            .text<br>
+    Relocations:<br>
+      - Offset:          0x0000000000000000<br>
+        Symbol:          ''<br>
+        Type:            R_X86_64_NONE<br>
+      - Offset:          0x0000000000000000<br>
+        Symbol:          ''<br>
+        Type:            R_X86_64_NONE<br>
+<br>
+<br></blockquote><div><br></div><div>This line contains trailing whitespace.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+# RUN: not ld.lld %p/Inputs/invalid-relocation-<wbr>x64.elf -o %t2 2>&1 | FileCheck %s<br>
+# CHECK: unrecognized reloc 152<br>
+# CHECK: unrecognized reloc 153<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><br></div></div>