Index: lld/trunk/ELF/InputSection.cpp =================================================================== --- lld/trunk/ELF/InputSection.cpp +++ lld/trunk/ELF/InputSection.cpp @@ -36,7 +36,10 @@ // Returns a string to construct an error message. template std::string lld::toString(const InputSectionBase *Sec) { - return (Sec->getFile()->getName() + ":(" + Sec->Name + ")").str(); + // File can absent if section is synthetic. + std::string FileName = + Sec->getFile() ? Sec->getFile()->getName() : ""; + return (FileName + ":(" + Sec->Name + ")").str(); } template Index: lld/trunk/test/ELF/incompatible-section-types2.s =================================================================== --- lld/trunk/test/ELF/incompatible-section-types2.s +++ lld/trunk/test/ELF/incompatible-section-types2.s @@ -0,0 +1,7 @@ +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +// RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s + +// CHECK: error: Section has different type from others with the same name :(.shstrtab) + +.section .shstrtab,"" +.short 20