brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 0f8f206 Raw
127 lines · c
1//===- COFFLinkerContext.h --------------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLD_COFF_COFFLINKERCONTEXT_H10#define LLD_COFF_COFFLINKERCONTEXT_H11 12#include "Chunks.h"13#include "Config.h"14#include "DebugTypes.h"15#include "Driver.h"16#include "InputFiles.h"17#include "PDB.h"18#include "SymbolTable.h"19#include "Writer.h"20#include "lld/Common/CommonLinkerContext.h"21#include "lld/Common/Timer.h"22 23namespace lld::coff {24 25class COFFLinkerContext : public CommonLinkerContext {26public:27  COFFLinkerContext();28  COFFLinkerContext(const COFFLinkerContext &) = delete;29  COFFLinkerContext &operator=(const COFFLinkerContext &) = delete;30  ~COFFLinkerContext() = default;31 32  LinkerDriver driver;33  SymbolTable symtab;34  COFFOptTable optTable;35 36  // A native ARM64 symbol table on ARM64X target.37  std::optional<SymbolTable> hybridSymtab;38 39  // Returns the appropriate symbol table for the specified machine type.40  SymbolTable &getSymtab(llvm::COFF::MachineTypes machine) {41    if (hybridSymtab && machine == ARM64)42      return *hybridSymtab;43    return symtab;44  }45 46  // Invoke the specified callback for each symbol table.47  void forEachSymtab(std::function<void(SymbolTable &symtab)> f) {48    // If present, process the native symbol table first.49    if (hybridSymtab)50      f(*hybridSymtab);51    f(symtab);52  }53 54  // Invoke the specified callback for each active symbol table,55  // skipping the native symbol table on pure ARM64EC targets.56  void forEachActiveSymtab(std::function<void(SymbolTable &symtab)> f) {57    if (symtab.ctx.config.machine == ARM64X)58      f(*hybridSymtab);59    f(symtab);60  }61 62  std::vector<ObjFile *> objFileInstances;63  std::map<std::string, PDBInputFile *> pdbInputFileInstances;64  std::vector<ImportFile *> importFileInstances;65  std::int64_t consumedInputsSize = 0;66 67  MergeChunk *mergeChunkInstances[Log2MaxSectionAlignment + 1] = {};68 69  /// All sources of type information in the program.70  std::vector<TpiSource *> tpiSourceList;71 72  void addTpiSource(TpiSource *tpi) { tpiSourceList.push_back(tpi); }73 74  std::map<llvm::codeview::GUID, TpiSource *> typeServerSourceMappings;75  std::map<uint32_t, TpiSource *> precompSourceMappings;76 77  /// List of all output sections. After output sections are finalized, this78  /// can be indexed by getOutputSection.79  std::vector<OutputSection *> outputSections;80 81  OutputSection *getOutputSection(const Chunk *c) const {82    return c->osidx == 0 ? nullptr : outputSections[c->osidx - 1];83  }84 85  // Fake sections for parsing bitcode files.86  FakeSection ltoTextSection;87  FakeSection ltoDataSection;88  FakeSectionChunk ltoTextSectionChunk;89  FakeSectionChunk ltoDataSectionChunk;90 91  // All timers used in the COFF linker.92  Timer rootTimer;93  Timer inputFileTimer;94  Timer ltoTimer;95  Timer gcTimer;96  Timer icfTimer;97 98  // Writer timers.99  Timer codeLayoutTimer;100  Timer outputCommitTimer;101  Timer totalMapTimer;102  Timer symbolGatherTimer;103  Timer symbolStringsTimer;104  Timer writeTimer;105 106  // PDB timers.107  Timer totalPdbLinkTimer;108  Timer addObjectsTimer;109  Timer typeMergingTimer;110  Timer loadGHashTimer;111  Timer mergeGHashTimer;112  Timer symbolMergingTimer;113  Timer publicsLayoutTimer;114  Timer tpiStreamLayoutTimer;115  Timer diskCommitTimer;116 117  std::optional<PDBStats> pdbStats;118 119  Configuration config;120 121  DynamicRelocsChunk *dynamicRelocs = nullptr;122};123 124} // namespace lld::coff125 126#endif127