Index: InputFiles.cpp =================================================================== --- InputFiles.cpp +++ InputFiles.cpp @@ -339,10 +339,10 @@ uint32_t Index = this->getSectionIndex(Sym); if (Index == 0) return nullptr; - if (Index >= Sections.size() || !Sections[Index]) + if (Index >= Sections.size()) fatal(getFilename(this) + ": invalid section index: " + Twine(Index)); InputSectionBase *S = Sections[Index]; - if (S == &InputSectionBase::Discarded) + if (!S || S == &InputSectionBase::Discarded) return S; return S->Repl; }