diff options
Diffstat (limited to 'lld/lib')
| -rw-r--r-- | lld/lib/ReaderWriter/PECOFF/IdataPass.cpp | 11 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/PECOFF/IdataPass.h | 14 |
2 files changed, 22 insertions, 3 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp index f0e30b40364..45900bb4376 100644 --- a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp +++ b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp @@ -135,6 +135,11 @@ std::vector<uint8_t> DelayImportDirectoryAtom::createContent() { void DelayImportDirectoryAtom::addRelocations( IdataContext &context, StringRef loadName, const std::vector<COFFSharedLibraryAtom *> &sharedAtoms) { + // "ModuleHandle" field + auto *hmodule = new (_alloc) DelayImportHModuleAtom(context); + addDir32NBReloc(this, hmodule, context.ctx.getMachineType(), + offsetof(delay_import_directory_table_entry, ModuleHandle)); + // "NameTable" field std::vector<ImportTableEntryAtom *> nameTable = createImportTableAtoms(context, sharedAtoms, true, ".didat", _alloc); @@ -143,11 +148,11 @@ void DelayImportDirectoryAtom::addRelocations( offsetof(delay_import_directory_table_entry, DelayImportNameTable)); // "Name" field - auto *atom = new (_alloc) + auto *name = new (_alloc) COFFStringAtom(context.dummyFile, context.dummyFile.getNextOrdinal(), ".didat", loadName); - context.file.addAtom(*atom); - addDir32NBReloc(this, atom, context.ctx.getMachineType(), + context.file.addAtom(*name); + addDir32NBReloc(this, name, context.ctx.getMachineType(), offsetof(delay_import_directory_table_entry, Name)); // TODO: emit other fields } diff --git a/lld/lib/ReaderWriter/PECOFF/IdataPass.h b/lld/lib/ReaderWriter/PECOFF/IdataPass.h index efba5835e1d..70f882b489b 100644 --- a/lld/lib/ReaderWriter/PECOFF/IdataPass.h +++ b/lld/lib/ReaderWriter/PECOFF/IdataPass.h @@ -161,6 +161,20 @@ private: } }; +class DelayImportHModuleAtom : public IdataAtom { +public: + explicit DelayImportHModuleAtom(IdataContext &context) + : IdataAtom(context, createContent(context.ctx)) {} + StringRef customSectionName() const override { return ".data"; } + ContentPermissions permissions() const override { return permRW_; } + Alignment alignment() const override { return Alignment(3); } + +private: + std::vector<uint8_t> createContent(const PECOFFLinkingContext &ctx) const { + return std::vector<uint8_t>(ctx.is64Bit() ? 8 : 4, 0); + } +}; + } // namespace idata class IdataPass : public lld::Pass { |

