Lines Matching +full:dll +full:- +full:config
1 //===- DLL.cpp ------------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines various types of chunks for the DLL import or export
10 // descriptor tables. They are inherently Windows-specific.
15 // DLL, you can skip this file, and you should still be able to
18 //===----------------------------------------------------------------------===//
20 #include "DLL.h"
45 // Starts with 2 byte Hint field, followed by a null-terminated string, in getSize()
66 setAlignment(ctx.config.wordsize); in LookupChunk()
68 size_t getSize() const override { return ctx.config.wordsize; } in getSize()
71 if (ctx.config.is64()) in writeTo()
72 write64le(buf, hintName->getRVA()); in writeTo()
74 write32le(buf, hintName->getRVA()); in writeTo()
84 // This chunk represent import-by-ordinal symbols.
90 setAlignment(ctx.config.wordsize); in OrdinalOnlyChunk()
92 size_t getSize() const override { return ctx.config.wordsize; } in getSize()
95 // An import-by-ordinal slot has MSB 1 to indicate that in writeTo()
96 // this is import-by-ordinal (and not import-by-name). in writeTo()
97 if (ctx.config.is64()) { in writeTo()
120 e->ImportLookupTableRVA = lookupTab->getRVA(); in writeTo()
121 e->NameRVA = dllName->getRVA(); in writeTo()
122 e->ImportAddressTableRVA = addressTab->getRVA(); in writeTo()
148 // Group DLL-imported symbols by DLL name because that's how in binImports()
151 return ctx.config.dllOrder[a] < ctx.config.dllOrder[b]; in binImports()
156 m[sym->getDLLName().lower()].push_back(sym); in binImports()
163 return a->getName() < b->getName(); in binImports()
185 e->Attributes = 1; in writeTo()
186 e->Name = dllName->getRVA(); in writeTo()
187 e->ModuleHandle = moduleHandle->getRVA(); in writeTo()
188 e->DelayImportAddressTable = addressTab->getRVA(); in writeTo()
189 e->DelayImportNameTable = nameTab->getRVA(); in writeTo()
198 // Initial contents for delay-loaded functions.
242 0x00, 0x00 // Padding to align on 32-bits
288 0xfd, 0x7b, 0xb3, 0xa9, // stp x29, x30, [sp, #-208]!
325 write32le(buf + 3, imp->getRVA() - rva - 7); in writeTo()
326 write32le(buf + 8, tailMerge->getRVA() - rva - 12); in writeTo()
342 write32le(buf + 39, desc->getRVA() - rva - 43); in writeTo()
343 write32le(buf + 44, helper->getRVA() - rva - 48); in writeTo()
354 // https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#struct-runtime_function in TailMergePDataChunkX64()
361 write32le(buf + 0, tm->getRVA()); // TailMergeChunk start RVA in writeTo()
362 write32le(buf + 4, tm->getRVA() + tm->getSize()); // TailMergeChunk stop RVA in writeTo()
363 write32le(buf + 8, unwind->getRVA()); // UnwindInfo RVA in writeTo()
374 // https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#struct-unwind_info in TailMergeUnwindInfoX64()
395 write32le(buf + 1, imp->getRVA() + ctx.config.imageBase); in writeTo()
396 write32le(buf + 6, tailMerge->getRVA() - rva - 10); in writeTo()
400 res->emplace_back(rva + 1, ctx.config.machine); in getBaserels()
420 write32le(buf + 4, desc->getRVA() + ctx.config.imageBase); in writeTo()
421 write32le(buf + 9, helper->getRVA() - rva - 13); in writeTo()
425 res->emplace_back(rva + 4, ctx.config.machine); in getBaserels()
447 applyMOV32T(buf + 0, imp->getRVA() + ctx.config.imageBase); in writeTo()
448 applyBranch24T(buf + 8, tailMerge->getRVA() - rva - 12); in writeTo()
452 res->emplace_back(rva + 0, IMAGE_REL_BASED_ARM_MOV32T); in getBaserels()
474 applyMOV32T(buf + 14, desc->getRVA() + ctx.config.imageBase); in writeTo()
475 applyBranch24T(buf + 22, helper->getRVA() - rva - 26); in writeTo()
479 res->emplace_back(rva + 14, IMAGE_REL_BASED_ARM_MOV32T); in getBaserels()
500 applyArm64Addr(buf + 0, imp->getRVA(), rva + 0, 12); in writeTo()
501 applyArm64Imm(buf + 4, imp->getRVA() & 0xfff, 0); in writeTo()
502 applyArm64Branch26(buf + 8, tailMerge->getRVA() - rva - 8); in writeTo()
520 applyArm64Addr(buf + 44, desc->getRVA(), rva + 44, 12); in writeTo()
521 applyArm64Imm(buf + 48, desc->getRVA() & 0xfff, 0); in writeTo()
522 applyArm64Branch26(buf + 52, helper->getRVA() - rva - 52); in writeTo()
534 setAlignment(ctx.config.wordsize); in DelayAddressChunk()
536 size_t getSize() const override { return ctx.config.wordsize; } in getSize()
539 if (ctx.config.is64()) { in writeTo()
540 write64le(buf, thunk->getRVA() + ctx.config.imageBase); in writeTo()
544 if (ctx.config.machine == ARMNT) in writeTo()
546 write32le(buf, (thunk->getRVA() + ctx.config.imageBase) | bit); in writeTo()
551 res->emplace_back(rva, ctx.config.machine); in getBaserels()
580 e->NameRVA = dllName->getRVA(); in writeTo()
581 e->OrdinalBase = baseOrdinal; in writeTo()
582 e->AddressTableEntries = (maxOrdinal - baseOrdinal) + 1; in writeTo()
583 e->NumberOfNamePointers = nameTabSize; in writeTo()
584 e->ExportAddressTableRVA = addressTab->getRVA(); in writeTo()
585 e->NamePointerRVA = nameTab->getRVA(); in writeTo()
586 e->OrdinalTableRVA = ordinalTab->getRVA(); in writeTo()
602 : baseOrdinal(baseOrdinal), size((maxOrdinal - baseOrdinal) + 1), in AddressTableChunk()
609 for (const Export &e : ctx.config.exports) { in writeTo()
612 uint8_t *p = buf + (e.ordinal - baseOrdinal) * 4; in writeTo()
615 if (ctx.config.machine == ARMNT && !e.data) in writeTo()
618 write32le(p, e.forwardChunk->getRVA() | bit); in writeTo()
620 assert(cast<Defined>(e.sym)->getRVA() != 0 && in writeTo()
622 write32le(p, cast<Defined>(e.sym)->getRVA() | bit); in writeTo()
640 write32le(buf, c->getRVA()); in writeTo()
657 for (const Export &e : ctx.config.exports) { in writeTo()
662 write16le(buf, e.ordinal - baseOrdinal); in writeTo()
678 // Create .idata contents for each DLL. in create()
682 // If they don't (if they are import-by-ordinals), we store only in create()
686 uint16_t ord = s->getOrdinal(); in create()
687 if (s->getExternalName().empty()) { in create()
692 auto *c = make<HintNameChunk>(s->getExternalName(), ord); in create()
698 lookups.push_back(make<NullChunk>(ctx.config.wordsize)); in create()
699 addresses.push_back(make<NullChunk>(ctx.config.wordsize)); in create()
702 syms[i]->setLocation(addresses[base + i]); in create()
705 dllNames.push_back(make<StringChunk>(syms[0]->getDLLName())); in create()
707 dir->lookupTab = lookups[base]; in create()
708 dir->addressTab = addresses[base]; in create()
741 // Create .didat contents for each DLL. in create()
744 dllNames.push_back(make<StringChunk>(syms[0]->getDLLName())); in create()
755 StringRef extName = s->getExternalName(); in create()
757 names.push_back(make<OrdinalOnlyChunk>(ctx, s->getOrdinal())); in create()
766 s->loadThunkSym = in create()
774 saver().save("__tailMerge_" + syms[0]->getDLLName().lower()); in create()
781 syms[i]->setLocation(addresses[base + i]); in create()
783 mh->setAlignment(8); in create()
787 dir->moduleHandle = mh; in create()
788 dir->addressTab = addresses[base]; in create()
789 dir->nameTab = names[base]; in create()
800 switch (ctx.config.machine) { in newTailMergeChunk()
815 switch (ctx.config.machine) { in newTailMergeUnwindInfoChunk()
824 switch (ctx.config.machine) { in newTailMergePDataChunk()
835 switch (ctx.config.machine) { in newThunkChunk()
851 for (Export &e : ctx.config.exports) { in EdataContents()
856 // https://learn.microsoft.com/en-us/cpp/build/reference/export-exports-a-function?view=msvc-170 in EdataContents()
859 auto *dllName = make<StringChunk>(sys::path::filename(ctx.config.outputFile)); in EdataContents()
862 for (Export &e : ctx.config.exports) in EdataContents()
867 for (Export &e : ctx.config.exports) { in EdataContents()