Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -469,6 +469,9 @@ return Sec->Name == Name; return false; }); + log((isa(S) ? "linker generated section '" + : "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,34 @@ +# 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' +# CHECK-NEXT: linker generated section '.comment' assigned to output section '.comment' +# CHECK-NEXT: linker generated section '.bss' assigned to output section '.bss' +# CHECK-NEXT: linker generated section '.bss.rel.ro' assigned to output section '.bss.rel.ro' +# CHECK-NEXT: linker generated section '.dynsym' assigned to output section '.dynsym' +# CHECK-NEXT: linker generated section '.gnu.version' assigned to output section '.gnu.version' +# CHECK-NEXT: linker generated section '.gnu.version_r' assigned to output section '.gnu.version_r' +# CHECK-NEXT: linker generated section '.hash' assigned to output section '.hash' +# CHECK-NEXT: linker generated section '.dynamic' assigned to output section '.dynamic' +# CHECK-NEXT: linker generated section '.dynstr' assigned to output section '.dynstr' +# CHECK-NEXT: linker generated section '.rela.dyn' assigned to output section '.rela.dyn' +# CHECK-NEXT: linker generated section '.got' assigned to output section '.got' +# CHECK-NEXT: linker generated section '.got.plt' assigned to output section '.got.plt' +# CHECK-NEXT: linker generated section '.got.plt' assigned to output section '.got.plt' +# CHECK-NEXT: linker generated section '.rela.plt' assigned to output section '.rela.plt' +# CHECK-NEXT: linker generated section '.rela.plt' assigned to output section '.rela.plt' +# CHECK-NEXT: linker generated section '.plt' assigned to output section '.plt' +# CHECK-NEXT: linker generated section '.plt' assigned to output section '.plt' +# CHECK-NEXT: linker generated section '.eh_frame' assigned to output section '.eh_frame' +# CHECK-NEXT: linker generated section '.symtab' assigned to output section '.symtab' +# CHECK-NEXT: linker generated section '.shstrtab' assigned to output section '.shstrtab' +# CHECK-NEXT: linker generated section '.strtab' assigned to output section '.strtab' + +.section .text.1,"a" + nop + +.section .text.2,"a" + nop