Index: lld/trunk/ELF/LinkerScript.cpp =================================================================== --- lld/trunk/ELF/LinkerScript.cpp +++ lld/trunk/ELF/LinkerScript.cpp @@ -887,7 +887,8 @@ // in case it is empty. bool IsEmpty = getInputSections(Sec).empty(); if (IsEmpty) - Sec->Flags = Flags & (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR); + Sec->Flags = + Flags & ((Sec->NonAlloc ? 0 : SHF_ALLOC) | SHF_WRITE | SHF_EXECINSTR); if (IsEmpty && isDiscardable(*Sec)) { Sec->Live = false; Index: lld/trunk/ELF/ScriptParser.cpp =================================================================== --- lld/trunk/ELF/ScriptParser.cpp +++ lld/trunk/ELF/ScriptParser.cpp @@ -752,6 +752,7 @@ } else { skip(); // This is "COPY", "INFO" or "OVERLAY". Cmd->NonAlloc = true; + Cmd->Type = SHT_PROGBITS; } expect(")"); return true; Index: lld/trunk/test/ELF/linkerscript/info-section-type.s =================================================================== --- lld/trunk/test/ELF/linkerscript/info-section-type.s +++ lld/trunk/test/ELF/linkerscript/info-section-type.s @@ -29,6 +29,10 @@ # RUN: ld.lld -o %t --script %t.script %t.o # RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=NONALLOC +# RUN: echo "SECTIONS { .bar (INFO) : { . += 1; } };" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=NONALLOC + # RUN: echo "SECTIONS { .bar 0x20000 (INFO) : { *(.foo) } };" > %t.script # RUN: ld.lld -o %t --script %t.script %t.o # RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=NONALLOC