[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 09:25:37 PDT 2016
davide created this revision.
davide added reviewers: ruiu, rafael.
davide added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.
Accidentally found while debugging an unrelated lto issue.
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,7 @@
}
template <class ELFT> void elf::reportDiscarded(InputSectionBase<ELFT> *IS) {
- if (!Config->PrintGcSections || !IS || IS->Live)
+ if (!Config->PrintGcSections || !IS || !IS->getFile() || 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.71841.patch
Type: text/x-patch
Size: 917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160919/ec56a8ea/attachment.bin>
More information about the llvm-commits
mailing list