[PATCH] D24731: [GC] Don't crash when printing gc'd sections with no name and no associated file
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 19 15:57:20 PDT 2016
davide updated this revision to Diff 71886.
davide added a comment.
I analyzed this a little bit further.
I think this happen only when we try to print the "special" section `&InputSection<ELFT>::Discarded` (the debugger confirms).
This has no name associated, and I don't think it's backed by a file. I think it's not entirely unreasonable to skip it while reporting sections which have been gc'ed. What do you think?
https://reviews.llvm.org/D24731
Files:
ELF/Writer.cpp
test/ELF/lto/dynsym.ll
Index: test/ELF/lto/dynsym.ll
===================================================================
--- test/ELF/lto/dynsym.ll
+++ test/ELF/lto/dynsym.ll
@@ -23,3 +23,8 @@
define void @foo() {
ret void
}
+
+; Check that we don't crash when gc'ing sections and printing the result.
+; RUN: ld.lld -m elf_x86_64 %t2.o %t.so --gc-sections --print-gc-sections \
+; RUN: -o %t
+; RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -99,7 +99,8 @@
}
template <class ELFT> void elf::reportDiscarded(InputSectionBase<ELFT> *IS) {
- if (!Config->PrintGcSections || !IS || IS->Live)
+ if (!Config->PrintGcSections || !IS || IS == &InputSection<ELFT>::Discarded ||
+ IS->Live)
return;
errs() << "removing unused section from '" << IS->Name << "' in file '"
<< IS->getFile()->getName() << "'\n";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24731.71886.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160919/92022924/attachment.bin>
More information about the llvm-commits
mailing list