diff options
author | George Rimar <grimar@accesssoftek.com> | 2017-01-23 09:36:19 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2017-01-23 09:36:19 +0000 |
commit | 8e2eca229e1832f12dd8c4622ccb61d65e896a69 (patch) | |
tree | 3890dd4b8510f842713f67d8e0e9dd73f360d273 | |
parent | 855086dad5ef96336a52a233ab3ea30274a77a3f (diff) | |
download | llvm-8e2eca229e1832f12dd8c4622ccb61d65e896a69.zip llvm-8e2eca229e1832f12dd8c4622ccb61d65e896a69.tar.gz llvm-8e2eca229e1832f12dd8c4622ccb61d65e896a69.tar.bz2 |
[ELF] - Linkerscripts: ignore CONSTRUCTORS in output section declaration.
It is used in linux kernel script:
http://lxr.free-electrons.com/source/arch/x86/kernel/vmlinux.lds.S#L140
Though CONSTRUCTORS is ignored for ELF.
Differential revision: https://reviews.llvm.org/D28951
llvm-svn: 292777
-rw-r--r-- | lld/ELF/LinkerScript.cpp | 4 | ||||
-rw-r--r-- | lld/test/ELF/linkerscript/constructor.s | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index a96a20c..ca2614d 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1439,6 +1439,10 @@ ScriptParser::readOutputSectionDescription(StringRef OutSec) { } 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") { diff --git a/lld/test/ELF/linkerscript/constructor.s b/lld/test/ELF/linkerscript/constructor.s new file mode 100644 index 0000000..3fb7143 --- /dev/null +++ b/lld/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 |