Path: blob/main/contrib/llvm-project/lld/COFF/DLL.h
34870 views
//===- DLL.h ----------------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLD_COFF_DLL_H9#define LLD_COFF_DLL_H1011#include "Chunks.h"12#include "Symbols.h"1314namespace lld::coff {1516// Windows-specific.17// IdataContents creates all chunks for the DLL import table.18// You are supposed to call add() to add symbols and then19// call create() to populate the chunk vectors.20class IdataContents {21public:22void add(DefinedImportData *sym) { imports.push_back(sym); }23bool empty() { return imports.empty(); }2425void create(COFFLinkerContext &ctx);2627std::vector<DefinedImportData *> imports;28std::vector<Chunk *> dirs;29std::vector<Chunk *> lookups;30std::vector<Chunk *> addresses;31std::vector<Chunk *> hints;32std::vector<Chunk *> dllNames;33};3435// Windows-specific.36// DelayLoadContents creates all chunks for the delay-load DLL import table.37class DelayLoadContents {38public:39DelayLoadContents(COFFLinkerContext &ctx) : ctx(ctx) {}40void add(DefinedImportData *sym) { imports.push_back(sym); }41bool empty() { return imports.empty(); }42void create(Defined *helper);43std::vector<Chunk *> getChunks();44std::vector<Chunk *> getDataChunks();45ArrayRef<Chunk *> getCodeChunks() { return thunks; }46ArrayRef<Chunk *> getCodePData() { return pdata; }47ArrayRef<Chunk *> getCodeUnwindInfo() { return unwindinfo; }4849uint64_t getDirRVA() { return dirs[0]->getRVA(); }50uint64_t getDirSize();5152private:53Chunk *newThunkChunk(DefinedImportData *s, Chunk *tailMerge);54Chunk *newTailMergeChunk(Chunk *dir);55Chunk *newTailMergePDataChunk(Chunk *tm, Chunk *unwind);56Chunk *newTailMergeUnwindInfoChunk();5758Defined *helper;59std::vector<DefinedImportData *> imports;60std::vector<Chunk *> dirs;61std::vector<Chunk *> moduleHandles;62std::vector<Chunk *> addresses;63std::vector<Chunk *> names;64std::vector<Chunk *> hintNames;65std::vector<Chunk *> thunks;66std::vector<Chunk *> pdata;67std::vector<Chunk *> unwindinfo;68std::vector<Chunk *> dllNames;6970COFFLinkerContext &ctx;71};7273// Windows-specific.74// EdataContents creates all chunks for the DLL export table.75class EdataContents {76public:77EdataContents(COFFLinkerContext &ctx);78std::vector<Chunk *> chunks;7980uint64_t getRVA() { return chunks[0]->getRVA(); }81uint64_t getSize() {82return chunks.back()->getRVA() + chunks.back()->getSize() - getRVA();83}8485COFFLinkerContext &ctx;86};8788} // namespace lld::coff8990#endif919293