[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 16:24:36 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL281946: [GC] Don't crash when printing the special Discarded GC section. (authored by davide).

Changed prior to commit:
  https://reviews.llvm.org/D24731?vs=71886&id=71887#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24731

Files:
  lld/trunk/ELF/Writer.cpp
  lld/trunk/test/ELF/lto/dynsym.ll

Index: lld/trunk/test/ELF/lto/dynsym.ll
===================================================================
--- lld/trunk/test/ELF/lto/dynsym.ll
+++ lld/trunk/test/ELF/lto/dynsym.ll
@@ -5,6 +5,11 @@
 ; RUN: ld.lld -m elf_x86_64 %t2.o %t.so -o %t
 ; RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
 
+; 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
+
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -102,7 +102,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.71887.patch
Type: text/x-patch
Size: 1178 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160919/c17ea925/attachment.bin>


More information about the llvm-commits mailing list