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

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 01:47:24 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL292777: [ELF] - Linkerscripts: ignore CONSTRUCTORS in output section declaration. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D28951?vs=85152&id=85331#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28951

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


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
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") {


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


More information about the llvm-commits mailing list