ELF: Exclude dead symbols from -Map output.

This was previously erroring out if one of the dead symbols was a
TLS symbol and we were able to discard all TLS sections.

Differential Revision: https://reviews.llvm.org/D35397

llvm-svn: 307984
This commit is contained in:
Peter Collingbourne 2017-07-14 00:31:56 +00:00
parent 3e2abdef02
commit b069a36f27
2 changed files with 10 additions and 1 deletions

View File

@ -55,7 +55,7 @@ template <class ELFT> std::vector<DefinedRegular *> getSymbols() {
for (SymbolBody *B : File->getSymbols())
if (B->File == File && !B->isSection())
if (auto *Sym = dyn_cast<DefinedRegular>(B))
if (Sym->Section)
if (Sym->Section && Sym->Section->Live)
V.push_back(Sym);
return V;
}

View File

@ -0,0 +1,9 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: ld.lld %t.o -o %t -Map=- --gc-sections | FileCheck %s
.section .tbss,"awT",@nobits
// CHECK-NOT: foo
.globl foo
foo:
.align 8
.long 0