[PATCH] D34327: [ELF] - Produce fatal error if we not able to create DWARFContextInMemory object.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 18 08:33:21 PDT 2017


grimar created this revision.
Herald added subscribers: aprantl, emaste.

We use DWARFContextInMemory for 2 purposes currently in LLD.

1. To report error line number when reporting errors.

I noticed in AVR patch (at one of moments during reviews) that we had undefined error
and DWARF context reported multiple issues like "relocation is not supported" or something like
that. That happens because there is no support for AVR relocations on parsers side.
I guess result of working with such object in unexpected and since LLD looks at some point where
there is chance to see even more new targets probably, I think we should fatal().

2. For .gdb_index building. Currently we have PR33173 and

"failed to compute relocation: R_X86_64_DTPOFF32 with --gdb-index". But also may have any other different errors,
like error of decompression of section or anything else because of broken object for example. That is true for
first case as well. And even now when looks that single relocation fail does not affect on index, it still wrong
not to fail in this case. That what was suggested in https://reviews.llvm.org/D33673 thread.

Also one benefit that we can fail early ar parsers side and do not wait for all section to be proccessed.
I'll post change for LLVM side shortly and update note with reference.


https://reviews.llvm.org/D34327

Files:
  ELF/InputFiles.cpp
  ELF/SyntheticSections.cpp


Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1789,7 +1789,11 @@
     return {};
   }
 
-  DWARFContextInMemory Dwarf(*Obj.get());
+  DWARFContextInMemory Dwarf(*Obj.get(), nullptr /*LoadedObjectInfo*/,
+                             false /*AllowErrors*/);
+  if (Dwarf.HasErrors())
+    fatal("unable to initialize DWARFContextInMemory for " +
+          toString(Sec->File));
 
   GdbIndexChunk Ret;
   Ret.CompilationUnits = readCuList(Dwarf, Sec);
Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -78,7 +78,9 @@
       check(object::ObjectFile::createObjectFile(this->MB), toString(this));
 
   ObjectInfo ObjInfo;
-  DWARFContextInMemory Dwarf(*Obj, &ObjInfo);
+  DWARFContextInMemory Dwarf(*Obj, &ObjInfo, false);
+  if (Dwarf.HasErrors())
+    fatal("unable to initialize DWARFContextInMemory for " + toString(this));
   DwarfLine.reset(new DWARFDebugLine(&Dwarf.getLineSection().Relocs));
   DataExtractor LineData(Dwarf.getLineSection().Data, Config->IsLE,
                          Config->Wordsize);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34327.102969.patch
Type: text/x-patch
Size: 1224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170618/cc2f79a4/attachment.bin>


More information about the llvm-commits mailing list