Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -465,6 +465,9 @@ return Sec->Name == Name; return false; }); + if (!isa(S)) + log("orphan input section '" + S->Name + + "' assigned to output section '" + Name + "'"); if (I == End) { Factory.addInputSec(S, Name); assert(S->getOutputSection()->SectionIndex == INT_MAX); Index: test/ELF/linkerscript/orphan-report.s =================================================================== --- test/ELF/linkerscript/orphan-report.s +++ test/ELF/linkerscript/orphan-report.s @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { .text : { *(.text.1) } }" > %t.script +# RUN: ld.lld -shared -o %t.out --script %t.script %t.o --verbose | FileCheck %s + +# CHECK: orphan input section '.text' assigned to output section '.text' +# CHECK-NEXT: orphan input section '.text.2' assigned to output section '.text' + +.section .text.1,"a" + nop + +.section .text.2,"a" + nop