Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -566,6 +566,7 @@ if (Pos == E) { Opt.Commands.insert(CmdIter, llvm::make_unique(Name)); + elf::log("unplaced orphan section " + Name); ++CmdIndex; continue; } Index: test/ELF/orphan-handling.s =================================================================== --- test/ELF/orphan-handling.s +++ test/ELF/orphan-handling.s @@ -0,0 +1,24 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { .foo.1 : { *(.foo.1) } }" > %t.script + +# RUN: ld.lld -shared -o %t.out --script %t.script %t.o --verbose | FileCheck %s +# CHECK: unplaced orphan section .foo.2 +# CHECK: unplaced orphan section .dynsym +# CHECK: unplaced orphan section .hash +# CHECK: unplaced orphan section .dynstr +# CHECK: unplaced orphan section .text +# CHECK: unplaced orphan section .dynamic +# CHECK: unplaced orphan section .symtab +# CHECK: unplaced orphan section .shstrtab +# CHECK: unplaced orphan section .strtab + +.text +.globl _start +_start: + +.section .foo.1,"a" + .quad 1 + +.section .foo.2,"a" + .quad 2