[ELF] Prevent crash when reporting errors if debug line cannot be parsed

LLD uses the debug info and debug line sections to determine the location of
e.g. references to undefined symbols, when producing error messages. In the
event that debug info was present, but debug line parsing failed for some
reason, then a nullptr would end up being dereferenced by the location-lookup
code.

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

Reviewers: grimar
llvm-svn: 326899
This commit is contained in:
James Henderson
2018-03-07 15:22:58 +00:00
parent cb9e89c39b
commit cb4c19f315
3 changed files with 52 additions and 2 deletions

View File

@@ -126,6 +126,8 @@ template <class ELFT> void ObjFile<ELFT>::initializeDwarf() {
// CU (object file), so offset is always 0.
const DWARFDebugLine::LineTable *LT =
DwarfLine->getOrParseLineTable(LineData, 0, Dwarf, nullptr);
if (!LT)
return;
// Return if there is no debug information about CU available.
if (!Dwarf.getNumCompileUnits())