[PATCH] D37517: [ELF] - Report orphan sections if -verbose given.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 07:41:25 PDT 2017
grimar created this revision.
Herald added a subscriber: emaste.
This ressurects ideas of abandoned (because of being outdated) https://reviews.llvm.org/D24725 patch.
When -verbose is specified, patch outputs names of each input orphan section
assigned to output. One problem I faced is synthetic sections. This patch bans them
from reporting, because we add them early and then remove unused later. If I would
not ban them, many unused sections would have being marked as orphans,
what is useless and not true.
The only way to report them correctly I see is to introduce some list for them (or IsOrphan flag
in SyntheticSection class may be), though probably can be too much.
Should we support this case ?
https://reviews.llvm.org/D37517
Files:
ELF/LinkerScript.cpp
test/ELF/linkerscript/orphan-report.s
Index: test/ELF/linkerscript/orphan-report.s
===================================================================
--- test/ELF/linkerscript/orphan-report.s
+++ test/ELF/linkerscript/orphan-report.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { .text : { *(.text.1) } }" > %t.script
+# RUN: ld.lld -shared -o %t.out --script %t.script %t.o --verbose | FileCheck %s
+
+# CHECK: orphan input section '.text' assigned to output section '.text'
+# CHECK-NEXT: orphan input section '.text.2' assigned to output section '.text'
+
+.section .text.1,"a"
+ nop
+
+.section .text.2,"a"
+ nop
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -465,6 +465,9 @@
return Sec->Name == Name;
return false;
});
+ if (!isa<SyntheticSection>(S))
+ log("orphan input section '" + S->Name +
+ "' assigned to output section '" + Name + "'");
if (I == End) {
Factory.addInputSec(S, Name);
assert(S->getOutputSection()->SectionIndex == INT_MAX);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37517.114008.patch
Type: text/x-patch
Size: 1163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170906/86fea300/attachment.bin>
More information about the llvm-commits
mailing list