Index: lld/trunk/ELF/LinkerScript.cpp =================================================================== --- lld/trunk/ELF/LinkerScript.cpp +++ lld/trunk/ELF/LinkerScript.cpp @@ -1439,6 +1439,10 @@ } else if (Tok == "ASSERT") { Cmd->Commands.emplace_back(new AssertCommand(readAssert())); expect(";"); + } else if (Tok == "CONSTRUCTORS") { + // CONSTRUCTORS is a keyword to make the linker recognize C++ ctors/dtors + // by name. This is for very old file formats such as ECOFF/XCOFF. + // For ELF, we should ignore. } else if (Tok == "FILL") { Cmd->Filler = readFill(); } else if (Tok == "SORT") { Index: lld/trunk/test/ELF/linkerscript/constructor.s =================================================================== --- lld/trunk/test/ELF/linkerscript/constructor.s +++ lld/trunk/test/ELF/linkerscript/constructor.s @@ -0,0 +1,12 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { foo : { *(.foo) CONSTRUCTORS } }" > %t.script + +# RUN: llvm-objdump -section-headers %t1 | FileCheck %s +# CHECK: Sections: +# CHECK-NEXT: Idx Name Size +# CHECK-NEXT: 0 00000000 +# CHECK-NEXT: 1 foo 00000001 + +.section foo, "a" +.byte 0