Lines Matching +defs:buffer +defs:file +defs:name
153 // Save off the DebugInfo entry to backfill the file signature (build id)
182 // OutputSection. Collating a collection of PartialSections of same name and
186 StringRef name;
190 int c = name.compare(other.name);
203 // The writer writes a SymbolTable result to a file.
207 : buffer(c.e.outputBuffer), delayIdata(c), ctx(c) {}
242 void markSymbolsWithRelocations(ObjFile *file, SymbolRVASet &usedSymbols);
244 void markSymbolsForRVATable(ObjFile *file,
247 void getSymbolsFromSections(ObjFile *file,
263 void fixPartialSectionChars(StringRef name, uint32_t chars);
266 PartialSection *createPartialSection(StringRef name, uint32_t outChars);
267 PartialSection *findPartialSection(StringRef name, uint32_t outChars);
272 OutputSection *findSection(StringRef name);
283 std::unique_ptr<FileOutputBuffer> &buffer;
332 // The range of .pdata sections in the output file.
384 // Write the section header to a given buffer.
389 // If name is too long, write offset into the string table as a name.
392 assert(!isDebug || name.size() <= COFF::NameSize ||
394 strncpy(hdr->Name, name.data(),
395 std::min(name.size(), (size_t)COFF::NameSize));
494 ObjFile *file = sc->file;
497 file->getCOFFObj()->getRelocations(sc->header);
500 Symbol *relocTarget = file->getSymbol(rel.SymbolTableIndex);
531 // To redirect the relocation, add a symbol to the parent object file's
534 auto insertion = thunkSymtabIndices.insert({{file, thunk}, ~0U});
537 thunkSymbolIndex = file->addRangeThunkSymbol(thunk);
542 // modified. If the relocations point into the object file, allocate new
629 Symbol *relocTarget = sc->file->getSymbol(rel.SymbolTableIndex);
725 uint32_t *buf = (uint32_t *)buffer->getBufferStart();
726 uint32_t size = (uint32_t)(buffer->getBufferSize());
818 if (auto e = buffer->commit())
819 Fatal(ctx) << "failed to write output '" << buffer->getPath()
823 static StringRef getOutputSectionName(StringRef name) {
824 StringRef s = name.split('$').first;
847 void Writer::fixPartialSectionChars(StringRef name, uint32_t chars) {
850 StringRef curName = pSec->name;
851 if (!curName.consume_front(name) ||
856 PartialSection *destSec = createPartialSection(pSec->name, chars);
868 // library consists of one header object, one object file for every imported
885 if (!pSec->name.starts_with(".idata"))
902 (sc1->file->parentName + "/" + sc1->file->getName()).str();
904 (sc2->file->parentName + "/" + sc2->file->getName()).str();
1000 static bool shouldStripSectionSuffix(SectionChunk *sc, StringRef name,
1002 // On MinGW, comdat groups are formed by putting the comdat group name
1003 // after the '$' in the section name. For .eh_frame$<symbol>, that must
1005 // strip the section name trailer. For other sections, such as
1015 return name.starts_with(".text$") || name.starts_with(".data$") ||
1016 name.starts_with(".rdata$") || name.starts_with(".pdata$") ||
1017 name.starts_with(".xdata$") || name.starts_with(".eh_frame$");
1058 auto createSection = [&](StringRef name, uint32_t outChars) {
1059 OutputSection *&sec = sections[{name, outChars}];
1061 sec = make<OutputSection>(name, outChars);
1086 // Then bin chunks by name and output characteristics.
1094 StringRef name = c->getSectionName();
1095 if (shouldStripSectionSuffix(sc, name, ctx.config.mingw))
1096 name = name.split('$').first;
1098 if (name.starts_with(".tls"))
1101 PartialSection *pSec = createPartialSection(name,
1128 StringRef name = getOutputSectionName(pSec->name);
1131 if (name == ".CRT") {
1138 Log(ctx) << "Processing section " << pSec->name << " -> " << name;
1146 (pSec->name == ".idata$5" || pSec->name == ".idata$9"))
1149 OutputSection *sec = createSection(name, outChars);
1158 // Move DISCARDABLE (or non-memory-mapped) sections to the end of file
1165 if (s->name.starts_with(".debug_"))
1258 for (ImportFile *file : ctx.importFileInstances) {
1259 if (!file->live)
1262 std::string dll = StringRef(file->dllName).lower();
1266 if (file->impSym && !isa<DefinedImportData>(file->impSym))
1267 Fatal(ctx) << file->impSym << " was replaced";
1268 DefinedImportData *impSym = cast_or_null<DefinedImportData>(file->impSym);
1269 if (ctx.config.delayLoads.count(StringRef(file->dllName).lower())) {
1270 if (!file->thunkSym)
1271 Fatal(ctx) << "cannot delay-load " << toString(file)
1285 for (ImportFile *file : ctx.importFileInstances) {
1286 if (!file->live)
1289 if (file->thunkSym) {
1290 if (!isa<DefinedImportThunk>(file->thunkSym))
1291 Fatal(ctx) << file->thunkSym << " was replaced";
1292 auto *chunk = cast<DefinedImportThunk>(file->thunkSym)->getChunk();
1297 if (file->auxThunkSym) {
1298 if (!isa<DefinedImportThunk>(file->auxThunkSym))
1299 Fatal(ctx) << file->auxThunkSym << " was replaced";
1300 auto *chunk = cast<DefinedImportThunk>(file->auxThunkSym)->getChunk();
1305 if (file->impchkThunk)
1306 textSec->addChunk(file->impchkThunk);
1461 StringRef name = def->getName();
1462 if (name.size() > COFF::NameSize) {
1464 sym.Name.Offset.Offset = addEntryToStringTable(name);
1467 memcpy(sym.Name.ShortName, name.data(), name.size());
1495 // section which is mapped at runtime also has its name mapped at runtime.
1497 if (sec->name.size() <= COFF::NameSize)
1503 << "section name " << sec->name
1507 sec->setStringTableOff(addEntryToStringTable(sec->name));
1511 for (ObjFile *file : ctx.objFileInstances) {
1512 for (Symbol *b : file->getSymbols()) {
1595 from->name = toName;
1620 // file offsets.
1641 llvm::TimeTraceScope timeScope("Section: ", sec->name);
1680 Err(ctx) << "section larger than 4 GiB: " << sec->name;
1704 uint8_t *buf = buffer->getBufferStart();
1733 assert((buf - buffer->getBufferStart()) % 8 == 0);
1740 assert(coffHeaderOffset == buf - buffer->getBufferStart());
1773 assert(peHeaderOffset == buf - buffer->getBufferStart());
1779 // reason signing the resulting PE file with Authenticode produces a
1840 dataDirOffset64 == buf - buffer->getBufferStart());
1916 buffer->getBufferStart() + coff->PointerToSymbolTable);
1928 buffer = CHECK(
1935 for (ObjFile *file : ctx.objFileInstances) {
1936 if (!file->hasSafeSEH())
1937 Err(ctx) << "/safeseh: " << file->getName()
1939 markSymbolsForRVATable(file, file->getSXDataChunks(), handlers);
1998 // This is a regular, defined, symbol from a COFF file. Mark the symbol as
2013 // Visit all relocations from all section contributions of this object file and
2015 void Writer::markSymbolsWithRelocations(ObjFile *file,
2017 for (Chunk *c : file->getChunks()) {
2031 Symbol *ref = sc->file->getSymbol(reloc.SymbolTableIndex);
2046 for (ObjFile *file : ctx.objFileInstances) {
2047 if (file->hasGuardCF()) {
2062 for (ObjFile *file : ctx.objFileInstances) {
2068 if (file->hasGuardCF()) {
2069 markSymbolsForRVATable(file, file->getGuardFidChunks(), addressTakenSyms);
2070 markSymbolsForRVATable(file, file->getGuardIATChunks(), giatsRVASet);
2071 getSymbolsFromSections(file, file->getGuardIATChunks(), giatsSymbols);
2072 markSymbolsForRVATable(file, file->getGuardLJmpChunks(), longJmpTargets);
2074 markSymbolsWithRelocations(file, addressTakenSyms);
2078 if (file->hasGuardEHCont())
2079 markSymbolsForRVATable(file, file->getGuardEHContChunks(), ehContTargets);
2139 void Writer::getSymbolsFromSections(ObjFile *file,
2154 << " symbol table index section in object " << file;
2162 ArrayRef<Symbol *> objSymbols = file->getSymbols();
2166 << c->getSectionName() << " in object " << file;
2179 void Writer::markSymbolsForRVATable(ObjFile *file,
2183 getSymbolsFromSections(file, symIdxChunks, syms);
2287 << toString(rpr.target->file) << " requires pseudo relocations";
2342 StringRef name = p.first;
2345 if (sec->name == name)
2433 // Write section contents to a mmap'ed file.
2436 uint8_t *buf = buffer->getBufferStart();
2467 // 2) In all cases, the PE COFF file header also contains a timestamp.
2477 // At this point the only fields in the COFF file which remain unset are the
2478 // "timestamp" in the COFF file header, and the ones in the coff debug
2479 // directory. Now we can hash the file and write that hash to the various
2480 // timestamp fields in the file.
2482 reinterpret_cast<const char *>(buffer->getBufferStart()),
2483 buffer->getBufferSize());
2505 uint8_t *buf = buffer->getBufferStart();
2521 return buffer->getBufferStart() + os->getFileOff() + c->getRVA() -
2577 // pointers in the order that they are listed in the object file (top to
2586 StringRef sAObj = sa->file->mb.getBufferIdentifier();
2587 StringRef sBObj = sb->file->mb.getBufferIdentifier();
2596 Log(ctx) << " " << sc->file->mb.getBufferIdentifier().str()
2602 OutputSection *Writer::findSection(StringRef name) {
2604 if (sec->name == name)
2625 llvm::TimeTraceScope timeScope("Base relocations: ", sec->name);
2721 PartialSection *Writer::createPartialSection(StringRef name,
2723 PartialSection *&pSec = partialSections[{name, outChars}];
2726 pSec = make<PartialSection>(name, outChars);
2730 PartialSection *Writer::findPartialSection(StringRef name, uint32_t outChars) {
2731 auto it = partialSections.find({name, outChars});
2747 uint8_t *secBuf = buffer->getBufferStart() + sec->getFileOff();
2773 uint8_t *secBuf = buffer->getBufferStart() + sec->getFileOff();
2833 uint8_t *secBuf = buffer->getBufferStart() + sec->getFileOff();