//===- 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, which maps address ranges to their // respective contents, plus the input file these contents were originally from. // The contents (typically symbols) are listed in address order. Dead-stripped // contents are included as well. // // # Path: test // # Arch: x86_84 // # Object files: // [ 0] linker synthesized // [ 1] a.o // # Sections: // # Address Size Segment Section // 0x1000005C0 0x0000004C __TEXT __text // # Symbols: // # Address Size File Name // 0x1000005C0 0x00000001 [ 1] _main // # Dead Stripped Symbols: // # Size File Name // <<dead>> 0x00000001 [ 1] _foo // //===----------------------------------------------------------------------===// #include "MapFile.h" #include "ConcatOutputSection.h" #include "Config.h" #include "InputFiles.h" #include "InputSection.h" #include "OutputSegment.h" #include "Symbols.h" #include "SyntheticSections.h" #include "Target.h" #include "lld/Common/ErrorHandler.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Parallel.h" #include "llvm/Support/TimeProfiler.h" usingnamespacellvm; usingnamespacellvm::sys; usingnamespacelld; usingnamespacelld::macho; struct CStringInfo { … }; struct MapInfo { … }; static MapInfo gatherMapInfo() { … } // We use this instead of `toString(const InputFile *)` as we don't want to // include the dylib install name in our output. static void printFileName(raw_fd_ostream &os, const InputFile *f) { … } // For printing the contents of the __stubs and __la_symbol_ptr sections. static void printStubsEntries( raw_fd_ostream &os, const DenseMap<lld::macho::InputFile *, uint32_t> &readerToFileOrdinal, const OutputSection *osec, size_t entrySize) { … } static void printNonLazyPointerSection(raw_fd_ostream &os, NonLazyPointerSectionBase *osec) { … } static uint64_t getSymSizeForMap(Defined *sym) { … } void macho::writeMapFile() { … }