brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 5105b79 Raw
84 lines · c
1//===- DLL.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_DLL_H10#define LLD_COFF_DLL_H11 12#include "Chunks.h"13#include "Symbols.h"14 15namespace lld::coff {16 17// Windows-specific.18// IdataContents creates all chunks for the DLL import table.19// You are supposed to call add() to add symbols and then20// call create() to populate the chunk vectors.21class IdataContents {22public:23  void add(DefinedImportData *sym) { imports.push_back(sym); }24  bool empty() { return imports.empty(); }25 26  void create(COFFLinkerContext &ctx);27 28  std::vector<DefinedImportData *> imports;29  std::vector<Chunk *> dirs;30  std::vector<Chunk *> lookups;31  std::vector<Chunk *> addresses;32  std::vector<Chunk *> hints;33  std::vector<Chunk *> dllNames;34  std::vector<Chunk *> auxIat;35  std::vector<Chunk *> auxIatCopy;36};37 38// Windows-specific.39// DelayLoadContents creates all chunks for the delay-load DLL import table.40class DelayLoadContents {41public:42  DelayLoadContents(COFFLinkerContext &ctx) : ctx(ctx) {}43  void add(DefinedImportData *sym) { imports.push_back(sym); }44  bool empty() { return imports.empty(); }45  void create();46  std::vector<Chunk *> getChunks();47  std::vector<Chunk *> getDataChunks();48  ArrayRef<Chunk *> getCodeChunks() { return thunks; }49  ArrayRef<Chunk *> getCodePData() { return pdata; }50  ArrayRef<Chunk *> getCodeUnwindInfo() { return unwindinfo; }51  ArrayRef<Chunk *> getAuxIat() { return auxIat; }52  ArrayRef<Chunk *> getAuxIatCopy() { return auxIatCopy; }53 54  uint64_t getDirRVA() { return dirs[0]->getRVA(); }55  uint64_t getDirSize();56 57private:58  Chunk *newThunkChunk(DefinedImportData *s, Chunk *tailMerge);59  Chunk *newTailMergeChunk(SymbolTable &symtab, Chunk *dir);60  Chunk *newTailMergePDataChunk(SymbolTable &symtab, Chunk *tm);61 62  std::vector<DefinedImportData *> imports;63  std::vector<Chunk *> dirs;64  std::vector<Chunk *> moduleHandles;65  std::vector<Chunk *> addresses;66  std::vector<Chunk *> names;67  std::vector<Chunk *> hintNames;68  std::vector<Chunk *> thunks;69  std::vector<Chunk *> pdata;70  std::vector<Chunk *> unwindinfo;71  std::vector<Chunk *> dllNames;72  std::vector<Chunk *> auxIat;73  std::vector<Chunk *> auxIatCopy;74 75  COFFLinkerContext &ctx;76};77 78// Create all chunks for the DLL export table.79void createEdataChunks(SymbolTable &symtab, std::vector<Chunk *> &chunks);80 81} // namespace lld::coff82 83#endif84