Lines Matching +full:dll +full:- +full:config
1 //===- Chunks.cpp ---------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
38 setRelocs(file->getCOFFObj()->getRelocations(header)); in SectionChunk()
43 if (Expected<StringRef> e = file->getCOFFObj()->getSectionName(header)) in SectionChunk()
49 setAlignment(header->getAlignment()); in SectionChunk()
51 hasData = !(header->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA); in SectionChunk()
54 // enabled, treat non-comdat sections as roots. Generally optimized object in SectionChunk()
55 // files will be built with -ffunction-sections or /Gy, so most things worth in SectionChunk()
58 live = !file->ctx.config.doGC || !isCOMDAT(); in SectionChunk()
76 // sections have section-relative relocations against absolute symbols.
80 if (sec->isCodeView()) in checkSecRel()
90 uint64_t secRel = s - os->getRVA(); in applySecRel()
92 error("overflow in SECREL relocation in section: " + sec->getSectionName()); in applySecRel()
108 add16(off, os->sectionIndex); in applySecIdx()
124 case IMAGE_REL_AMD64_REL32: add32(off, s - p - 4); break; in applyRelX64()
125 case IMAGE_REL_AMD64_REL32_1: add32(off, s - p - 5); break; in applyRelX64()
126 case IMAGE_REL_AMD64_REL32_2: add32(off, s - p - 6); break; in applyRelX64()
127 case IMAGE_REL_AMD64_REL32_3: add32(off, s - p - 7); break; in applyRelX64()
128 case IMAGE_REL_AMD64_REL32_4: add32(off, s - p - 8); break; in applyRelX64()
129 case IMAGE_REL_AMD64_REL32_5: add32(off, s - p - 9); break; in applyRelX64()
131 applySecIdx(off, os, file->ctx.outputSections.size()); in applyRelX64()
149 case IMAGE_REL_I386_REL32: add32(off, s - p - 4); break; in applyRelX86()
151 applySecIdx(off, os, file->ctx.outputSections.size()); in applyRelX86()
213 if (os && (os->header.Characteristics & IMAGE_SCN_MEM_EXECUTE)) in applyRelARM()
223 case IMAGE_REL_ARM_BRANCH20T: applyBranch20T(off, sx - p - 4); break; in applyRelARM()
224 case IMAGE_REL_ARM_BRANCH24T: applyBranch24T(off, sx - p - 4); break; in applyRelARM()
225 case IMAGE_REL_ARM_BLX23T: applyBranch24T(off, sx - p - 4); break; in applyRelARM()
227 applySecIdx(off, os, file->ctx.outputSections.size()); in applyRelARM()
230 case IMAGE_REL_ARM_REL32: add32(off, sx - p - 4); break; in applyRelARM()
245 imm = (s >> shift) - (p >> shift); in applyArm64Addr()
277 if ((imm & ((1 << size) - 1)) != 0) in applyArm64Ldr()
285 applyArm64Imm(off, (s - os->getRVA()) & 0xfff, 0); in applySecRelLow12A()
292 uint64_t secRel = (s - os->getRVA()) >> 12; in applySecRelHigh12A()
295 sec->getSectionName()); in applySecRelHigh12A()
304 applyArm64Ldr(off, (s - os->getRVA()) & 0xfff); in applySecRelLdr()
333 case IMAGE_REL_ARM64_BRANCH26: applyArm64Branch26(off, s - p); break; in applyRelARM64()
334 case IMAGE_REL_ARM64_BRANCH19: applyArm64Branch19(off, s - p); break; in applyRelARM64()
335 case IMAGE_REL_ARM64_BRANCH14: applyArm64Branch14(off, s - p); break; in applyRelARM64()
348 applySecIdx(off, os, file->ctx.outputSections.size()); in applyRelARM64()
350 case IMAGE_REL_ARM64_REL32: add32(off, s - p - 4); break; in applyRelARM64()
365 if (fromChunk->isCodeView() || fromChunk->isDWARF() || isMinGW) in maybeReportRelocationToDiscarded()
370 ObjFile *file = fromChunk->file; in maybeReportRelocationToDiscarded()
373 name = sym->getName(); in maybeReportRelocationToDiscarded()
376 check(file->getCOFFObj()->getSymbol(rel.SymbolTableIndex)); in maybeReportRelocationToDiscarded()
377 name = check(file->getCOFFObj()->getSymbolName(coffSym)); in maybeReportRelocationToDiscarded()
418 write32le(buf - sizeof(uint32_t), entryThunk->getRVA() - rva + 1); in writeTo()
423 auto *sym = dyn_cast_or_null<Defined>(file->getSymbol(rel.SymbolTableIndex)); in applyRelocation()
428 Chunk *c = sym ? sym->getChunk() : nullptr; in applyRelocation()
429 OutputSection *os = c ? file->ctx.getOutputSection(c) : nullptr; in applyRelocation()
437 maybeReportRelocationToDiscarded(this, sym, rel, file->ctx.config.mingw); in applyRelocation()
441 uint64_t s = sym->getRVA(); in applyRelocation()
445 uint64_t imageBase = file->ctx.config.imageBase; in applyRelocation()
471 warn("some relocations in " + file->getName() + " are not sorted"); in sortRelocations()
500 applyRelocation(&buf[rel.VirtualAddress - vaBegin], rel); in writeAndRelocateSubsection()
507 assert(child->assocChildren == nullptr && in addAssociative()
511 for (; next != nullptr; prev = next, next = next->assocChildren) { in addAssociative()
512 if (next->getSectionName() <= child->getSectionName()) in addAssociative()
517 assert(prev->assocChildren == next); in addAssociative()
518 prev->assocChildren = child; in addAssociative()
519 child->assocChildren = next; in addAssociative()
550 // Windows-specific.
552 // fixed by the loader if load-time relocation is needed.
559 Symbol *target = file->getSymbol(rel.SymbolTableIndex); in getBaserels()
562 res->emplace_back(rva + rel.VirtualAddress, ty); in getBaserels()
570 // another DLL) This returns the size the relocation is supposed to update,
588 // *(base + .target) += *(base + .sym) - (base + .sym) in getRuntimePseudoRelocSize()
649 // imported from another DLL).
654 dyn_cast_or_null<Defined>(file->getSymbol(rel.SymbolTableIndex)); in getRuntimePseudoRelocs()
655 if (!target || !target->isRuntimePseudoReloc) in getRuntimePseudoRelocs()
662 if (!target->getChunk()) in getRuntimePseudoRelocs()
665 getRuntimePseudoRelocSize(rel.Type, file->ctx.config.machine); in getRuntimePseudoRelocs()
667 error("unable to automatically import from " + target->getName() + in getRuntimePseudoRelocs()
669 file->getCOFFObj()->getRelocationTypeName(rel.Type) + " in " + in getRuntimePseudoRelocs()
673 int addressSizeInBits = file->ctx.config.is64() ? 64 : 32; in getRuntimePseudoRelocs()
676 "symbol " + target->getName() + " is too narrow (only " + in getRuntimePseudoRelocs()
687 return header->Characteristics & IMAGE_SCN_LNK_COMDAT; in isCOMDAT()
691 // Removed by dead-stripping. If it's removed by ICF, ICF already in printDiscardedMessage()
694 log("Discarded " + sym->getName()); in printDiscardedMessage()
699 return sym->getName(); in getDebugName()
705 cantFail(file->getCOFFObj()->getSectionContents(header, a)); in getContents()
741 if (c->getSectionName() == name) in findByName()
747 p2Align = std::max(p2Align, other->p2Align); in replace()
748 other->repl = repl; in replace()
749 other->live = false; in replace()
755 SectionRef s(r, file->getCOFFObj()); in getSectionNumber()
780 // should be 16-byte aligned. MSVC linker does this too. in ImportThunkChunkX64()
787 write32le(buf + 2, impSymbol->getRVA() - rva - getSize()); in writeTo()
791 res->emplace_back(getRVA() + 2, ctx.config.machine); in getBaserels()
797 write32le(buf + 2, impSymbol->getRVA() + ctx.config.imageBase); in writeTo()
801 res->emplace_back(getRVA(), IMAGE_REL_BASED_ARM_MOV32T); in getBaserels()
807 applyMOV32T(buf, impSymbol->getRVA() + ctx.config.imageBase); in writeTo()
811 int64_t off = impSymbol->getRVA() & 0xfff; in writeTo()
813 applyArm64Addr(buf, impSymbol->getRVA(), rva, 12); in writeTo()
817 // A Thumb2, PIC, non-interworking range extension thunk.
819 0x40, 0xf2, 0x00, 0x0c, // P: movw ip,:lower16:S - (P + (L1-P) + 4)
820 0xc0, 0xf2, 0x00, 0x0c, // movt ip,:upper16:S - (P + (L1-P) + 4)
825 assert(ctx.config.machine == ARMNT); in getSize()
831 assert(ctx.config.machine == ARMNT); in writeTo()
832 uint64_t offset = target->getRVA() - rva - 12; in writeTo()
838 // +/- 4 GB, which is enough for any PE-COFF.
846 assert(ctx.config.machine == ARM64); in getSize()
852 assert(ctx.config.machine == ARM64); in writeTo()
854 applyArm64Addr(buf + 0, target->getRVA(), rva, 12); in writeTo()
855 applyArm64Imm(buf + 4, target->getRVA() & 0xfff, 0); in writeTo()
860 setAlignment(ctx.config.wordsize); in LocalImportChunk()
864 res->emplace_back(getRVA(), ctx.config.machine); in getBaserels()
867 size_t LocalImportChunk::getSize() const { return ctx.config.wordsize; } in getSize()
870 if (ctx.config.is64()) { in writeTo()
871 write64le(buf, sym->getRVA() + ctx.config.imageBase); in writeTo()
873 write32le(buf, sym->getRVA() + ctx.config.imageBase); in writeTo()
881 begin[cnt++] = co.inputChunk->getRVA() + co.offset; in writeTo()
884 "RVA tables should be de-duplicated"); in writeTo()
897 flag.rva = sym.inputChunk->getRVA() + sym.offset; in writeTo()
905 "RVA tables should be de-duplicated"); in writeTo()
916 uint32_t start = entry.first->getRVA(); in writeTo()
918 table[i].Length = entry.last->getRVA() + entry.last->getSize() - start; in writeTo()
943 table[idx + 0] = rpr.sym->getRVA(); in writeTo()
944 table[idx + 1] = rpr.target->getRVA() + rpr.targetOffset; in writeTo()
950 // Windows-specific. This class represents a block in .reloc section.
953 // On Windows, each DLL is linked against a fixed base address and
955 // DLL that overlaps, the loader has to relocate it. To do that, DLLs
957 // up at runtime. If the loader finds that a DLL cannot be loaded to its
959 // base address> - <desired base address> to each offset that is
976 // 0x00000 -- page address (4 bytes)
977 // 16 -- size of this block (4 bytes)
978 // 0xA030 -- entries (2 bytes each)
982 // 0x20000 -- page address (4 bytes)
983 // 12 -- size of this block (4 bytes)
984 // 0xA004 -- entries (2 bytes each)
992 data.resize(alignTo((end - begin) * 2 + 8, 4)); in BaserelChunk()
998 write16le(p, (i->type << 12) | (i->rva - page)); in BaserelChunk()
1026 assert(isPowerOf2_32(c->getAlignment())); in addSection()
1027 uint8_t p2Align = llvm::Log2_32(c->getAlignment()); in addSection()
1031 mc = make<MergeChunk>(c->getAlignment()); in addSection()
1032 mc->sections.push_back(c); in addSection()
1038 if (c->live) in finalizeContents()
1039 builder.add(toStringRef(c->getContents())); in finalizeContents()
1046 if (!c->live) in assignSubsectionRVAs()
1048 size_t off = builder.getOffset(toStringRef(c->getContents())); in assignSubsectionRVAs()
1049 c->setRVA(rva + off); in assignSubsectionRVAs()
1066 size_t AbsolutePointerChunk::getSize() const { return ctx.config.wordsize; } in getSize()
1069 if (ctx.config.is64()) { in writeTo()