//===- LLDMapFile.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 /lldmap option. It shows lists in order and // hierarchically the output sections, input sections, input files and // symbol: // // Address Size Align Out File Symbol // 00201000 00000015 4 .text // 00201000 0000000e 4 test.o:(.text) // 0020100e 00000000 0 local // 00201005 00000000 0 f(int) // //===----------------------------------------------------------------------===// #include "LLDMapFile.h" #include "COFFLinkerContext.h" #include "SymbolTable.h" #include "Symbols.h" #include "Writer.h" #include "lld/Common/ErrorHandler.h" #include "llvm/Support/Parallel.h" #include "llvm/Support/TimeProfiler.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; usingnamespacellvm::object; usingnamespacelld; usingnamespacelld::coff; SymbolMapTy; static constexpr char indent8[] = …; // 8 spaces static constexpr char indent16[] = …; // 16 spaces // Print out the first three columns of a line. static void writeHeader(raw_ostream &os, uint64_t addr, uint64_t size, uint64_t align) { … } // Returns a list of all symbols that we want to print out. static std::vector<DefinedRegular *> getSymbols(const COFFLinkerContext &ctx) { … } // Returns a map from sections to their symbols. static SymbolMapTy getSectionSyms(ArrayRef<DefinedRegular *> syms) { … } // Construct a map from symbols to their stringified representations. static DenseMap<DefinedRegular *, std::string> getSymbolStrings(const COFFLinkerContext &ctx, ArrayRef<DefinedRegular *> syms) { … } void lld::coff::writeLLDMapFile(const COFFLinkerContext &ctx) { … }