diff --git a/lld/MachO/MapFile.cpp b/lld/MachO/MapFile.cpp --- a/lld/MachO/MapFile.cpp +++ b/lld/MachO/MapFile.cpp @@ -61,13 +61,15 @@ } // Returns a list of all symbols that we want to print out. -static std::vector getSymbols() { +// Return only live symbols if `Live` is true. Else, return 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); } @@ -136,12 +138,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"; @@ -156,6 +158,6 @@ } // Dump table of symbols - writeSymbols(syms) + writeSymbols(getSectionSyms(liveSyms)) // TODO: when we implement -dead_strip, we should dump dead stripped symbols }