Lines Matching refs:CP

168 static bool layoutOptionalHeader(COFFParser &CP) {  in layoutOptionalHeader()  argument
169 if (!CP.isPE()) in layoutOptionalHeader()
171 unsigned PEHeaderSize = CP.is64Bit() ? sizeof(object::pe32plus_header) in layoutOptionalHeader()
173 CP.Obj.Header.SizeOfOptionalHeader = in layoutOptionalHeader()
207 static bool layoutCOFF(COFFParser &CP) { in layoutCOFF() argument
210 CP.SectionTableStart = in layoutCOFF()
211 CP.getHeaderSize() + CP.Obj.Header.SizeOfOptionalHeader; in layoutCOFF()
212 if (CP.isPE()) in layoutCOFF()
213 CP.SectionTableStart += DOSStubSize + sizeof(COFF::PEMagic); in layoutCOFF()
214 CP.SectionTableSize = COFF::SectionSize * CP.Obj.Sections.size(); in layoutCOFF()
217 CP.SectionTableStart + CP.SectionTableSize; in layoutCOFF()
219 for (COFFYAML::Section &S : CP.Obj.Sections) { in layoutCOFF()
224 CP.StringsAndChecksums); in layoutCOFF()
225 if (CP.StringsAndChecksums.hasChecksums() && in layoutCOFF()
226 CP.StringsAndChecksums.hasStrings()) in layoutCOFF()
232 for (COFFYAML::Section &S : CP.Obj.Sections) { in layoutCOFF()
235 assert(CP.StringsAndChecksums.hasStrings() && in layoutCOFF()
239 toDebugS(S.DebugS, CP.StringsAndChecksums, CP.Allocator); in layoutCOFF()
243 S.SectionData = CodeViewYAML::toDebugT(S.DebugT, CP.Allocator, S.Name); in layoutCOFF()
246 S.SectionData = CodeViewYAML::toDebugT(S.DebugP, CP.Allocator, S.Name); in layoutCOFF()
249 S.SectionData = CodeViewYAML::toDebugH(*S.DebugH, CP.Allocator); in layoutCOFF()
254 CP.isPE() ? CP.getFileAlignment() : 4); in layoutCOFF()
256 if (CP.isPE()) in layoutCOFF()
258 alignTo(S.Header.SizeOfRawData, CP.getFileAlignment()); in layoutCOFF()
281 for (std::vector<COFFYAML::Symbol>::iterator i = CP.Obj.Symbols.begin(), in layoutCOFF()
282 e = CP.Obj.Symbols.end(); in layoutCOFF()
293 (i->File.size() + CP.getSymbolSize() - 1) / CP.getSymbolSize(); in layoutCOFF()
303 CP.Obj.Header.NumberOfSections = CP.Obj.Sections.size(); in layoutCOFF()
304 CP.Obj.Header.NumberOfSymbols = NumberOfSymbols; in layoutCOFF()
305 if (NumberOfSymbols > 0 || CP.StringTable.size() > 4) in layoutCOFF()
306 CP.Obj.Header.PointerToSymbolTable = SymbolTableStart; in layoutCOFF()
308 CP.Obj.Header.PointerToSymbolTable = 0; in layoutCOFF()
310 *reinterpret_cast<support::ulittle32_t *>(&CP.StringTable[0]) = in layoutCOFF()
311 CP.StringTable.size(); in layoutCOFF()
351 static uint32_t initializeOptionalHeader(COFFParser &CP, uint16_t Magic, in initializeOptionalHeader() argument
355 Header->SectionAlignment = CP.Obj.OptionalHeader->Header.SectionAlignment; in initializeOptionalHeader()
356 Header->FileAlignment = CP.Obj.OptionalHeader->Header.FileAlignment; in initializeOptionalHeader()
359 uint32_t SizeOfHeaders = alignTo(CP.SectionTableStart + CP.SectionTableSize, in initializeOptionalHeader()
363 for (const COFFYAML::Section &S : CP.Obj.Sections) { in initializeOptionalHeader()
381 CP.Obj.OptionalHeader->Header.AddressOfEntryPoint; // RVA in initializeOptionalHeader()
382 Header->ImageBase = CP.Obj.OptionalHeader->Header.ImageBase; in initializeOptionalHeader()
384 CP.Obj.OptionalHeader->Header.MajorOperatingSystemVersion; in initializeOptionalHeader()
386 CP.Obj.OptionalHeader->Header.MinorOperatingSystemVersion; in initializeOptionalHeader()
387 Header->MajorImageVersion = CP.Obj.OptionalHeader->Header.MajorImageVersion; in initializeOptionalHeader()
388 Header->MinorImageVersion = CP.Obj.OptionalHeader->Header.MinorImageVersion; in initializeOptionalHeader()
390 CP.Obj.OptionalHeader->Header.MajorSubsystemVersion; in initializeOptionalHeader()
392 CP.Obj.OptionalHeader->Header.MinorSubsystemVersion; in initializeOptionalHeader()
395 Header->Subsystem = CP.Obj.OptionalHeader->Header.Subsystem; in initializeOptionalHeader()
396 Header->DLLCharacteristics = CP.Obj.OptionalHeader->Header.DLLCharacteristics; in initializeOptionalHeader()
397 Header->SizeOfStackReserve = CP.Obj.OptionalHeader->Header.SizeOfStackReserve; in initializeOptionalHeader()
398 Header->SizeOfStackCommit = CP.Obj.OptionalHeader->Header.SizeOfStackCommit; in initializeOptionalHeader()
399 Header->SizeOfHeapReserve = CP.Obj.OptionalHeader->Header.SizeOfHeapReserve; in initializeOptionalHeader()
400 Header->SizeOfHeapCommit = CP.Obj.OptionalHeader->Header.SizeOfHeapCommit; in initializeOptionalHeader()
405 static bool writeCOFF(COFFParser &CP, raw_ostream &OS) { in writeCOFF() argument
406 if (CP.isPE()) { in writeCOFF()
429 if (CP.useBigObj()) { in writeCOFF()
434 << binary_le(CP.Obj.Header.Machine) in writeCOFF()
435 << binary_le(CP.Obj.Header.TimeDateStamp); in writeCOFF()
438 << zeros(uint32_t(0)) << binary_le(CP.Obj.Header.NumberOfSections) in writeCOFF()
439 << binary_le(CP.Obj.Header.PointerToSymbolTable) in writeCOFF()
440 << binary_le(CP.Obj.Header.NumberOfSymbols); in writeCOFF()
442 OS << binary_le(CP.Obj.Header.Machine) in writeCOFF()
443 << binary_le(static_cast<int16_t>(CP.Obj.Header.NumberOfSections)) in writeCOFF()
444 << binary_le(CP.Obj.Header.TimeDateStamp) in writeCOFF()
445 << binary_le(CP.Obj.Header.PointerToSymbolTable) in writeCOFF()
446 << binary_le(CP.Obj.Header.NumberOfSymbols) in writeCOFF()
447 << binary_le(CP.Obj.Header.SizeOfOptionalHeader) in writeCOFF()
448 << binary_le(CP.Obj.Header.Characteristics); in writeCOFF()
450 if (CP.isPE()) { in writeCOFF()
451 if (CP.is64Bit()) { in writeCOFF()
453 initializeOptionalHeader(CP, COFF::PE32Header::PE32_PLUS, &PEH); in writeCOFF()
458 initializeOptionalHeader(CP, COFF::PE32Header::PE32, &PEH); in writeCOFF()
463 CP.Obj.OptionalHeader->DataDirectories) { in writeCOFF()
476 assert(OS.tell() == CP.SectionTableStart); in writeCOFF()
478 for (std::vector<COFFYAML::Section>::iterator i = CP.Obj.Sections.begin(), in writeCOFF()
479 e = CP.Obj.Sections.end(); in writeCOFF()
492 assert(OS.tell() == CP.SectionTableStart + CP.SectionTableSize); in writeCOFF()
496 for (std::vector<COFFYAML::Symbol>::iterator I = CP.Obj.Symbols.begin(), in writeCOFF()
497 E = CP.Obj.Symbols.end(); in writeCOFF()
504 for (const COFFYAML::Section &S : CP.Obj.Sections) { in writeCOFF()
533 for (std::vector<COFFYAML::Symbol>::const_iterator i = CP.Obj.Symbols.begin(), in writeCOFF()
534 e = CP.Obj.Symbols.end(); in writeCOFF()
538 if (CP.useBigObj()) in writeCOFF()
551 OS.write_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
559 OS.write_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
565 OS.write_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
568 unsigned SymbolSize = CP.getSymbolSize(); in writeCOFF()
585 OS.write_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
591 OS.write_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
596 if (CP.Obj.Header.PointerToSymbolTable) in writeCOFF()
597 OS.write(&CP.StringTable[0], CP.StringTable.size()); in writeCOFF()
606 COFFParser CP(Doc, ErrHandler); in yaml2coff() local
607 if (!CP.parse()) { in yaml2coff()
612 if (!layoutOptionalHeader(CP)) { in yaml2coff()
617 if (!layoutCOFF(CP)) { in yaml2coff()
621 if (!writeCOFF(CP, Out)) { in yaml2coff()