[PATCH] D28951: [ELF] - Linkerscripts: ignore CONSTRUCTORS in output section declaration.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 07:25:08 PST 2017


grimar created this revision.

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. I also added verbose message about that
so users will be able to locate and remove that command from their scripts.


https://reviews.llvm.org/D28951

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/constructor.s


Index: test/ELF/linkerscript/constructor.s
===================================================================
--- test/ELF/linkerscript/constructor.s
+++ test/ELF/linkerscript/constructor.s
@@ -0,0 +1,14 @@
+# 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: ld.lld --script %t.script %t.o -o %t1 --verbose | FileCheck %s
+# CHECK: {{.*}}.script:1: CONSTRUCTORS ignored for ELF
+
+# RUN: llvm-objdump -section-headers %t1 | FileCheck %s --check-prefix=SIZE
+# SIZE:      Sections:
+# SIZE-NEXT: Idx Name          Size
+# SIZE-NEXT:   0               00000000
+# SIZE-NEXT:   1 foo           00000001
+
+.section foo, "a"
+.byte 0
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1449,6 +1449,9 @@
     } else if (Tok == "ASSERT") {
       Cmd->Commands.emplace_back(new AssertCommand(readAssert()));
       expect(";");
+    } else if (Tok == "CONSTRUCTORS") {
+      if (Config->Verbose)
+        elf::log(getCurrentLocation() + ": CONSTRUCTORS ignored for ELF");
     } else if (Tok == "FILL") {
       Cmd->Filler = readFill();
     } else if (Tok == "SORT") {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28951.85134.patch
Type: text/x-patch
Size: 1280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170120/f404fef8/attachment.bin>


More information about the llvm-commits mailing list