<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 29, 2017 at 8:06 AM George Rimar via Phabricator 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">grimar created this revision.<br>
Herald added subscribers: aprantl, emaste.<br>
<br>
This is relative to PR33173,<br>
<br>
Previously if something wrong happened on DWARF parsers side during parsing<br>
object for building gdb index (like was in PR: unsupported relocation) then LLD continued<br>
and finished the link. DWARF parsers sure showed error message on their side, but that is all.<br>
<br>
Patch changes behavior to fail the link in this case and show more detailed message.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D34814" rel="noreferrer" target="_blank">https://reviews.llvm.org/D34814</a><br>
<br>
Files:<br>
  ELF/SyntheticSections.cpp<br>
  test/ELF/invalid/invalid-debug-relocations.test<br>
<br>
<br>
Index: test/ELF/invalid/invalid-debug-relocations.test<br>
===================================================================<br>
--- test/ELF/invalid/invalid-debug-relocations.test<br>
+++ test/ELF/invalid/invalid-debug-relocations.test<br>
@@ -0,0 +1,41 @@<br>
+# REQUIRES: x86<br>
+# RUN: yaml2obj %s -o %t.o<br>
+# RUN: not ld.lld -gdb-index %t.o -o %t.exe 2>&1 | FileCheck %s<br>
+<br>
+# CHECK:      error: {{.*}}.o: error parsing DWARF data:<br>
+# CHECK-NEXT: >>> failed to compute relocation: Unknown, Invalid data was encountered while parsing the file<br>
+<br>
+!ELF<br>
+FileHeader:<br>
+  Class:           ELFCLASS32<br>
+  Data:            ELFDATA2LSB<br>
+  Type:            ET_REL<br>
+  Machine:         EM_386<br>
+Sections:<br>
+  - Type:            SHT_PROGBITS<br>
+    Name:            .text<br>
+    Flags:           [ ]<br>
+    AddressAlign:    0x04<br>
+    Content:         "0000"<br>
+  - Type:            SHT_PROGBITS<br>
+    Name:            .debug_info<br>
+    Flags:           [ ]<br>
+    AddressAlign:    0x04<br>
+    Content:         "0000"<br>
+  - Type:            SHT_REL<br>
+    Name:            .rel.debug_info<br>
+    Link:            .symtab<br>
+    Info:            .debug_info<br>
+    Relocations:<br>
+      - Offset:          0<br>
+        Symbol:          _start<br>
+        Type:            0xFF<br>
+      - Offset:          4<br>
+        Symbol:          _start<br>
+        Type:            0xFF<br>
+Symbols:<br>
+  Global:<br>
+    - Name:     _start<br>
+      Type:     STT_FUNC<br>
+      Section:  .text<br>
+      Value:    0x0<br>
Index: ELF/SyntheticSections.cpp<br>
===================================================================<br>
--- ELF/SyntheticSections.cpp<br>
+++ ELF/SyntheticSections.cpp<br>
@@ -1810,7 +1810,11 @@<br>
     return {};<br>
   }<br>
<br>
-  DWARFContextInMemory Dwarf(*Obj.get());<br>
+  DWARFContextInMemory Dwarf(*Obj.get(), nullptr, [&](Error E) {<br>
+    error(toString(Sec->File) + ": error parsing DWARF data:\n>>> " +<br>
+          toString(std::move(E)));<br>
+    return ErrorPolicy::Continue;<br></blockquote><div><br>Is 'error(...)' a noreturn function (does it cause the linker to stop immediately?)? If so, remove the 'return' after it, since that'll be unreachable code.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  });<br>
<br>
   GdbIndexChunk Ret;<br>
   Ret.CompilationUnits = readCuList(Dwarf, Sec);<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>