[lld] r330883 - [COFF] more informative "broken object file" diagnostics

Bob Haarman via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 25 16:33:20 PDT 2018


Author: inglorion
Date: Wed Apr 25 16:33:19 2018
New Revision: 330883

URL: http://llvm.org/viewvc/llvm-project?rev=330883&view=rev
Log:
[COFF] more informative "broken object file" diagnostics

Summary:
When a symbol refers to a special section or a section that doesn't
exist, lld would fatal with "broken object file". This change gives a
different message for each scenario, and includes the name of the
file, name of the symbol, and the section being referred to.

Reviewers: pcc, ruiu

Reviewed By: ruiu

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D46090

Modified:
    lld/trunk/COFF/InputFiles.cpp

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=330883&r1=330882&r2=330883&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Wed Apr 25 16:33:19 2018
@@ -326,14 +326,13 @@ Optional<Symbol *> ObjFile::createDefine
   if (SectionNumber == llvm::COFF::IMAGE_SYM_DEBUG)
     return nullptr;
 
-  // Reserved sections numbers don't have contents.
   if (llvm::COFF::isReservedSectionNumber(SectionNumber))
-    fatal("broken object file: " + toString(this));
+    fatal(toString(this) + ": " + Name +
+          " should not refer to special section " + Twine(SectionNumber));
 
-  // This symbol references a section which is not present in the section
-  // header.
   if ((uint32_t)SectionNumber >= SparseChunks.size())
-    fatal("broken object file: " + toString(this));
+    fatal(toString(this) + ": " + Name +
+          " should not refer to non-existent section " + Twine(SectionNumber));
 
   // Handle comdat leader symbols.
   if (const coff_aux_section_definition *Def = ComdatDefs[SectionNumber]) {




More information about the llvm-commits mailing list