Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -628,6 +628,8 @@ continue; StringRef Name = getOutputSectionName(S); + if (Name == "") + continue; if (Config->OrphanHandling == OrphanHandlingPolicy::Error) error(toString(S) + " is being placed in '" + Name + "'"); Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -98,6 +98,8 @@ !isa(S)) { OutputSection *Out = cast(S)->getRelocatedSection()->getOutputSection(); + if (!Out) + return ""; if (S->Type == SHT_RELA) return Saver.save(".rela" + Out->Name); return Saver.save(".rel" + Out->Name);