//===- MapFile.cpp --------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the -Map option. It shows lists in order and // hierarchically the output sections, input sections, input files and // symbol: // // Addr Off Size Out In Symbol // - 00000015 10 .text // - 0000000e 10 test.o:(.text) // - 00000000 5 local // - 00000000 5 f(int) // //===----------------------------------------------------------------------===// #include "MapFile.h" #include "InputElement.h" #include "InputFiles.h" #include "OutputSections.h" #include "OutputSegment.h" #include "SymbolTable.h" #include "Symbols.h" #include "SyntheticSections.h" #include "lld/Common/Strings.h" #include "llvm/ADT/MapVector.h" #include "llvm/Support/Parallel.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; usingnamespacellvm::object; usingnamespacelld; usingnamespacelld::wasm; SymbolMapTy; // Print out the first three columns of a line. static void writeHeader(raw_ostream &os, int64_t vma, uint64_t lma, uint64_t size) { … } // Returns a list of all symbols that we want to print out. static std::vector<Symbol *> getSymbols() { … } // Returns a map from sections to their symbols. static SymbolMapTy getSectionSyms(ArrayRef<Symbol *> syms) { … } // Construct a map from symbols to their stringified representations. // Demangling symbols (which is what toString() does) is slow, so // we do that in batch using parallel-for. static DenseMap<Symbol *, std::string> getSymbolStrings(ArrayRef<Symbol *> syms) { … } void lld::wasm::writeMapFile(ArrayRef<OutputSection *> outputSections) { … }