Lines Matching refs:CP
153 static bool layoutOptionalHeader(COFFParser &CP) { in layoutOptionalHeader() argument
154 if (!CP.isPE()) in layoutOptionalHeader()
156 unsigned PEHeaderSize = CP.is64Bit() ? sizeof(object::pe32plus_header) in layoutOptionalHeader()
158 CP.Obj.Header.SizeOfOptionalHeader = in layoutOptionalHeader()
170 static bool layoutCOFF(COFFParser &CP) { in layoutCOFF() argument
173 CP.SectionTableStart = in layoutCOFF()
174 CP.getHeaderSize() + CP.Obj.Header.SizeOfOptionalHeader; in layoutCOFF()
175 if (CP.isPE()) in layoutCOFF()
176 CP.SectionTableStart += DOSStubSize + sizeof(COFF::PEMagic); in layoutCOFF()
177 CP.SectionTableSize = COFF::SectionSize * CP.Obj.Sections.size(); in layoutCOFF()
180 CP.SectionTableStart + CP.SectionTableSize; in layoutCOFF()
183 for (COFFYAML::Section &S : CP.Obj.Sections) { in layoutCOFF()
186 CP.isPE() ? CP.getFileAlignment() : 4); in layoutCOFF()
188 if (CP.isPE()) in layoutCOFF()
190 alignTo(S.Header.SizeOfRawData, CP.getFileAlignment()); in layoutCOFF()
209 for (std::vector<COFFYAML::Symbol>::iterator i = CP.Obj.Symbols.begin(), in layoutCOFF()
210 e = CP.Obj.Symbols.end(); in layoutCOFF()
221 (i->File.size() + CP.getSymbolSize() - 1) / CP.getSymbolSize(); in layoutCOFF()
231 CP.Obj.Header.NumberOfSections = CP.Obj.Sections.size(); in layoutCOFF()
232 CP.Obj.Header.NumberOfSymbols = NumberOfSymbols; in layoutCOFF()
233 if (NumberOfSymbols > 0 || CP.StringTable.size() > 4) in layoutCOFF()
234 CP.Obj.Header.PointerToSymbolTable = SymbolTableStart; in layoutCOFF()
236 CP.Obj.Header.PointerToSymbolTable = 0; in layoutCOFF()
238 *reinterpret_cast<support::ulittle32_t *>(&CP.StringTable[0]) in layoutCOFF()
239 = CP.StringTable.size(); in layoutCOFF()
297 static uint32_t initializeOptionalHeader(COFFParser &CP, uint16_t Magic, T Header) { in initializeOptionalHeader() argument
300 Header->SectionAlignment = CP.Obj.OptionalHeader->Header.SectionAlignment; in initializeOptionalHeader()
301 Header->FileAlignment = CP.Obj.OptionalHeader->Header.FileAlignment; in initializeOptionalHeader()
304 uint32_t SizeOfHeaders = alignTo(CP.SectionTableStart + CP.SectionTableSize, in initializeOptionalHeader()
308 for (const COFFYAML::Section &S : CP.Obj.Sections) { in initializeOptionalHeader()
326 CP.Obj.OptionalHeader->Header.AddressOfEntryPoint; // RVA in initializeOptionalHeader()
327 Header->ImageBase = CP.Obj.OptionalHeader->Header.ImageBase; in initializeOptionalHeader()
329 CP.Obj.OptionalHeader->Header.MajorOperatingSystemVersion; in initializeOptionalHeader()
331 CP.Obj.OptionalHeader->Header.MinorOperatingSystemVersion; in initializeOptionalHeader()
333 CP.Obj.OptionalHeader->Header.MajorImageVersion; in initializeOptionalHeader()
335 CP.Obj.OptionalHeader->Header.MinorImageVersion; in initializeOptionalHeader()
337 CP.Obj.OptionalHeader->Header.MajorSubsystemVersion; in initializeOptionalHeader()
339 CP.Obj.OptionalHeader->Header.MinorSubsystemVersion; in initializeOptionalHeader()
342 Header->Subsystem = CP.Obj.OptionalHeader->Header.Subsystem; in initializeOptionalHeader()
343 Header->DLLCharacteristics = CP.Obj.OptionalHeader->Header.DLLCharacteristics; in initializeOptionalHeader()
344 Header->SizeOfStackReserve = CP.Obj.OptionalHeader->Header.SizeOfStackReserve; in initializeOptionalHeader()
345 Header->SizeOfStackCommit = CP.Obj.OptionalHeader->Header.SizeOfStackCommit; in initializeOptionalHeader()
346 Header->SizeOfHeapReserve = CP.Obj.OptionalHeader->Header.SizeOfHeapReserve; in initializeOptionalHeader()
347 Header->SizeOfHeapCommit = CP.Obj.OptionalHeader->Header.SizeOfHeapCommit; in initializeOptionalHeader()
352 static bool writeCOFF(COFFParser &CP, raw_ostream &OS) { in writeCOFF() argument
353 if (CP.isPE()) { in writeCOFF()
376 if (CP.useBigObj()) { in writeCOFF()
380 << binary_le(CP.Obj.Header.Machine) in writeCOFF()
381 << binary_le(CP.Obj.Header.TimeDateStamp); in writeCOFF()
387 << binary_le(CP.Obj.Header.NumberOfSections) in writeCOFF()
388 << binary_le(CP.Obj.Header.PointerToSymbolTable) in writeCOFF()
389 << binary_le(CP.Obj.Header.NumberOfSymbols); in writeCOFF()
391 OS << binary_le(CP.Obj.Header.Machine) in writeCOFF()
392 << binary_le(static_cast<int16_t>(CP.Obj.Header.NumberOfSections)) in writeCOFF()
393 << binary_le(CP.Obj.Header.TimeDateStamp) in writeCOFF()
394 << binary_le(CP.Obj.Header.PointerToSymbolTable) in writeCOFF()
395 << binary_le(CP.Obj.Header.NumberOfSymbols) in writeCOFF()
396 << binary_le(CP.Obj.Header.SizeOfOptionalHeader) in writeCOFF()
397 << binary_le(CP.Obj.Header.Characteristics); in writeCOFF()
399 if (CP.isPE()) { in writeCOFF()
400 if (CP.is64Bit()) { in writeCOFF()
402 initializeOptionalHeader(CP, COFF::PE32Header::PE32_PLUS, &PEH); in writeCOFF()
406 uint32_t BaseOfData = initializeOptionalHeader(CP, COFF::PE32Header::PE32, &PEH); in writeCOFF()
411 CP.Obj.OptionalHeader->DataDirectories) { in writeCOFF()
424 assert(OS.tell() == CP.SectionTableStart); in writeCOFF()
426 for (std::vector<COFFYAML::Section>::iterator i = CP.Obj.Sections.begin(), in writeCOFF()
427 e = CP.Obj.Sections.end(); in writeCOFF()
440 assert(OS.tell() == CP.SectionTableStart + CP.SectionTableSize); in writeCOFF()
444 for (std::vector<COFFYAML::Symbol>::iterator I = CP.Obj.Symbols.begin(), in writeCOFF()
445 E = CP.Obj.Symbols.end(); in writeCOFF()
452 for (const COFFYAML::Section &S : CP.Obj.Sections) { in writeCOFF()
470 for (std::vector<COFFYAML::Symbol>::const_iterator i = CP.Obj.Symbols.begin(), in writeCOFF()
471 e = CP.Obj.Symbols.end(); in writeCOFF()
475 if (CP.useBigObj()) in writeCOFF()
489 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
496 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
501 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
503 unsigned SymbolSize = CP.getSymbolSize(); in writeCOFF()
520 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
526 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size); in writeCOFF()
530 if (CP.Obj.Header.PointerToSymbolTable) in writeCOFF()
531 OS.write(&CP.StringTable[0], CP.StringTable.size()); in writeCOFF()
536 COFFParser CP(Doc); in yaml2coff() local
537 if (!CP.parse()) { in yaml2coff()
542 if (!layoutOptionalHeader(CP)) { in yaml2coff()
546 if (!layoutCOFF(CP)) { in yaml2coff()
550 if (!writeCOFF(CP, Out)) { in yaml2coff()