[PATCH] D34814: [ELF] - Fail the link if something happens on DWARF parsing stage of -gdb-index building

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 7 02:18:50 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL307370: [ELF] - Fail the link if something happens on DWARF parsing stage of -gdb-index… (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D34814?vs=104653&id=105602#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34814

Files:
  lld/trunk/ELF/SyntheticSections.cpp
  lld/trunk/test/ELF/invalid/invalid-debug-relocations.test


Index: lld/trunk/test/ELF/invalid/invalid-debug-relocations.test
===================================================================
--- lld/trunk/test/ELF/invalid/invalid-debug-relocations.test
+++ lld/trunk/test/ELF/invalid/invalid-debug-relocations.test
@@ -0,0 +1,41 @@
+# REQUIRES: x86
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld -gdb-index %t.o -o %t.exe 2>&1 | FileCheck %s
+
+# CHECK:      error: {{.*}}.o: error parsing DWARF data:
+# CHECK-NEXT: >>> failed to compute relocation: Unknown, Invalid data was encountered while parsing the file
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_386
+Sections:
+  - Type:            SHT_PROGBITS
+    Name:            .text
+    Flags:           [ ]
+    AddressAlign:    0x04
+    Content:         "0000"
+  - Type:            SHT_PROGBITS
+    Name:            .debug_info
+    Flags:           [ ]
+    AddressAlign:    0x04
+    Content:         "0000"
+  - Type:            SHT_REL
+    Name:            .rel.debug_info
+    Link:            .symtab
+    Info:            .debug_info
+    Relocations:
+      - Offset:          0
+        Symbol:          _start
+        Type:            0xFF
+      - Offset:          4
+        Symbol:          _start
+        Type:            0xFF
+Symbols:
+  Global:
+    - Name:     _start
+      Type:     STT_FUNC
+      Section:  .text
+      Value:    0x0
Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -1811,7 +1811,11 @@
     return {};
   }
 
-  DWARFContextInMemory Dwarf(*Obj.get());
+  DWARFContextInMemory Dwarf(*Obj.get(), nullptr, [&](Error E) {
+    error(toString(Sec->File) + ": error parsing DWARF data:\n>>> " +
+          toString(std::move(E)));
+    return ErrorPolicy::Continue;
+  });
 
   GdbIndexChunk Ret;
   Ret.CompilationUnits = readCuList(Dwarf, Sec);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34814.105602.patch
Type: text/x-patch
Size: 2017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170707/ba8116d8/attachment.bin>


More information about the llvm-commits mailing list