Lines Matching +full:segment +full:- +full:no +full:- +full:remap
1 //===- PDB.cpp ------------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
83 // order to maintain as much byte-for-byte compatibility as possible.
194 /// these strings need to have their indices re-written to refer to the
205 /// contain string table references which need to be re-written, so we
206 /// collect them all here and re-write them after all subsections have been
243 // https://docs.microsoft.com/en-us/visualstudio/debugger/debug-source-files-common-properties-solution-property-pages-dialog-box
301 builder.getTpiBuilder().addTypeRecords(source->mergedTpi.recs,
302 source->mergedTpi.recSizes,
303 source->mergedTpi.recHashes);
304 builder.getIpiBuilder().addTypeRecords(source->mergedIpi.recs,
305 source->mergedIpi.recSizes,
306 source->mergedIpi.recHashes);
337 return static_cast<SymbolKind>(uint16_t(prefix->RecordKind));
348 prefix->RecordKind = SymbolKind::S_END;
355 // symbol that refers to the type stream index space. So we remap again from
371 if (!ti->isSimple() && !ti->isNoneType()) {
376 newType = idToType->second;
390 source->file->getName(), ti->getIndex()));
397 prefix->RecordKind = uint16_t(kind);
427 warn("symbol scopes are not balanced in " + file->getName());
437 scopeRec->ptrParent = offParent;
438 scopeRec->ptrEnd = offEnd;
480 // Records that go in the globals stream, unless they are function-local.
538 reinterpret_cast<RecordPrefix *>(recordBytes.data())->RecordLen =
539 alignedSize - 2;
540 memset(recordBytes.data() + oldSize, 0, alignedSize - oldSize);
548 prefix->RecordKind = SymbolKind::S_SKIP;
549 prefix->RecordLen = recordBytes.size() - 2;
565 debugChunk->writeAndRelocateSubsection(sectionContents, sym.data(),
569 // Re-map all the type index references.
570 TpiSource *source = debugChunk->file->debugTypesObj;
571 if (!source->remapTypesInSymbolRecord(recordBytes)) {
585 ObjFile *file = debugChunk->file;
590 ArrayRef<uint8_t> sectionContents = debugChunk->getContents();
596 warn("empty symbols subsection in " + file->getName());
599 symsBuffer, [&](CVSymbol sym) -> llvm::Error {
604 --scopeLevel;
616 file->moduleDBI->getModuleIndex(), moduleSymOffset,
637 warn("corrupt symbol records in " + file->getName());
650 for (SectionChunk *debugChunk : file->getDebugChunks()) {
651 if (!debugChunk->live || debugChunk->getSize() == 0 ||
652 debugChunk->getSectionName() != ".debug$S")
655 ArrayRef<uint8_t> sectionContents = debugChunk->getContents();
674 symsBuffer, [&](CVSymbol sym) -> llvm::Error {
713 return static_cast<PDBLinker *>(ctx)->writeAllModuleSymbolRecords(
722 sc.ISect = os ? os->sectionIndex : llvm::pdb::kInvalidStreamIndex;
723 sc.Off = c && os ? c->getRVA() - os->getRVA() : 0;
724 sc.Size = c ? c->getSize() : -1;
726 sc.Characteristics = secChunk->header->Characteristics;
727 sc.Imod = secChunk->file->moduleDBI->getModuleIndex();
728 ArrayRef<uint8_t> contents = secChunk->getContents();
733 sc.Characteristics = os ? os->header.Characteristics : 0;
758 ArrayRef<uint8_t> contents = debugChunk->getContents();
764 debugChunk->sortRelocations();
802 // These appear to relate to cross-module optimization, so we might use
831 ptrdiff_t vaBegin = subsec.data() - sc->getContents().data();
833 auto relocs = sc->getRelocs();
862 debugChunk->writeAndRelocateSubsection(debugChunk->getContents(), subsec,
865 // Remap type indices in inlinee line records in place. Skip the remapping if
866 // there is no type source info.
868 debugChunk->file->debugTypesObj) {
869 TpiSource *source = debugChunk->file->debugTypesObj;
875 TypeIndex &inlinee = *const_cast<TypeIndex *>(&line.Header->Inlinee);
876 if (!source->remapTypeIndex(inlinee, TiRefKind::IndexRef)) {
877 log("bad inlinee line record in " + debugChunk->file->getName() +
892 file.moduleDBI->addDebugSubsection(
899 // We need to re-write string table indices here, so save off all
915 uint32_t offset = iter->FileNameOffset;
924 file.moduleDBI->addUnmergedSymbols(&file, moduleStreamSize -
936 warn("No StringTable subsection was encountered, but there are string "
949 // 32 bit little-endian integer.
955 debugChunk->writeAndRelocateSubsection(debugChunk->getContents(),
958 // Use of memcpy here avoids violating type-based aliasing rules.
981 file.moduleDBI->setStringTableFixups(std::move(stringTableFixups));
983 // Make a new file checksum table that refers to offsets in the PDB-wide
995 newChecksums->addChecksum(filename, fc.Kind, fc.Checksum);
998 newChecksums->calculateSerializedSize() &&
1001 file.moduleDBI->addDebugSubsection(std::move(newChecksums));
1028 if (!source->file)
1035 DebugSHandler dsh(*this, *source->file);
1037 for (SectionChunk *debugChunk : source->file->getDebugChunks()) {
1038 if (!debugChunk->live || debugChunk->getSize() == 0)
1041 bool isDebugS = debugChunk->getSectionName() == ".debug$S";
1042 bool isDebugF = debugChunk->getSectionName() == ".debug$F";
1065 // Do any post-processing now that all .debug$S sections have been processed.
1078 bool inArchive = !file->parentName.empty();
1079 objName = inArchive ? file->parentName : file->getName();
1081 StringRef modName = inArchive ? file->getName() : objName.str();
1083 file->moduleDBI = &exitOnErr(dbiBuilder.addModuleInfo(modName));
1084 file->moduleDBI->setObjFileName(objName);
1085 file->moduleDBI->setMergeSymbolsCallback(this, &commitSymbolsForObject);
1087 ArrayRef<Chunk *> chunks = file->getChunks();
1088 uint32_t modi = file->moduleDBI->getModuleIndex();
1092 if (!secChunk || !secChunk->live)
1095 file->moduleDBI->setFirstSectionContrib(sc);
1107 llvm::TimeTraceScope timeScope("Merge types (Non-GHASH)");
1109 if (Error e = source->mergeDebugT(&tMerger)) {
1111 warnUnusable(source->file, std::move(e),
1118 Error typeError = std::move(source->typeMergingError);
1120 warnUnusable(source->file, std::move(typeError),
1130 pub.Name = def->getName().data();
1131 pub.NameLen = def->getName().size();
1135 if (d->getCOFFSymbol().isFunctionDefinition())
1142 OutputSection *os = ctx.getOutputSection(def->getChunk());
1144 pub.Offset = def->getRVA() - os->getRVA();
1145 pub.Segment = os->sectionIndex;
1198 nbTypeRecords += source->nbTypeRecords;
1199 nbTypeRecordsBytes += source->nbTypeRecordsBytes;
1212 // non-external symbols do not appear in the symbol table.
1214 if (def && def->isLive() && def->getChunk()) {
1221 StringRef name = def->getName();
1249 << std::string(80, '-') << '\n';
1256 "Input OBJ files (expanded from all cmd-line inputs)");
1307 << "Run llvm-pdbutil to print details about a particular record:\n";
1308 stream << formatv("llvm-pdbutil dump -{0}s -{0}-index {1:X} {2}\n",
1336 ctx.driver.tar->append(relativeToRoot(data->getBufferIdentifier()),
1337 data->getBuffer());
1355 exitOnErr(builder.addNamedStream(stream, data->getBuffer()));
1378 // Double double-quotes are handled, so that the resulting string can be
1379 // executed again on the cmd-line.
1469 assert(!sec->chunks.empty());
1470 const Chunk *firstChunk = *sec->chunks.begin();
1471 const Chunk *lastChunk = *sec->chunks.rbegin();
1475 cgs.Name = sec->name;
1476 cgs.Segment = os.sectionIndex;
1477 cgs.Offset = firstChunk->getRVA() - os.getRVA();
1478 cgs.Size = lastChunk->getRVA() + lastChunk->getSize() - firstChunk->getRVA();
1479 cgs.Characteristics = sec->characteristics;
1524 if (!file->live)
1527 if (!file->thunkSym)
1530 if (!file->thunkLive)
1533 std::string dll = StringRef(file->dllName).lower();
1537 SmallString<128> libPath = file->parentName;
1544 exitOnErr(dbiBuilder.addModuleInfo(file->dllName));
1551 mod = &exitOnErr(dbiBuilder.addModuleInfo("Import:" + file->dllName));
1552 mod->setObjFileName(libPath);
1555 DefinedImportThunk *thunk = cast<DefinedImportThunk>(file->thunkSym);
1556 Chunk *thunkChunk = thunk->getChunk();
1564 ons.Name = file->dllName;
1569 ts.Name = thunk->getName();
1574 ts.Length = thunkChunk->getSize();
1575 ts.Segment = thunkOS->sectionIndex;
1576 ts.Offset = thunkChunk->getRVA() - thunkOS->getRVA();
1579 mod->addSymbol(codeview::SymbolSerializer::writeOneSymbol(
1581 mod->addSymbol(codeview::SymbolSerializer::writeOneSymbol(
1591 mod->addSymbol(newSym);
1595 thunkSymScope->ptrEnd = mod->getNextSymbolOffset();
1597 mod->addSymbol(newSym);
1600 createSectionContrib(ctx, thunk->getChunk(), mod->getModuleIndex());
1601 mod->setFirstSectionContrib(sc);
1627 memcpy(&buildId->PDB70.Signature, &guid, 16);
1646 buildId->Signature.CVSignature = OMF::Signature::PDB70;
1648 memset(buildId->PDB70.Signature, 0, 16);
1649 buildId->PDB70.Age = 1;
1663 dbiBuilder.setAge(buildId->PDB70.Age);
1667 // debugging tools on Windows expect Microsoft-specific version numbers or
1688 for (Chunk *c : os->chunks) {
1755 const uint32_t secrelReloc = getSecrelReloc(c->getArch());
1757 for (SectionChunk *dbgC : c->file->getDebugChunks()) {
1758 if (dbgC->getSectionName() != ".debug$S")
1763 for (const coff_relocation &r : dbgC->getRelocs()) {
1768 c->file->getSymbols()[r.SymbolTableIndex]))
1769 if (s->getChunk() == c)
1770 secrels[r.VirtualAddress] = s->getValue();
1774 SectionChunk::consumeDebugMagic(dbgC->getContents(), ".debug$S");
1796 size_t offsetInDbgC = bytes.data() - dbgC->getContents().data();
1806 uint32_t offsetInC = i->second + linesTmp.header()->RelocOffset;
1807 if (addr < offsetInC || addr >= offsetInC + linesTmp.header()->CodeSize)
1813 offsetInLinetable = addr - offsetInC;