[PATCH] D24725: [ELF] - Linkerscript: report orphans if --verbose used.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 21 08:57:47 PDT 2016


grimar retitled this revision from "[ELF] - Linkerscript: implemented --orphan-handling command line option." to "[ELF] - Linkerscript: report orphans if --verbose used.".
grimar updated the summary for this revision.
grimar updated this revision to Diff 72062.
grimar added a comment.

- As was duscussed in llvm maillist, just report orphans if --verbose used.


https://reviews.llvm.org/D24725

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/orphan-handling.s

Index: test/ELF/linkerscript/orphan-handling.s
===================================================================
--- test/ELF/linkerscript/orphan-handling.s
+++ test/ELF/linkerscript/orphan-handling.s
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { .foo.1 : { *(.foo.1) } }" > %t.script
+
+# RUN: ld.lld -o %t.out --script %t.script %t.o --verbose | FileCheck %s
+# CHECK: unplaced orphan section .text from {{.*}}.o
+# CHECK: unplaced orphan section .foo.2 from {{.*}}.o
+
+.text
+.globl _start
+_start:
+
+.section .foo.1,"a"
+ .quad 1
+
+.section .foo.2,"a"
+ .quad 2
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -316,10 +316,15 @@
 void LinkerScript<ELFT>::createSections(OutputSectionFactory<ELFT> &Factory) {
   processCommands(Factory);
   // Add orphan sections.
-  for (ObjectFile<ELFT> *F : Symtab<ELFT>::X->getObjectFiles())
-    for (InputSectionBase<ELFT> *S : F->getSections())
-      if (!isDiscarded(S) && !S->OutSec)
+  for (ObjectFile<ELFT> *F : Symtab<ELFT>::X->getObjectFiles()) {
+    for (InputSectionBase<ELFT> *S : F->getSections()) {
+      if (!isDiscarded(S) && !S->OutSec) {
         addSection(Factory, S, getOutputSectionName(S));
+        elf::log("unplaced orphan section " + S->Name + " from " +
+                 getFilename(F));
+      }
+    }
+  }
 }
 
 // Sets value of a section-defined symbol. Two kinds of


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24725.72062.patch
Type: text/x-patch
Size: 1534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160921/0739bec6/attachment.bin>


More information about the llvm-commits mailing list