diff --git a/lld/MachO/MapFile.cpp b/lld/MachO/MapFile.cpp --- a/lld/MachO/MapFile.cpp +++ b/lld/MachO/MapFile.cpp @@ -40,14 +40,15 @@ using namespace lld; using namespace lld::macho; -// Returns a list of all symbols that we want to print out. -static std::vector getSymbols() { +// Returns only live symbols if `Live` is true. Else, returns only dead-stripped +// symbols. +static std::vector getSymbols(bool Live = true) { std::vector v; for (InputFile *file : inputFiles) if (isa(file)) for (Symbol *sym : file->symbols) if (auto *d = dyn_cast_or_null(sym)) - if (d->isLive() && d->isec && d->getFile() == file) { + if ((d->isLive() == Live) && d->isec && d->getFile() == file) { assert(!shouldOmitFromOutput(d->isec)); v.push_back(d); } @@ -105,12 +106,12 @@ } // Collect symbol info that we want to print out. - std::vector syms = getSymbols(); - parallelSort(syms.begin(), syms.end(), [](Defined *a, Defined *b) { + std::vector liveSyms = getSymbols(true); + parallelSort(liveSyms.begin(), liveSyms.end(), [](Defined *a, Defined *b) { return a->getVA() != b->getVA() ? a->getVA() < b->getVA() : a->getName() < b->getName(); }); - DenseMap symStr = getSymbolStrings(syms); + DenseMap symStr = getSymbolStrings(liveSyms); // Dump table of sections os << "# Sections:\n"; @@ -134,6 +135,6 @@ }; os << "# Symbols:\n"; - writeSymbols(syms); + writeSymbols(liveSyms); // TODO: when we implement -dead_strip, we should dump dead stripped symbols }