[PATCH] D114735: [lld][macho] Stop grouping symbols by sections in mapfile.
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 20 12:16:50 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf84023a812b6: [lld][macho] Stop grouping symbols by sections in mapfile. (authored by Roger, committed by int3).
Changed prior to commit:
https://reviews.llvm.org/D114735?vs=396048&id=401737#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114735/new/
https://reviews.llvm.org/D114735
Files:
lld/MachO/MapFile.cpp
lld/test/MachO/map-file.s
Index: lld/test/MachO/map-file.s
===================================================================
--- lld/test/MachO/map-file.s
+++ lld/test/MachO/map-file.s
@@ -47,8 +47,8 @@
# CHECK-NEXT: # Symbols:
# CHECK-NEXT: # Address File Name
-# CHECK-NEXT: 0x[[#NUMBER]] [ 1] _number
# CHECK-NEXT: 0x[[#MAIN]] [ 1] _main
# CHECK-NEXT: 0x[[#FOO]] [ 2] _foo
+# CHECK-NEXT: 0x[[#NUMBER]] [ 1] _number
# MAPFILE: "name":"Total Write map file"
Index: lld/MachO/MapFile.cpp
===================================================================
--- lld/MachO/MapFile.cpp
+++ lld/MachO/MapFile.cpp
@@ -40,26 +40,6 @@
using namespace lld;
using namespace lld::macho;
-using SymbolMapTy = DenseMap<const InputSection *, SmallVector<Defined *, 4>>;
-
-// Returns a map from sections to their symbols.
-static SymbolMapTy getSectionSyms(ArrayRef<Defined *> syms) {
- SymbolMapTy ret;
- for (Defined *dr : syms)
- ret[dr->isec].push_back(dr);
-
- // Sort symbols by address. We want to print out symbols in the order they
- // appear in the output file rather than the order they appeared in the input
- // files.
- for (auto &it : ret)
- parallelSort(
- it.second.begin(), it.second.end(), [](Defined *a, Defined *b) {
- return a->getVA() != b->getVA() ? a->getVA() < b->getVA()
- : a->getName() < b->getName();
- });
- return ret;
-}
-
// Returns a list of all symbols that we want to print out.
static std::vector<Defined *> getSymbols() {
std::vector<Defined *> v;
@@ -126,7 +106,10 @@
// Collect symbol info that we want to print out.
std::vector<Defined *> syms = getSymbols();
- SymbolMapTy sectionSyms = getSectionSyms(syms);
+ parallelSort(syms.begin(), syms.end(), [](Defined *a, Defined *b) {
+ return a->getVA() != b->getVA() ? a->getVA() < b->getVA()
+ : a->getName() < b->getName();
+ });
DenseMap<Symbol *, std::string> symStr = getSymbolStrings(syms);
// Dump table of sections
@@ -144,15 +127,9 @@
// Dump table of symbols
os << "# Symbols:\n";
os << "# Address\t File Name\n";
- for (InputSection *isec : inputSections) {
- auto symsIt = sectionSyms.find(isec);
- assert(!shouldOmitFromOutput(isec) || (symsIt == sectionSyms.end()));
- if (symsIt == sectionSyms.end())
- continue;
- for (Symbol *sym : symsIt->second) {
- os << format("0x%08llX\t[%3u] %s\n", sym->getVA(),
- readerToFileOrdinal[sym->getFile()], symStr[sym].c_str());
- }
+ for (Symbol *sym : syms) {
+ os << format("0x%08llX\t[%3u] %s\n", sym->getVA(),
+ readerToFileOrdinal[sym->getFile()], symStr[sym].c_str());
}
// TODO: when we implement -dead_strip, we should dump dead stripped symbols
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114735.401737.patch
Type: text/x-patch
Size: 2829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220120/7848762f/attachment.bin>
More information about the llvm-commits
mailing list